• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

My LCD NTP clock display on 16*2 is not working

Q&A Forum › Category: ESP8266 › My LCD NTP clock display on 16*2 is not working
0 Vote Up Vote Down
rastogi.rastogisanjay.sanjay asked 2 years ago
  1. I make a digital clock NTP with esp8266 that clock is displayed time date and day.But the code is taken from YouTube channel void loop rbotech nomber36 . But the code is shown an error get formatted Date.then i red your code that said the NTP library is not have date and day.the code is taken from YouTube is that
  2. #include <NTPClient.h>
    #include <ESP8266WiFi.h>
    #include <WiFiUdp.h>
    #include <Wire.h>
    #include <LiquidCrystal_I2C.h>
    LiquidCrystal_I2C lcd(0x27, 16, 2);
    const char *ssid = “**********”;
    const char *password = “*********”;
    WiFiUDP ntpUDP;
    /*
    for PAKISTAN 5
    5X60X60 = 18000

    */
    NTPClient timeClient(ntpUDP, “pool.ntp.org”, 18000, 60000);
    String ImtiazTech[] = {“I”, “m”, “t”, “i”, “a”, “z”, “T”, “e”, “c”, “h”};
    String arr_days[] = {“Sun”, “Mon”, “Tue”, “Wed”, “Thu”, “Fri”, “Sat”};
    String date_time;
    void setup() {
    Serial.begin(115200);
    lcd.begin();
    lcd.backlight();
    lcd.clear();
    WiFi.begin(ssid, password);
    while (WiFi.status() != WL_CONNECTED)
    {
    for (int i = 0; i <= 10; i++)
    {
    lcd.setCursor(i + 3, 0);
    lcd.print(ImtiazTech[i]);
    delay(250);
    Serial.print ( “.” );
    }
    }
    Serial.println(“connected… :)”);
    timeClient.begin();
    lcd.clear();
     
    }
    void loop() {
    timeClient.update(); // time update from NTP server
    Serial.print(timeClient.getFormattedTime());
    Serial.print(” “);
    date_time = timeClient.getFormattedDate();
    int index_date = date_time.indexOf(“T”);
    String date = date_time.substring(0, index_date);
    Serial.println(date);
    int hh = timeClient.getHours();
    int mm = timeClient.getMinutes();
    int ss = timeClient.getSeconds();
    lcd.setCursor(1, 0);
    if (hh > 12)
    {
    hh = hh – 12;
    if (hh < 10) {
    lcd.print(0);
    lcd.print(hh);
    }
    else
    {
    lcd.print(hh);
    }

    lcd.print(“:”);
    if (mm < 10) {
    lcd.print(0);
    lcd.print(mm);
    }
    else
    {
    lcd.print(mm);
    }
    lcd.print(“:”);
    if (ss < 10) {
    lcd.print(0);
    lcd.print(ss);
    }
    else
    {
    lcd.print(ss);
    }
    lcd.print(” PM”);
    }
    else
    {
    if (hh < 10) {
    lcd.print(0);
    lcd.print(hh);
    }
    else
    {
    lcd.print(hh);
    }

    lcd.print(“:”);
    if (mm < 10) {
    lcd.print(0);
    lcd.print(mm);
    }
    else
    {
    lcd.print(mm);
    }
    lcd.print(“:”);
    if (ss < 10) {
    lcd.print(0);
    lcd.print(ss);
    }
    else
    {
    lcd.print(ss);
    }
    lcd.print(” AM”);
    }
     
    int day = timeClient.getDay();
    lcd.print(” “);
    lcd.print(arr_days[day]); // it will print day
    lcd.print(” “);
    lcd.setCursor(3, 1);
    lcd.print(date);

    }

  3. That code is shown “get formatted day” you men “get formatted time”.
  4. Please given the answer what can I do 
  5. But your code is shown only on serial monitor how can display on LCD 16*2 
  6. Please help me
  7. Iam thankfully to you.
5 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Hi.
Your problem is probably because you’re not using the right library.
In our example we use
NTP Client library forked by Taranais. Follow the next steps to install this library in your Arduino IDE:

  1. Click here to download the NTP Client library. You should have a .zip folder in your Downloads folder.
  2. Go to Sketch > Library > Include ZIP library and select the library you just downloaded.
  3. Finally, re-open your Arduino IDE

Try to compile the code again.
 
Regards,
Sara

0 Vote Up Vote Down
rastogi.rastogisanjay.sanjay answered 2 years ago

sir
     I downloaded library and compil the sketch but problem is not solve.The code is shown the same error. “get formatted day” . what can i do . sir that code is why not worked. that project is upsed my mind. Please and Please 
solbed this problem i am thankfuly to you.     I am a hobist of electronics but not have knowledg of coding but i larning more whith your books.        thanksfully to you.

0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Hi.
Did you install the library that I’ve sent you?
What is the exact error message? Can you paste it?
Remove any other library related to this that you might have instaled previously and install the one that I’ve sent you.
Regards,
Sara

0 Vote Up Vote Down
rastogi.rastogisanjay.sanjay answered 2 years ago

Sir,
      I am sanjay kumar rastogi . I am very very happy to hellp in my project “NTPClient” LCD 1602 display time.
     Sara Santos i have not more word in english how to thanks to you.I am from INDEA .Whot can i do for you.
    thanks a lot                                                                                       Sanjay Kumar Rastogi
                                                                                   Email== rastogi.rastogisanjay.sanjay@gmail.com

0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Hi.
Is your project working now?
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.