Cool clock with temperature and humidity.

Things used in this project
Hardware components
HARDWARE LIST
 1 DFRobot DHT22 Temperature and Humidity Sensor
 1 Arduino Nano R3
 1 Jumper wires (generic)
 1 Real Time Clock (RTC)
 2 LED Lighting, 16 X 8 LED Matrix
 Hand tools and fabrication machines
Hot glue gun (generic)
Soldering iron (generic)  
Solder Wire, Lead Free
3D Printer (generic)
Story
I just wanted clock with temperature and humidity ;)
Schematics

Code
CODE
 /*MAX7219 Display  Arduino
VCC 5 V
GND GND
DIN 11 (MOSI)
CS  3 (SS)
CLK 13 (SCK)
RTC- clk 6, dat 7, rst 8
DHT22 - D4
Hardware: Arduino Nano v3, Max7219 4x matrix Display, jumper wires, solidering iron,ds 1302 RTC real time clock,DHT22
*/
// Include the required Arduino libraries:
//DHT11
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#define DHTPIN 4 
//MAX
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
//RTC
#include <virtuabotixRTC.h>
virtuabotixRTC myRTC(6, 7, 8);//RTC pins
// Define Max hardware type, size, and output pins:
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
#define CS_PIN 3
#define DHTTYPE    DHT22
DHT dht(DHTPIN, DHTTYPE);
// Create a new instance of the MD_Parola class with hardware SPI connection:
MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
unsigned long time = millis();//idk something for counting
void setup() {
 
  dht.begin();
  //myRTC.setDS1302Time(50, 46, 13, 3, 30, 4, 2021);  //Setting up time
  //max settings
  myDisplay.begin();
  // Set the intensity (brightness) of the display (0-15):
  myDisplay.setIntensity(13);
  // Clear the display:
  myDisplay.displayClear();
  myDisplay.setTextAlignment(PA_CENTER);
  myDisplay.setInvert(true);
  myDisplay.print("Settin");
  myDisplay.setInvert(false);
  delay(6000);
  myDisplay.print("DONE");
  delay(2000);
  myDisplay.displayClear();
}
void loop() {
  float h = dht.readHumidity();//DHT humidity
  float temp = dht.readTemperature();//DHT temperature
  
//TEMP---------------------------------------------------------------------
if(millis()-time > 20000){
  if(millis()-time < 23000){
myDisplay.setTextAlignment(PA_CENTER);
  myDisplay.print("TEMP");
  }
  else{
    if(millis()-time < 39999){
           
  int te = round(temp);
    myDisplay.print((String)te+"*C");
  
  //myDisplay.print(tempC,0);
  delay(1000);
    }
//----HIUMIDITY----------------------------------------------------------
if(millis()-time > 40000){
  if(millis()-time < 43000){
    myDisplay.print("HIUM%");
    }
    else{
    if(millis()-time < 59999){
    int hum = round(h);
    myDisplay.print((String)hum+"%");
    //myDisplay.print(h,0); 
    delay(1000);
    }
    }   
  } 
//----------------DATE---------------------------------------------------
if(millis()-time > 60000){
myDisplay.setTextAlignment(PA_CENTER);
  if(millis()-time < 63000){
    myDisplay.print("DATE");
    }
    else{
    myDisplay.print((String)myRTC.dayofmonth+" / "+myRTC.month);
    delay(10000);
    }   
  } 
//----Counter Reset-------------------------------------------------------
  if(millis()-time > 80000){
   time = millis();     
  }     
  }//end of else---------------------------------------------------------------
 }//end of if------------------------------------------------------------
else{   //HOUR---------------------------------------------------------
   myRTC.updateTime();//time update
myDisplay.setTextAlignment(PA_CENTER);
 //myDisplay.print(myRTC.hours);
 //myDisplay.setTextAlignment(PA_CENTER);
 //myDisplay.print(":");
 //myDisplay.setTextAlignment(PA_RIGHT);
 //myDisplay.print(myRTC.minutes);
 myDisplay.print((String)myRTC.hours+" : "+myRTC.minutes);
 delay(1000);
 
 
}//end of else-----------------------
  //end--------------------------------------
}The article was first published in hackster, April 30, 2021
cr: https://www.hackster.io/Mikiklopsiki/matrix-max7219-32x8-temperature-humidity-clock-982f3e
author: Mikiklopsiki
License      
 All Rights
 Reserved

 0
 More from this category
 
 
 







