Self-adjusting watch with electronic display
- Transfer
- Recovery mode
The main idea was to create a self-adjusting clock 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 (electronic ink) display. All of these modules are connected to the Arduino Nano.
Module connection diagram
Below is the connection diagram of the modules:
- the GPS module uses a serial port for communication,
- The e-Paper display uses 4-line SPI for communication.
Program
The program was written in the Arduino IDE. I used the following libraries:
- TinyGPS ++ - for decoding the received GPS signal and parsing time and date,
- U8g2lib - to control the display of e-Paper,
- Time zone - for managing time and date in a given time zone and supporting daylight saving time (this happens in Eastern Europe, approx. Translator).
Diagram
1. The first step is to initialize the platform: the serial number of the software for receiving data from the GPS module, displaying e-Paper, the initial value for 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 point, 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
# include
# include
# include
# include
# include
// дескриптор 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
Короткая видеопрезентация
Используемые электронные компоненты
1 × 2,9 'дисплей e-Paper (электронные чернила),
1 × Arduino Nano,
1 × НЕО-7М
Исходный код
164955