element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Smart Alarm Clock
  • Challenges & Projects
  • Project14
  • Smart Alarm Clock
  • More
  • Cancel
Smart Alarm Clock
Blog Self-adjusting clock with e-display
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Smart Alarm Clock to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: kk99
  • Date Created: 1 Jul 2018 2:22 PM Date Created
  • Views 5244 views
  • Likes 16 likes
  • Comments 12 comments
  • ardintermediate
  • smartalarmch
  • iot_projects
  • arduino_projects
Related
Recommended

Self-adjusting clock with e-display

kk99
kk99
1 Jul 2018


The basic idea was to create self-adjusting clock which should work in CET time zone with support for daylight saving. As source of time I have used a GPS signal received from NEO-7M module which have serial port. As display I have used a nice 2.9 inch module with e-paper. All this modules are connected to Arduino Nano.image

 

Below there is connection diagram of modules:
- GPS module uses serial for communication,
- e-Paper display uses 4-line SPI for communication.

image

 

Program was written in Arduino IDE. I have used following libraries:

- TinyGPS++ - for decoding of received GPS signal and parsing of time and date,

- U8g2lib - for driving e-paper display,

- Timezone - for managing time and date in given time zone and support of DST.

 

Here is diagram with flow of program:
image

1. First step is initialization of platform: software serial for receiving data from GPS module, e-paper display, initial value of date and time.

2. At second step we are receiving data from serial port. Received GPS signal is parsed.

3. If GPS data is valid we are updating date and time.

4. At this stage we are updating time on e-paper display.

image

Source code is also available in attachment.

/* 
   Self-adjusting clock for CET time zone with DST 
   by kk99 
   2018 
*/

#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#include <SPI.h>
#include <U8g2lib.h>
#include <Timezone.h>
#include <Arduino.h>

// GPS handle
TinyGPSPlus gps;

// EDP handle
U8G2_IL3820_V2_296X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);

// Central European Time
TimeChangeRule CEST = {"CEST", Last, Sun, Mar, 2, 120}; // Central European Summer Time
TimeChangeRule CET = {"CET ", Last, Sun, Oct, 3, 60};   // Central European Standard Time
Timezone CE(CEST, CET);
TimeChangeRule *tcr;

// Serial handle
SoftwareSerial softSerial(3, 2);

void setup() {
  // put your setup code here, to run once:
  u8g2.begin();
  softSerial.begin(9600);
  setTime(00, 00, 00, 01, 01, 1970);
}

void loop() {
  // put your main code here, to run repeatedly:
  readGPSData(1000);
  updateTime();
  displayTime();
  delay(59000);
}

static void readGPSData(unsigned long timeoutMs)
{
  unsigned long start = millis();
  do
  {
    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", hour(local), minute(local));
  u8g2.firstPage();
  do {
    u8g2.setFont(u8g2_font_logisoso78_tn);
    u8g2.drawStr(26, 103, timeValue);
    } while (u8g2.nextPage());
}

 

Here is short video presentation:

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Attachments:
epdClock.zip
  • Sign in to reply

Top Comments

  • genebren
    genebren over 7 years ago +5
    kk99 , Very nice concept. I really like the self-adjusting concept of this clock. The running around and adjusting clocks on day light savings time changes is very frustrating. Did I forget a clock? Did…
  • DAB
    DAB over 7 years ago +5
    Good post. Yes, GPS is a great source for reliable time in addition to position information. DAB
  • kk99
    kk99 over 7 years ago +4
    genebren : Thanks for comment. I think that there is possible further improvements of this clock e.g. - support for a date, - support for multiple time zones, - support for DCF77 as alternative time source…
Parents
  • trafficpro
    trafficpro over 4 years ago

    Hello dear friend! I want to create some clock. But with 7.5 inch display. But the U8g2lib dont work with my display. Can you help me with this problem?

    https://www.waveshare.com/7.5inch-e-paper-hat.htm problem with this display.

    It doesn't work with libraries U8g2lib. Perhaps you have a solution to the problem.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • trafficpro
    trafficpro over 4 years ago

    Hello dear friend! I want to create some clock. But with 7.5 inch display. But the U8g2lib dont work with my display. Can you help me with this problem?

    https://www.waveshare.com/7.5inch-e-paper-hat.htm problem with this display.

    It doesn't work with libraries U8g2lib. Perhaps you have a solution to the problem.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
  • kk99
    kk99 over 4 years ago in reply to trafficpro

    Hi,
    On the vendor page there is example library but it supports only displaying of images:
    https://www.waveshare.com/wiki/7.5inch_e-Paper_HAT

    In my opinion best option for you will be usage of GxEPD2 library instead of U8g2lib:
    https://github.com/ZinggJM/GxEPD2
    Here is simple example for text displaying:
    https://github.com/ZinggJM/GxEPD2/blob/master/examples/GxEPD2_MinimumExample/GxEPD2_MinimumExample.ino

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube