Clock without using RTC in Arduino with Temperature and humi

Clock without using RTC in Arduino with Temperature and humidity indicator

Jan 10, 2018

63432 views

80 respects

Components and supplies

1

DHT11 Temperature & Humidity Sensor (4 pins)

1

Breadboard (generic)

1

Arduino UNO

1

Standard LCD - 16x2 White on Blue

1

Rotary potentiometer (generic)

1

Jumper wires (generic)

3

Button

Project description

Code

Clock without using RTC with temperature and humidity indicator

arduino

Clock without using RTC with temperature and humidity indicator

Clock without using RTC with temperature and humidity indicator

arduino

Clock without using RTC with temperature and humidity indicator

Downloadable files

Clock withou using RTC with Temperature und Humidity indicator

Clock withou using RTC with Temperature und Humidity indicator

Comments

Only logged in users can leave comments

fthtfgh

7 months ago

Hi all that seems to happen is just random characters on my lcd screen ( o?oooOOO/OOO?? ) thing like that, any help would be appreciated thanks.

Anonymous user

2 years ago

hello, dont know if you still look at this place, but why is it that the lcd just lights up? theres nothing showing...

Anonymous user

2 years ago

hey my LDC is not lighting up can you help?

saharshnair

2 years ago

Make sure that youconnect the positive and negative from both ends of the Lcd to the 5V and the GND

Anonymous user

2 years ago

please help the lcd dose not turn on, i have checked the wiring several times and it still won't work

Anonymous user

2 years ago

Sorry to bump an old thread here but just adding my two cents! Thank you to those providing links to the right library and making that correction in the schematic! works beautifully but it bothered me that the whole display line was flashing with the clock seconds and i could just barely see "Read DHT11 failed"on the temp/humidity line (which was false). so i deleted that line. now the display no longer flashes!!

Anonymous user

2 years ago

I Need help ive tried so many things and keep getting this... Arduino: 1.8.12 (Windows 10), Board: "Arduino Uno" sketch_jul18d:10:10: fatal error: SimpleDHT.h: No such file or directory #include <SimpleDHT.h> ^~~~~~~~~~~~~ compilation terminated. exit status 1 SimpleDHT.h: No such file or directory This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

Anonymous user

2 years ago

You need to install that library.

lucaskywalker99

2 years ago

the time is not changing I've tried everything

Anonymous user

2 years ago

This is a very nice project. I like that you added the temperature and humidity display with the DHT11 module. Thank you for sharing it with us. Questions: How accurate is the clock without using an RTC module? I do not know the accuracy of the Arduino quartz crystal (or is it a ceramic resonator?), but I do not think it would be quite as accurate as the timebase in an RTC module. The pictorial diagram shows the hour button ("b_h") connected between digital pin 5 and +5V instead of ground. Was that intentional? I ask because your sketch code sets the pinMode for b_h as INPUT_PULLUP. This implies that the button should be connected to ground instead of +5V. Or am I missing something? Also, the pictorial diagram shows the anode and cathode of the LCD back-light connected directly to (respectively) +5V and ground, with no current-limiting resistor. Did you mean to show a resistor in there? (Or is your back-light 5V incandescent, instead of LED?) Thank you. Ed.

Anonymous user

2 years ago

Thank you for your reply, Ahmad. I read through your sketch code in more detail, after I posted my earlier comment, and I think I see one possible major source of inaccuracy in the clock. In your loop() function, you have your main running clock code in a "while" loop starting at line 91, and there is a "delay(1000)" at line 118. The total execution of the "while" loop will take slightly longer than one second (i.e. one second due to the "delay", plus additional time due to other code executing inside the "while" loop). I believe this will cause your clock to run slightly slower than it should and the error will, of course, accumulate over time. Instead, you could have a global variable (outside of the loop() function) that would keep track of the time of the previous one-second tick, and put your running clock code, and temperature-humidity display in the loop() function, outside of any while loop. (I do not think that your clock-setting code needs to be in a "while" loop either.) Then, every time that the loop() function runs, check the current "millis", and see if one second has accumulated yet, since the last "tick". If not, just return from the loop() function. But if 1 second has actually elapsed since the last "tick" display the new time, temperature and humidity, and update the "tick" timer to the current "millis". If you do this, I think that you might find your clock runs a little more accurately. There could be some slight inaccuracy between the one-second ticks, but that should not accumulate over time and your clock, overall, should keep better time. However, the overall accuracy of the clock would still depend on the accuracy of the 16 MHz Arduino crystal. Your RTC module should do better, I think. I plan to experiment with this some time in the future. (I am currently using my Arduino UNO board to develop another project.) One other possible source of a time base for a clock, is to use the 1.5 V clock module from one of those inexpensive, black, square clock motors (such as you might have in a wall clock). The little circuit board from these motors normally have two leads going to a coil that is used to pulse the little stepper motor. Even though they are very inexpensive, these little clock motor circuits are very accurate. (Think of how often you have to re-set the time on those wall clocks.) Each of the two leads emits a pulse once every two seconds, alternating so that the circuit generates a pulse once per second (once on one lead, then once on the other lead one second later). I think one of these pulses could generate an interrupt to the Arduino, that could be used to syncrhonise the clock every two seconds. Or you could connect the two leads to a simple transistor circuit to logically "or" the pulses together, to generate one pulse per second. So that is another idea to think about. Something else I plan to try in the future. Thanks and very best regards, Ed.

ahmadordi

2 years ago

Hi Ed and sorry for the late answering. Thanks for you valuable advices. I will defenetely try the approaches you mentioned. Actully if I use RTC I will have really accure Clock and it is somehow obvious. In this project I tried to write a program without RTC module. But the approache that you said to make a change in programming method I will apply definitely. I am busy these days with my master thesis because of that I have to postpone this changes to later ;) Best regards Ahmad

ahmadordi

2 years ago

Hi Ed and thank you for your comment. - About accuracy, I should say that unfortunately it is not so accure. I let it run about 3 days and I realized that it's about two minutes behind the actual time. So I would suggest not to use as a real clock ;). I made it like that because I didn't have any RTC at that time :D. - About second question, you are right, I think I made a mistake by making this diagram. Thanks for the attention and thanks that you mentioned it to me. I appreciate it. It is pullup so ground should be connected when we pree the button not +5V. - Actually I don't have any idea about it :D It works for me like that, or maybe my LCD has 5V incandescent, I have to check. Again thanks for your attention :) I will update the diagram as soon as possible and I have a RTC now and I will try to catch some free time to make a real clock with RTC. Best wishes Ahmad

Anonymous user

2 years ago

HI! I'm trying to use this code in Code Composer Studio. Do you think is possible? I'm doing a project using MSP432 LaunchPad. Any advice or help would be great. Great project btw.

saharshnair

2 years ago

How do you set the time?

armanpixel

2 years ago

Hi I checked the schematics and the code I see that all the push button have to connect to gnd as U see one of them had been connected to power and its wrong!

Anonymous user

2 years ago

Hi. I just want to ask that is there anything wrong to the Potentiometer as all the leg in outwards except the middle one.

regwes0310a

2 years ago

when I made it the code only lasted for 1 day!

ahmadordi

2 years ago

It should work properly. What shows it on the LCD after 1 day?

24Ishan

2 years ago

Hi, I like your project. I was wondering how this thing can be set. Right now, it only responds to the second button's click. Also how do you toggle between clock and temperature?

Anonymous user

2 years ago

what do i do when this shows up? Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino/Genuino Uno" sketch_sep10f:11:24: error: SimpleDHT.h : No such file or directory compilation terminated. exit status 1 SimpleDHT.h : No such file or directory This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

saharshnair

2 years ago

You Don't have the simple Dht library. here is the ink for it: https://www.arduinolibraries.info/libraries/simple-dht

Anonymous user

2 years ago

Thank you for a fun saturday project. Well done! Very fun.

Anonymous user

2 years ago

This works great, thank you for a cool first project! if anyone wants to convert the temperature to Fahrenheit, use int temperaturef = int (temperature*1.8)+32; lcd.print((int)temperaturef); in place of lcd.print((int)temperature); (:

Anonymous user

2 years ago

For what is left button? if it's for SET time than it's not working to me

Anonymous user

2 years ago

how do you set up the clock

Anonymous user

2 years ago

Hi I checked the schematics and the code I see that all the push button have to connect to gnd as U see one of them had been connected to power and its wrong!

Anonymous user

2 years ago

Doesn't Work compilation terminated. exit status 1 SimpleDHT.h: No such file or directory Could you give us the file so it can actually work?

Anonymous user

2 years ago

i downloaded the simpleDHT.h (I suggest a link to it so people know what to do) but nothing works, it is just a blue screen on my lcd. i know it works because i have tested it after this project and it still displays wording. i even redid the wiring.

Anonymous user

2 years ago

What changes in the connections if i have an LCD1602 with I2C?

Anonymous user

2 years ago

Great project but a little confusing. The LCD on the photo and the one on the parts list is different via an additional part. What is the connection for the ADA181. What is the reason for the ADA181.

milespeterson101

2 years ago

My Humidity sensor has 4 pins. On the schematic it has one that has 3 pins? Is there a way to make it still work with the one I have? Please help.

leoparkdelrue

2 years ago

The 3rd pin of your sensor is ignored.

Anonymous user

2 years ago

could not get it to work. LCD just lights up. mstrunk4@gmail.com

Anonymous user

2 years ago

Hi I have to say thanks becaz this prj was rly useful for me I checked the schematics and the code I see that all the push button have to connect to gnd as U see one of them had been connected to power and its wrong! RESPECT to ahmad <3

Anonymous user

2 years ago

I got this working for about 3 hours. I even modified it with my own code and it worked. I left it for about 2 hours and I tried to get it to work again, but it wouldn't work. I redid the entire circuit and re-uploaded the base code, and all that I got was an LCD that displays 1 row of characters fully whited out but with decreasing brightness from the top of the character to the bottom. Any fixes? personally, I think I uploaded too much data to the Arduino, but this was one of my first builds, so I'm not very experienced. Any way to delete all previous uploaded code on Arduino, or does it do that automatically?

vedkor980

2 years ago

hey I am having trouble with my project all its doing is it is showing my a blue screen and that's all

Anonymous user

2 years ago

Hola, me parece que al usar interrupciones (attachInterrupt), no se puede usar (delay), porque detiene todo el proceso y no se produce la interrupción. Por eso creo que se retrasa el reloj. Saludos.

Anonymous user

2 years ago

HI ahmadordi! Nice way of showing the time without a RTC. Well done:-)

Anonymous user

2 years ago

I²C module?

yeetus420

2 years ago

ok, i need to try this out. I do have a question. do yo need to toggle between clock and temp/humidity?

Anonymous user

2 years ago

how can I make it

Anonymous user

2 years ago

Ich ich habe ein Problem bei mir steht SETd DHT11 faile und Read DHT11 faile Kann mir einer helfen i am from germany pls translate

french-ishtoast

2 years ago

This works great, thank you for a cool first project! if anyone wants to convert the temperature to Fahrenheit, use int temperaturef = int (temperature*1.8)+32; lcd.print((int)temperaturef); in place of lcd.print((int)temperature); (:

Anonymous user

2 years ago

For what is left button? if it's for SET time than it's not working to me

Anonymous user

3 years ago

What changes in the connections if i have an LCD1602 with I2C?

Anonymous user

3 years ago

Doesn't Work compilation terminated. exit status 1 SimpleDHT.h: No such file or directory Could you give us the file so it can actually work?

Anonymous user

2 years ago

i downloaded the simpleDHT.h (I suggest a link to it so people know what to do) but nothing works, it is just a blue screen on my lcd. i know it works because i have tested it after this project and it still displays wording. i even redid the wiring.

milespeterson101

3 years ago

My Humidity sensor has 4 pins. On the schematic it has one that has 3 pins? Is there a way to make it still work with the one I have? Please help.

leoparkdelrue

2 years ago

The 3rd pin of your sensor is ignored.

Anonymous user

3 years ago

Thank you for a fun saturday project. Well done! Very fun.

Anonymous user

3 years ago

Hi. I just want to ask that is there anything wrong to the Potentiometer as all the leg in outwards except the middle one.

Anonymous user

3 years ago

I Need help ive tried so many things and keep getting this... Arduino: 1.8.12 (Windows 10), Board: "Arduino Uno" sketch_jul18d:10:10: fatal error: SimpleDHT.h: No such file or directory #include <SimpleDHT.h> ^~~~~~~~~~~~~ compilation terminated. exit status 1 SimpleDHT.h: No such file or directory This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

Anonymous user

2 years ago

You need to install that library.

Anonymous user

3 years ago

Great project but a little confusing. The LCD on the photo and the one on the parts list is different via an additional part. What is the connection for the ADA181. What is the reason for the ADA181.

Anonymous user

3 years ago

I got this working for about 3 hours. I even modified it with my own code and it worked. I left it for about 2 hours and I tried to get it to work again, but it wouldn't work. I redid the entire circuit and re-uploaded the base code, and all that I got was an LCD that displays 1 row of characters fully whited out but with decreasing brightness from the top of the character to the bottom. Any fixes? personally, I think I uploaded too much data to the Arduino, but this was one of my first builds, so I'm not very experienced. Any way to delete all previous uploaded code on Arduino, or does it do that automatically?

lucaskywalker99

4 years ago

the time is not changing I've tried everything

vedkor980

4 years ago

hey I am having trouble with my project all its doing is it is showing my a blue screen and that's all

Anonymous user

4 years ago

Sorry to bump an old thread here but just adding my two cents! Thank you to those providing links to the right library and making that correction in the schematic! works beautifully but it bothered me that the whole display line was flashing with the clock seconds and i could just barely see "Read DHT11 failed"on the temp/humidity line (which was false). so i deleted that line. now the display no longer flashes!!

Anonymous user

4 years ago

HI! I'm trying to use this code in Code Composer Studio. Do you think is possible? I'm doing a project using MSP432 LaunchPad. Any advice or help would be great. Great project btw.

armanpixel

4 years ago

Hi I have to say thanks becaz this prj was rly useful for me I checked the schematics and the code I see that all the push button have to connect to gnd as U see one of them had been connected to power and its wrong! RESPECT to ahmad <3

jeske_matthew

4 years ago

how do you set up the clock

armanpixel

2 years ago

Hi I checked the schematics and the code I see that all the push button have to connect to gnd as U see one of them had been connected to power and its wrong!

joshuaqqqq13

4 years ago

how can I make it

saharshnair

4 years ago

How do you set the time?

Anonymous user

2 years ago

Hi I checked the schematics and the code I see that all the push button have to connect to gnd as U see one of them had been connected to power and its wrong!

24Ishan

5 years ago

Hi, I like your project. I was wondering how this thing can be set. Right now, it only responds to the second button's click. Also how do you toggle between clock and temperature?

Anonymous user

5 years ago

hey my LDC is not lighting up can you help?

saharshnair

2 years ago

Make sure that youconnect the positive and negative from both ends of the Lcd to the 5V and the GND

Anonymous user

5 years ago

hello, dont know if you still look at this place, but why is it that the lcd just lights up? theres nothing showing...

mstrunk4

5 years ago

could not get it to work. LCD just lights up. mstrunk4@gmail.com

Anonymous user

5 years ago

I²C module?

Anonymous user

5 years ago

what do i do when this shows up? Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino/Genuino Uno" sketch_sep10f:11:24: error: SimpleDHT.h : No such file or directory compilation terminated. exit status 1 SimpleDHT.h : No such file or directory This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

saharshnair

2 years ago

You Don't have the simple Dht library. here is the ink for it: https://www.arduinolibraries.info/libraries/simple-dht

Anonymous user

6 years ago

Hola, me parece que al usar interrupciones (attachInterrupt), no se puede usar (delay), porque detiene todo el proceso y no se produce la interrupción. Por eso creo que se retrasa el reloj. Saludos.

yeetus420

6 years ago

ok, i need to try this out. I do have a question. do yo need to toggle between clock and temp/humidity?

Anonymous user

6 years ago

please help the lcd dose not turn on, i have checked the wiring several times and it still won't work

Anonymous user

7 years ago

This is a very nice project. I like that you added the temperature and humidity display with the DHT11 module. Thank you for sharing it with us. Questions: How accurate is the clock without using an RTC module? I do not know the accuracy of the Arduino quartz crystal (or is it a ceramic resonator?), but I do not think it would be quite as accurate as the timebase in an RTC module. The pictorial diagram shows the hour button ("b_h") connected between digital pin 5 and +5V instead of ground. Was that intentional? I ask because your sketch code sets the pinMode for b_h as INPUT_PULLUP. This implies that the button should be connected to ground instead of +5V. Or am I missing something? Also, the pictorial diagram shows the anode and cathode of the LCD back-light connected directly to (respectively) +5V and ground, with no current-limiting resistor. Did you mean to show a resistor in there? (Or is your back-light 5V incandescent, instead of LED?) Thank you. Ed.

ahmadordi

2 years ago

Hi Ed and thank you for your comment. - About accuracy, I should say that unfortunately it is not so accure. I let it run about 3 days and I realized that it's about two minutes behind the actual time. So I would suggest not to use as a real clock ;). I made it like that because I didn't have any RTC at that time :D. - About second question, you are right, I think I made a mistake by making this diagram. Thanks for the attention and thanks that you mentioned it to me. I appreciate it. It is pullup so ground should be connected when we pree the button not +5V. - Actually I don't have any idea about it :D It works for me like that, or maybe my LCD has 5V incandescent, I have to check. Again thanks for your attention :) I will update the diagram as soon as possible and I have a RTC now and I will try to catch some free time to make a real clock with RTC. Best wishes Ahmad

ahmadordi

2 years ago

Hi Ed and sorry for the late answering. Thanks for you valuable advices. I will defenetely try the approaches you mentioned. Actully if I use RTC I will have really accure Clock and it is somehow obvious. In this project I tried to write a program without RTC module. But the approache that you said to make a change in programming method I will apply definitely. I am busy these days with my master thesis because of that I have to postpone this changes to later ;) Best regards Ahmad

Anonymous user

2 years ago

Thank you for your reply, Ahmad. I read through your sketch code in more detail, after I posted my earlier comment, and I think I see one possible major source of inaccuracy in the clock. In your loop() function, you have your main running clock code in a "while" loop starting at line 91, and there is a "delay(1000)" at line 118. The total execution of the "while" loop will take slightly longer than one second (i.e. one second due to the "delay", plus additional time due to other code executing inside the "while" loop). I believe this will cause your clock to run slightly slower than it should and the error will, of course, accumulate over time. Instead, you could have a global variable (outside of the loop() function) that would keep track of the time of the previous one-second tick, and put your running clock code, and temperature-humidity display in the loop() function, outside of any while loop. (I do not think that your clock-setting code needs to be in a "while" loop either.) Then, every time that the loop() function runs, check the current "millis", and see if one second has accumulated yet, since the last "tick". If not, just return from the loop() function. But if 1 second has actually elapsed since the last "tick" display the new time, temperature and humidity, and update the "tick" timer to the current "millis". If you do this, I think that you might find your clock runs a little more accurately. There could be some slight inaccuracy between the one-second ticks, but that should not accumulate over time and your clock, overall, should keep better time. However, the overall accuracy of the clock would still depend on the accuracy of the 16 MHz Arduino crystal. Your RTC module should do better, I think. I plan to experiment with this some time in the future. (I am currently using my Arduino UNO board to develop another project.) One other possible source of a time base for a clock, is to use the 1.5 V clock module from one of those inexpensive, black, square clock motors (such as you might have in a wall clock). The little circuit board from these motors normally have two leads going to a coil that is used to pulse the little stepper motor. Even though they are very inexpensive, these little clock motor circuits are very accurate. (Think of how often you have to re-set the time on those wall clocks.) Each of the two leads emits a pulse once every two seconds, alternating so that the circuit generates a pulse once per second (once on one lead, then once on the other lead one second later). I think one of these pulses could generate an interrupt to the Arduino, that could be used to syncrhonise the clock every two seconds. Or you could connect the two leads to a simple transistor circuit to logically "or" the pulses together, to generate one pulse per second. So that is another idea to think about. Something else I plan to try in the future. Thanks and very best regards, Ed.

regwes0310a

7 years ago

when I made it the code only lasted for 1 day!

ahmadordi

2 years ago

It should work properly. What shows it on the LCD after 1 day?

Anonymous user

7 years ago

i had compilation error for my genuino uno board look at this: Arduino:1.8.5 (Windows Store 1.8.10.0) (Windows 10), Płytka:"Arduino/Genuino Uno" C:\\Users\\secret\\Documents\\Arduino\\zegar\\zegar.ino:4:23: fatal error: SimpleDHT.h: No such file or directory #include <SimpleDHT.h> ^ compilation terminated. exit status 1 Błąd kompilacji dla płytki Arduino/Genuino Uno.=COMPILATION ERROR FOR GENUINO UNO Ten raport powinien zawierać więcej informacji jeśli w File -> Preferencje zostanie włączona opcja "Pokaż szczegółowe informacje podczas kompilacji"= THIS REPORT SHOULD CONTAIN MORE INFORMATIONS IF IN FILE-> PREFERENCIONS OPTION "SHOW INFO WHILE COMPILATING "OPTION IS ON

ahmadordi

2 years ago

Hi, maybe you don't have the SimpleDHT.h library?!

Anonymous user

2 years ago

I don't.

zioalex

7 years ago

HI ahmadordi! Nice way of showing the time without a RTC. Well done:-)