harshitmehra2007
Published © GPL3+

Arduino Clock (without rtc) with temperature and humidity

This project is a arduino clock made without using an rtc and it is totally accurate it also displays the temperature and the humidity

BeginnerFull instructions provided2 hours6,040
Arduino Clock (without rtc) with temperature and humidity

Things used in this project

Hardware components

DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Nano 33 BLE Sense
Arduino Nano 33 BLE Sense
×1
I2C 16x2 Arduino LCD Display Module
DFRobot I2C 16x2 Arduino LCD Display Module
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

The connections

Code

Code

C/C++
Just upload it
#include <SimpleDHT.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
int h = Your  hours here;
int m = Your minutes here;
int s = seconds here;
int flag = 0;
int TIME = 0;
const int hs = A0;
const int ms = A1;
int state1 = 0;
int state2 = 0;
int pinDHT11 = 11;
SimpleDHT11 dht11(pinDHT11);

void setup()
{
   pinMode(hs,INPUT_PULLUP);
  pinMode(ms,INPUT_PULLUP);
  lcd.init();
  lcd.init();
  lcd.backlight();
  lcd.print("Made by - ");
 lcd.setCursor(0,1);
 lcd.print("Harshit");
 delay (3000);
 lcd.clear();
}
void loop()
{
  byte temperature = 0;
  byte humidity = 0;
  int err = SimpleDHTErrSuccess;
  if ((err = dht11.read(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess){
    return;
  }
  lcd.setCursor(0, 0);
  s = s + 0.50;
  lcd.print("TIME:" );
  lcd.print(h);
  lcd.print(":");
  lcd.print(m);
  lcd.print(":");
  lcd.print(s);
  if (flag < 12) lcd.print(" AM");
  if (flag == 12) lcd.print(" PM");
  if (flag > 12) lcd.print(" PM");
  if (flag == 24) flag = 0;
  delay(1000);
 lcd.clear();
  if (s == 60)
  {
    s = 0;
    m = m + 1;
  }
  if (m == 60)
  {
    m = 0;
    h = h + 1;
    flag = flag + 1;
  }
  if (h == 13)
  {
    h = 1;
  }
  state1 = digitalRead(hs);
  if (state1 == 0)
  {
    h = h + 1;
    flag = flag + 1;
    if (flag < 12) lcd.print(" AM");
    if (flag == 12) lcd.print(" PM");
    if (flag > 12) lcd.print(" PM");
    if (flag == 24) flag = 0;
    if (h == 13) h = 1;
  }
  state2 = digitalRead(ms);
  if (state2 == 0)
  {
    s = 0;
    m = m + 1;
  }

 s=s+1;
 if(s==60){
  s=0;
  m=m+1;
 }
 if(m==60)
 {
  m=0;
  h=h+1;
 }
 if(h==13)
 {
  h=1;
  flag=flag+1;
  if(flag==2)flag=0;
 }
  lcd.setCursor(0,1);
  lcd.print("Temp= ");
  lcd.setCursor(5,1);
  lcd.print((int)temperature);
  lcd.setCursor(7,1);
  lcd.print("C");
  lcd.setCursor (9,1);
  lcd.print("H=");
  lcd.setCursor(11,1);
  lcd.print((int)humidity);
  lcd.setCursor(13,1);
  lcd.print("%");
}

Credits

harshitmehra2007

harshitmehra2007

3 projects • 2 followers

Comments