Hello, all !!
This is my project of a digital clock with RTC (Real Time Clock) using a LED display of 04 digits and 07 segments including features of temperature and humidity.
To control the display I have used an Arduino Uno and 02 chips 74HC595 (8 bit shift register with output latches).
There are two modules: one for the sensor of temperature (ºC - Celsius / ºF - Fahrenheit degrees) and humidity (% - in percentage) and another module for the RTC.
The assembly is very simple but you need take care with the wiring.
Be patient, follow the schematics and enjoy it.
Step 1: Material
- 01 x DS1307 (Real Time Clock)
- 01 x DHT11 (Temperature and Humidity sensor)
- 02 x 74HC595 (8 bit shift register with output latches - 3 state)
- 08 x Resistors of 150 Ohms (Brown, Green, Brown)
- 01 x FYQ-5642BX (Common Anode LED Display 04 digits and 07 segments or equivalent but take care with the pins numbers)
- 01 x Arduino Uno
- 01 x Breadboard
- 01 x Kit of jumpers
- RTC - DS1307 - Real Time Clock.pdf
- Sensor Temperatura e Umidade - DHT11.pdf
- Display LED 4 Digitos - fyq-5642ax_bx.pdf
Step 2: Assembly
The assembly of components is very easy but you need to follow the schematics with care about the wiring connections.
If you want to use another LED display, check the datasheet to update the output wiring (jumpers) of 74HC595.
Step 3: Programming
To run the program on Arduino you need to have the following libraries:
- Time (library for date & time)
- DS130RTC(library for the Real Time Clock)
- Wire (library used to support the RTC)
- dht11 (library for the sensor of Temperature and Humidity)
For the numbering (0 to 9), I have created a table with binary representation of each segment (A to G) that forms the digit as following:
- B01111110 - 0
- B00110000 - 1
- B01101101 - 2
- B01111001 - 3
- B00110011 - 4
- B01011011 - 5
- B01011111 - 6
- B01110000 - 7
- B01111111 - 8
- B01111011 - 9
To show in the LED display the data in sequence of time, temperature and humidity, I have used a "timer" with functions millis() and while().
In this case, each information is presented on the display and after 3 seconds moves to the next one.
Simple and very efficient.
You can apply this function millis() in several different ways to manage the time during the program running.
In many situations you can use it in the place of some timer library.
Another usefull function is digitalWrite(). With this function you can simplify the writting of data into the shift registers.
Take a look on it in the Arduino's home page at http://arduino.cc/en/Reference/DigitalWrite
- How to setup the time of internal clock of RTC module:
1 - To update or setup the time of RTC module, load the program "SetTime" that you can find here or in the library/example of DS1307RTC on Arduino Software.
2 - Recompile and reload the program of Digital_Clock on Arduino.
With this procedure, the RTC module will keep the right time due its battery pack attached and you do not need to recompile the Digital_Clock program every time you turn it on.
Step 4: Conclusion
The main lesson for me in this project is related to the logic to manage the display (data multiplexing) using shift registers and also the combination of different sensors in same application.
I hope you have enjoyed this project where I also had the opportunity to contribute to you with a little bit more information about Arduino programming.
March 22, 2015
(Last update: 17.Jun.2017)