Close
0%
0%

Kids NTP Clock

A simple clock for my Son's room to help him keep tabs on time and also his morning/evening routine

Similar projects worth following
Version 1 is built around a NodeMCU and a 20x4 LCD display. The clock gets the time from the NTP service, and displaying a hardcoded schedule on the bottom line based on the time.
Future plans: to move to an old Pi model B with 2.8" touchscreen, and retrieve schedule information from a Google calendar.

The plan was to create a simple clock which could help my son with his routine on School days.

I built a really simple version around a NodeMCU and an i2c 20x4 screen, which gets gets the time via WiFi from NTP. 

It's great for the time displaying, and uses a really basic way of providing information; if the time displayed falls between a particular time slot display the corresponding message (get up, get ready, eat breakfast, play time, bed time etc).

This version has been running perfectly for a number of months, however I now want to take it further, with more flexibility over the messages rather than relying on hard-coded slots.

I have an old Pi Model B, 2.8" touch screen and a nice little enclosure, so Version 2 will be built around this; the screen will be much better for displaying an interactive interface for him, and I will look into using Python to read from a Google Calendar to control his prompts.

One thing I would like to explore is running a Python GUI on Raspbian Lite (without full desktop), and running the OS in a read only mode to prevent corruption to the SD card if power is removed.

  • 1 × Nodemcu
  • 1 × 20x4 LCD display
  • 1 × Enclosure To make it look pretty - I used an old Pi case I had

  • V1 Code

    Craig Hissett04/07/2020 at 15:20 0 comments

    #include <NTPClient.h>

    #include <ESP8266WiFi.h>
    #include <WiFiUdp.h>
    #include <LiquidCrystal_I2C.h>
    #include <Wire.h>

    //WiFi Creds
    const char *ssid     = "Insert your router here";
    const char *password = "router password";

    //Clock variables
    const long utcOffsetInSeconds = 0;
    char daysOfTheWeek[7][12] = {"Sunday   ", "Monday   ", "Tuesday  ", "Wednesday", "Thursday ", "Friday   ", "Saturday "};

    // Define NTP Client to get time
    WiFiUDP ntpUDP;
    NTPClient timeClient(ntpUDP, "pool.ntp.org", utcOffsetInSeconds);

    //i2c Screen definitions
    LiquidCrystal_I2C lcd(0x3F, 20, 4);

    uint8_t bell[8]  = {0x4, 0xe, 0xe, 0xe, 0x1f, 0x0, 0x4};
    uint8_t note[8]  = {0x2, 0x3, 0x2, 0xe, 0x1e, 0xc, 0x0};
    uint8_t clock[8] = {0x0, 0xe, 0x15, 0x17, 0x11, 0xe, 0x0};
    uint8_t heart[8] = {0x0, 0xa, 0x1f, 0x1f, 0xe, 0x4, 0x0};
    uint8_t duck[8]  = {0x0, 0xc, 0x1d, 0xf, 0xf, 0x6, 0x0};
    uint8_t check[8] = {0x0, 0x1 ,0x3, 0x16, 0x1c, 0x8, 0x0};
    uint8_t cross[8] = {0x0, 0x1b, 0xe, 0x4, 0xe, 0x1b, 0x0};
    uint8_t retarrow[8] = {  0x1, 0x1, 0x5, 0x9, 0x1f, 0x8, 0x4};

    void setup(){
      Serial.begin(115200);
      Wire.begin(D2, D1); 
      lcd.begin();

      lcd.createChar(0, bell);
      lcd.createChar(1, note);
      lcd.createChar(2, clock);
      lcd.createChar(3, heart);
      lcd.createChar(4, duck);
      lcd.createChar(5, check);
      lcd.createChar(6, cross);
      lcd.createChar(7, retarrow);
      
      lcd.home(); 
      lcd.print("Isaac's Clock   ");
      lcd.write(0);

      WiFi.begin(ssid, password);

      while ( WiFi.status() != WL_CONNECTED ) {
        delay ( 500 );
        Serial.print ( "." );
      }
      
      timeClient.begin();

    }

    void loop() {
      timeClient.update();
      Serial.print(daysOfTheWeek[timeClient.getDay()]);
      Serial.print(", ");
      Serial.print(timeClient.getHours());
      Serial.print(":");
      Serial.print(timeClient.getMinutes());
      Serial.print(":");
      Serial.println(timeClient.getSeconds());
      //Serial.println(timeClient.getFormattedTime());

      lcd.setCursor(0,1);
      lcd.print(timeClient.getFormattedTime());
      lcd.setCursor(11,1);  
      lcd.print(daysOfTheWeek[timeClient.getDay()]);

      displaySchedule();
      
      delay(1000);
    }

    void displaySchedule()
    {
      lcd.setCursor(0,3);
      if(timeClient.getHours() == 23 && timeClient.getMinutes() >= 20 && timeClient.getMinutes() <= 30)
      {
        lcd.print("Test Schedule       ");
      }
      else if(timeClient.getHours() == 19 && timeClient.getMinutes() >= 50 && timeClient.getMinutes() <= 59)
      {
        lcd.print("Put your Pyjamas on ");
      }
      else if(timeClient.getHours() == 20 && timeClient.getMinutes() >= 00 && timeClient.getMinutes() <= 30)
      {
        lcd.print("Isaac Time! :-)     ");
      }
      else if(timeClient.getHours() == 20 && timeClient.getMinutes() >= 30 && timeClient.getMinutes() <= 59)
      {
        lcd.print("Bed time|Sleep time ");
      }
      else if(timeClient.getHours() == 07 && timeClient.getMinutes() >= 00 && timeClient.getMinutes() <= 29)
      {
        lcd.print("Morning! Breakfast  ");
      }
      else if(timeClient.getHours() == 07 && timeClient.getMinutes() >= 30 && timeClient.getMinutes() <= 59)
      {
        lcd.print("Get ready for School");
      }
      else
      {
        lcd.print("                    ");
      }
    }

View project log

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates