Clock Without Using RTC In Arduino With Temperature and Humidity Indicators

by | May 22, 2022 | Arduino, Coding

Introduction

In this Arduino project tutorial, we will create a Clock Without Using RTC In Arduino With Temperature and Humidity Indicators. You will get to learn the step by step procedure along with the source code and explanation of the code. So let us start with our project.

 

Supplies

In order to make a Clock Without Using RTC In Arduino With Temperature and Humidity Indicators, we will require the following components:

Components

Circuit Diagram

Clock Without Using RTC In Arduino With Temperature and Humidity Indicator

Steps To Make A Clock Without Using RTC In Arduino With Temperature And Humidity Indicators

Step 1: Firstly, we need to gather the components on the Physical table or Digital Board.

Step 2: Plug the Potentiometer and the temperature sensor on the BreadBoard.

Temperature Sensor:

Step 3: Connect the GND Terminal of it to the Ground(GND) pin of the Arduino using a black colored wire.

Step 4: Connect the Vout terminal of it to the A1 number pin of the Arduino on the Analog side.

Step 5: Connect the Power terminal of it to the 5V power supply pin of the Arduino Uno.

Potentiometer:

Step 6: Connect the First terminal of it to the 5V power supply pin of the Arduino Uno.

Step 7: Connect the Wiper Terminal of it to the Contrast terminal of the LCD, as shown in the figure.

Step 8: Connect the second terminal of it to the GND pin of the Arduino, as shown in the figure.

LCD:

Step 9: Connect the Ground terminal of the LCD to the GND pin of the Arduino.

Step 10: Connect the Power terminal of it to the 5V power supply pin of the Arduino Uno.

Step 11: Connect the Register Select terminal of the LCD to the 12 number pin of the Arduino.

Step 12: Connect the Read/Write terminal of the LCD to the GND pin of the Arduino.

Step 13: Connect the Enable terminal of the LCD to the 11 number pin of the Arduino.

Step 14: Connect the DB4 terminal of the LCD to the 5-number pin of the Arduino.

Step 15: Connect the DB5 terminal of the LCD to the 4-number pin of the Arduino.

Step 16:Connect the DB6 terminal of the LCD to the 3-number pin of the Arduino.

Step 17: Connect the DB7 terminal of the LCD to the 2 number pin of the Arduino.

Step 18: Connect the LED Anode terminal of the LCD to the Resistor and another end of the resistor to the 5V pin of the Arduino.

Step 19: Connect the LED cathode terminal of the LCD to the GND pin of the Arduino.

Source Code

#include <LiquidCrystal.h>

#include <time.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int val;

int temp = 1;

int hour, min, sec;

void setup()

{

lcd.begin(16, 2);

}

void loop()

{

lcd.setCursor(0, 0);

lcd.print("Time=");

lcd.print(hour);

lcd.print(":");

lcd.print(min);

lcd.print(":");

lcd.print(sec);




lcd.setCursor(0, 1);




val = analogRead(temp);




float mv = ( val/1024.0)*5000;

float cel = mv/10;

float farh = (cel*9)/5 + 32;

float realcel = cel - 49;

lcd.print("TEMP=");

lcd.print(realcel);

lcd.print("*C");

sec=sec+1;

if(sec==60)

{

sec = 0;

min = min+1;

}

if(min==60)

{

min = 0;

hour = hour +1;

}

if(hour==24)

{

hour = 0;

}




delay(1000);




}


Explanation of the Code

In the beginning, we included two libraries.

1. The first one is the Liquid Crystal library to get the temperature from the temperature sensor. The Second one is to display time in seconds. Then we have initialized the library with the numbers of the interface pins in Arduino.

2. After that, we initialized one variable and declared four variables for time.

3. In the setup function, we are setting up the LCD’s number of columns and rows, respectively.

4. In the loop function, we are setting the cursor of the LCD to 0,0.

5. Then, in the first row of the display, we are printing the time in hours:minute:seconds format.

6. Now, we set the LCD’s cursor to 0,1, which means row 1 and column 0.

7. After that, we are reading the temperature and storing its value in a variable.

8. Then, we calculated the temperature in celsius using formulas.

9. Using the if statement, we are changing the time from seconds to minute and from minute to hours.

10. Finally, we have used a delay function of 1000 milliseconds which equates to one second.

Output

On successful completion of this project, we will get the below-demonstrated output.

Clock Without Using RTC In Arduino With Temperature and Humidity Indicator

We will get the time along with the temperature on the LCD screen.

 

You May Also Like To Create…

0 Comments

Submit a Comment

Your email address will not be published.