Introduction: ESP8266 NTP TIMEZONE CLOCK WITH WiFi MANAGER
Running on your ESP8266, this NTP Time Zone Arduino
IDE Sketch will display the exact time on MAX 7219 Display.
The sketch uses the Timezone library of JChristensen which converts the time to daylight summer time and standard time for any region.
Clock Features:-
- Exact Time
- Synchronization of Time With NTP Servers
- Indication, If Time Will Not be Synchronized , Hash before “A”(Am) and “P”(PM)
- Daylight Summer Time and Standard Time for Any Region.
- Saving Access Point Credentials in The Clock Through Web Browser
- Credentials Can Be Erased With a Push Button Switch
The provided libraries will comply only with Arduino IDE 1.6.5 and you must use the provided libraries.
Do not update the libraries after unzipping the provided libraries. It is better you rename your present “libraries” folder and copy all the library files in the new “libraries” folder.
Don’t forget to edit the “Timezone lines” in the sketch for your region. Documentation is available at JChristensen's GitHub page.
Required Hardware.
- Power Supply 3.3V and 5V
- ESP8266
- MAX 7219 LED Display
- Push Button Switch
The Zip folder ESP_NTP_Clock contains, Libraries, Drawing and The Sketch for 7 segment display
The Zip folder 8x32_ESP_NTP contains the libraries for 8x32 Dot Matrix MAX7219 Display.
13 Comments
Question 4 years ago
Is there a way to make it display time in 24 hour format? not everyone needs AM/PM :)
Answer 3 years ago
Yes,
void digitalClockDisplay() {
tmElements_t tm;
char *dayOfWeek;
breakTime(now(), tm);
lc.clearDisplay(0);
// Start with left digit
lc.setDigit(0, 7, int(hour(CE.toLocal(utc, &tcr)) / 10), false);
lc.setDigit(0, 6, (hour(CE.toLocal(utc, &tcr)) % 10), false);
lc.setDigit(0, 4, (minute() / 10), false);
lc.setDigit(0, 3, (minute() % 10), false);
lc.setDigit(0, 1, int(second() / 10), false);
lc.setDigit(0, 0, (second() % 10), false);
//Is it AM or PM
//If PM Display "P" On Last Digit Position 0
/* if (hour(CE.toLocal(utc, &tcr)) >= 12) {
lc.setChar(0, 0, 'P', false);
}
//If AM Display "A" On Last Digit Position 0
else {
lc.setChar(0, 0, 'A', false);
}
*/
}
Question 5 years ago
thank you for your project. is anyway possible to use bigger font's ? something like just HH:MM but with bigger fonts . thank you
5 years ago
Hallo super Job thanks for your work.
i'm doing something wrong, my display is not working correctly :-/
Software / Hardware:
Arduino IDE 1.8.5
Max7219 (LED Version not 7-seg)
ESP8266 E12 Nodemcu
Which Pins (Clk, Din & CS/Load) should i use?
Reply 5 years ago
Steve,
Can you please let me know exact type of display connected. Is it dot matrix 4 in one like the image?
Reply 5 years ago
Yes it the one pictured.
Reply 5 years ago
The sketch/code is for 7 segment LED display and will not work for other type displays. I must modify the sketch to work for 4 in 1 display dot matrix module. I will send it to you once it's ready
Reply 5 years ago
Super thank you.
Reply 5 years ago
Steve,
Sketch and library for 4 in 1 display dot matrix module added. Good Luck
6 years ago
Hallo Great Work!
I live in Germany and i put this
static const char ntpServerName[] = "ptbtime1.ptb.de";
instead of
static const char ntpServerName[] = "time.nist.gov";
So! Only two problems to solve and the clock is perfect for me :-)
1. How can i change from 04.24.00 P to 16-24-00
2. If the board is switched on and the stored Wlan is not on, then comes setup. Is it possible to do this so that the time displayed by the DS3231 and pressing the reset button tries to connect.
Or even without reset button, anyway! Headache the clock is running.
The background is the one where the clock is just Wlan from my iPhone and I'm not there every day. After this possibility many have asked, so would be a milestone for this watch.
For help, I would be grateful.
Also in a forum of your choice.
And sorry for my bad english
Robert
6 years ago
Thanks for this project. I was looking for such cheap clock. I did some modifications by adding a second unit which displays day, month and year. In addition, the libraries included in the ZIP are not neccesary as they are standard. You need to change the line
#include <Time.h> to
#include <TimeLib.h>
------
unsigned int HexToBCD(unsigned int number)
{
unsigned char i = 0;
unsigned int k = 0;
while (number)
{
k = (k) | ((number % 10) << i * 4);
number = number / 10;
i++;
}
return (k);
}
void digitalClockDisplay() {
tmElements_t tm;
char *dayOfWeek;
breakTime(now(), tm);
lc.clearDisplay(0);
// Start with left digit
lc.setDigit(0, 7, int(hour(CE.toLocal(utc, &tcr)) / 10), false);
lc.setDigit(0, 6, (hour(CE.toLocal(utc, &tcr)) % 10), false);
lc.setChar(0, 5, '-', false);
lc.setDigit(0, 4, (minute() / 10), false);
lc.setDigit(0, 3, (minute() % 10), false);
lc.setChar(0, 2, '-', false);
lc.setDigit(0, 1, int(second() / 10), false);
lc.setDigit(0, 0, (second() % 10), false);
lc.setDigit(1, 7, int(day(CE.toLocal(utc, &tcr)) / 10), false);
lc.setDigit(1, 6, (day(CE.toLocal(utc, &tcr)) % 10), true);
lc.setDigit(1, 5, int(month(CE.toLocal(utc, &tcr)) / 10), false);
lc.setDigit(1, 4, (month(CE.toLocal(utc, &tcr)) % 10), true);
unsigned int count_one;
count_one = HexToBCD(year(CE.toLocal(utc, &tcr)));
lc.setDigit(1, 3, ((count_one >> 12) & 0x0F), false);
lc.setDigit(1, 2, ((count_one >> 8) & 0x0F), false);
lc.setDigit(1, 1, ((count_one >> 4) & 0x0F), false);
lc.setDigit(1, 0, (count_one & 0x0F), false);
}
Reply 6 years ago
AdrianCronauer Thanks for your comments. I agree that most of the libraries are standard but I have edited the timezone library by removing all lines related with EEPROM in order to compile
6 years ago
Neat idea :)