📜 ⬆️ ⬇️

Self-adjusting electronic display clock



The main idea was to create self-adjusting clocks that should work in the CET time zone with support for daylight saving time. As a time source, I used the GPS signal received from the NEO-7M module, which has a serial port. As a display unit, I used a 2.9-inch e-Paper display (electronic ink). All of these modules are connected to Arduino Nano.

Module wiring diagram


Below is a diagram of connecting modules:


')

Program




The program was written in the Arduino IDE. I used the following libraries:


Diagram




1. The first step is to initialize the platform: the serial number of the software for receiving data from the GPS module, the display of e-Paper, the initial value of the date and time.

2. In the second stage, we receive data from the serial port. The received GPS signal is analyzed.

3. If the GPS data is valid, we update the date and time.

4. At this stage, we update the time on the e-Paper display.

Source code (also available as an attachment at the end of the article)


/ *      CET  DST  kk99 2018 * / # include <SoftwareSerial.h> # include <TinyGPS ++. h> # include <SPI.h> # include <U8g2lib.h> # include <Timezone.h> # include <Arduino.h> //  GPS TinyGPSPlus gps; //  EDP U8G2_IL3820_V2_296X128_1_4W_HW_SPI u8g2 (U8G2_R0, / * cs = * / 10 , / * dc = * / 9 , / * reset = * / 8 ) ; //   TimeChangeRule CEST = { "CEST" , Last, Sun, Mar, 2 , 120 }; //    TimeChangeRule CET = { "CET" , Last, Sun, Oct, 3 , 60 }; // -    CE (CEST, CET) ; TimeChangeRule * tcr; //   SoftwareSerial softSerial ( 3 , 2 ) ; void setup () { //     ,     : u8g2.begin (); softSerial.begin ( 9600 ); setTime ( 00 , 00 , 00 , 01 , 01 , 1970 ); } void loop () { //        : readGPSData ( 1000 );  (); displayTime ();  ( 59000 ); } static void readGPSData ( unsigned long timeoutMs) { unsigned long start = millis ();  { while (softSerial.available ()) gps.encode (softSerial.read ()); } while (millis () - start <timeoutMs); } static void updateTime ( void ) { if (gps.time.isValid () && gps.date.isValid ()) { setTime (gps.time.hour (), gps.time.minute (), gps.time.second (), gps.date.day (), gps.date.month (), gps.date.year ()) ; } } static void displayTime ( void ) { const unsigned timeLength = 6 ; char timeValue [timeLength]; time_t utc = now (); time_t local = CE.toLocal (utc, & tcr); snprintf (timeValue, timeLength, "% 02d:% 02d" ,  (),  ()); u8g2.firstPage ();  { u8g2.setFont (u8g2_font_logisoso78_tn); u8g2.drawStr ( 26 , 103 , timeValue); } while (u8g2.nextPage ()); } 

Short video presentation



Used electronic components


1 × 2.9 'e-Paper display (electronic ink),
1 × Arduino Nano,
1 × NEO-7M

Source


164955

Source: https://habr.com/ru/post/450102/


All Articles