Real time watch with display on Nano V3

In our blog post today we combine three products: our popular AZ-Delivery Nano V3one, one DS3231 Real-time watchand one 4-digit 7-segment LED display.

These provide a good basis for projects where time plays a role, whether someone wants to make an Arduino-based cuckoo clock, a time-controlled access control, or a clock with RFID tags.

In our project today, the Arduino receives the time from the real-time clock, and displays it on the display. Each module needs only four connections.

We cable the components as follows:

AZ-Delivery Nano V3

DS3231

A5

SCL

A4

SDA

3V3

VCC

GNI

GNI

 

AZ-Delivery Nano V3

4 Digit 7 Segment Display

D2

CLK

D3

GOD

+5V

VCC

GNI

GNI

 

 

Clock Schedule

 

For programming we use the same library as in our eBook for the 4 Digit 7 Segment Display: TM1637Display.h.

We connect the real time clock via the IqC bus. The watch has the address 0x68.

We need the bcdToDec function to convert the binary code we get from the real time clock into decimal numbers.

 

'35; includes <Arduino..h>

'35; includes <TM1637Display.h>
'35; includes <Wire.h>
\35; define RTC/I2C ADDRESS 0x68 // I2C Address of RTC DS3231
 
\35; define CLK 2 // Arduino Pin D2 as CLK (RTC) 
\35; define GOD 3 // Ardiono Pin D3 as DIO (RTC)
 
TM1637Display display(CLK, GOD); // 

u t bdToDec( u t choice )
{    return (u t) ((choice / 16 * 10) + (choice % 16));
}

int pause = 500;
 
int time,minutes,second;     void setup(){   Wire.start();   Serial.start(9600);   display.setBrightness(0x0a);     }
 
void run(){    Wire.start(RTC/I2C ADDRESS); //Construction of connection to address 0x68    Wire.write(0);    Wire.endTransmission();    Wire.requestFrom(RTC/I2C ADDRESS, 7);      second = bdToDec(Wire.read() & 0x7f);    minutes = bdToDec(Wire.read());     time = bdToDec(Wire.read() & 0x3f);           Serial.print(time);      Serial.print(":");      Serial.print(minutes);      Serial.print(":");      Serial.Print(second);               display.showNumberDec(time, true, 2, 0);      display.showNumberDec(minutes, true, 2, 2);    delay(pause);

}

After uploading the code we can check on the serial monitor of the Arduino IDE whether the time is spent every half second.

If everything is connected correctly, the current time appears on the 7-Segment display.

 

Finished construction

 

We have thus created the basis for further projects. How about a bigger display? Sensors for temperature and air pressure for a weather station? Or an MP3 shield that gives you a "cuckoo" every full hour?

 

We hope that you have been inspired by our blog post today and we look forward to your comments. Until the next post by AZ-Delivery, your expert in microelectronics!


 

For arduinoProjects for beginners

2 comments

udo

udo

hallo,

durch diesen code stürzt ständig meine arduino ide ab.

truefirewolf

truefirewolf

Hallo,

zunächst hatte ich mich gefreut mit so wenigen Bauteilen und kurzem Code eine Digitaluhr zu bauen.

Bei genauerer Betrachtung stellt man allerdings fest, dass man die Uhrzeit so nicht einstellen kann, das gibt die Software nicht her.

Es wäre ein außerordentlicher Zufall, wenn die Uhrzeit beim Einschalten genau stimmen würde. Man benötigt ein anderes Programm wie z.B. von der Seite: http://shelvin.de/die-uhrzeit-des-rtc3231-vom-arduino-einstellen/

Betreiben kann man die so eingestellte Uhr dann mit dem oben angegeben Programm. Da die Batterie Jahre halten soll, muss o.g. Prozedur eben auch nur bei Batteriewechsel durchgeführt werden.

truefirewolf

Leave a comment

All comments are moderated before being published

Recommended blog posts

  1. Install ESP32 now from the board manager
  2. Lüftersteuerung Raspberry Pi
  3. Arduino IDE - Programmieren für Einsteiger - Teil 1
  4. ESP32 - das Multitalent
  5. OTA - Over the Air - ESP programming via WLAN