Dot Matrix Clock With NTP Server Using ESP32

Let's turn your conventional clock to IoT.

Introduction

The problem that most of us face when dealing with the conventional wall clock is, the time will start shifting after it runs for a certain period of time. When that happens, you will start to refer to your smartphone clock to get the exact time. So in this tutorial, I will share with you how to create a dot matrix clock and get time from the NTP server using the ESP32 board.

Video

This video will show you how to create dot matrix clock and get time and date from NTP (Network Time Protocol) server using ESP32 board.

Hardware Preparation

This is the list of items used in the video.

Sample Program

This is a sample program to get time from the NTP server and display clock at the dot matrix. Before that, you need to install 3 libraries:

  1. MD_MAX72XX by majicDesigns Version 3.2.1 (Library Manager)
  2. MD_Parola by majicDesigns Version 3.3.0 (Library Manager)
  3. NTPClient by Fabrice Weinberg Version 3.1.0 (ZIP file)
/*
Project: Dot matrix clock with NTP server using ESP32
Board: ESP32 Dev Module (Node32 Lite)
Connections:
ESP32 | Dot Matrix
RAW – VCC
GND – GND
27 – DIN
26 – CS
25 – CLK
External libraries:
– MD_MAX72XX by majicDesigns Version 3.2.1 (Manager)
– MD_Parola by majicDesigns Version 3.3.0 (Manager)
– NTPClient by Fabrice Weinberg Version 3.1.0 (Zip)
https://github.com/taranais/NTPClient/archive/master.zip
*/
#include <WiFi.h>
#include <WiFiClient.h>
const char ssid[] = "Your WiFi SSID"; // WiFi name
const char password[] = "Your WiFi Password"; // WiFi password
#include <NTPClient.h>
#include <WiFiUdp.h>
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP);
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
//#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define HARDWARE_TYPE MD_MAX72XX::ICSTATION_HW
#define MAX_DEVICES 4
#define CLK_PIN 25 // 18 or 25
#define DATA_PIN 27 // 16 or 27
#define CS_PIN 26 // 17 or 26
MD_Parola DotMatrix = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
uint8_t scrollSpeed = 50; // default frame delay value
textEffect_t scrollEffect = PA_SCROLL_LEFT;
textPosition_t scrollAlign = PA_LEFT;
uint16_t scrollPause = 3000; // in milliseconds
long currentMillis = 0;
long previousMillis = 0;
int interval = 1000;
String formattedDate;
String timeStamp, hour, minute, second;
String dateStamp, year, month, date;
char dateBuffer[] = "";
String monthArray[12] = {
" Jan ", " Feb ", " Mar ", " Apr ", " May ", " Jun ",
" Jul ", " Aug ", " Sep ", " Oct ", " Nov ", " Dec "
};
enum {TIME, DATE};
boolean displayMode = TIME;
void setup()
{
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
DotMatrix.begin();
DotMatrix.setIntensity(0);
timeClient.begin();
timeClient.setTimeOffset(28800); // Set offset time in seconds, GMT+8 = 28800
DotMatrix.displayText("NTP Clock by Idris", scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);
displayMode = DATE;
}
void loop()
{
while (!timeClient.update()) {
timeClient.forceUpdate();
}
if (displayMode == DATE && DotMatrix.displayAnimate()) {
DotMatrix.displayReset();
displayMode = TIME;
}
currentMillis = millis();
if (currentMillis – previousMillis > interval &&
displayMode == TIME) {
previousMillis = millis();
// The formattedDate comes with the following format:
// 2018-05-28T16:00:13Z
formattedDate = timeClient.getFormattedDate();
Serial.println(formattedDate);
// Extract date
year = formattedDate.substring(0, 4);
month = formattedDate.substring(5, 7);
month = monthArray[month.toInt() – 1];
date = formattedDate.substring(8, 10);
date = String(date.toInt());
dateStamp = year + ", " + date + month;
dateStamp.toCharArray(dateBuffer, dateStamp.length()+1);
// Extract time
hour = formattedDate.substring(11, 13);
minute = formattedDate.substring(14, 16);
second = formattedDate.substring(17, 19);
if (hour.toInt() == 0) {
hour = String(hour.toInt() + 12);
}
else if (hour.toInt() < 13) {
hour = String(hour.toInt());
}
else {
hour = String(hour.toInt() – 12);
}
if (second.toInt() == 0) {
displayMode = DATE;
DotMatrix.displayClear();
DotMatrix.displayText(dateBuffer, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);
return;
}
else if (second.toInt() % 2) {
timeStamp = hour + ":" + minute;
}
else {
timeStamp = hour + " " + minute;
}
DotMatrix.setTextAlignment(PA_CENTER);
DotMatrix.print(timeStamp);
}
}

view raw
ESP32NTPClock.ino
hosted with ❤ by GitHub

Thank You

References:

  1. Displaying on MAX7219 Dot Matrix Using Arduino
  2. Getting Date and Time with ESP32 on Arduino IDE (NTP Client)
  3. ESP32 Pinout References

Thanks for reading this tutorial. If you have any technical inquiries, please post at Cytron Technical Forum.

6 thoughts on “Dot Matrix Clock With NTP Server Using ESP32”

  1. Hi. I tried to run using the sample code. But somehow cannot as it got few errors. I need help for this. Please contact me.

    The error were:

    Arduino: 1.8.15 (Windows 10), Board: “ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None”

    ESP32NTPClock:22:1: error: stray ‘\342’ in program

    const char ssid[] = “TINKER”; // WiFi name

    ^

    ESP32NTPClock:22:1: error: stray ‘\200’ in program

    ESP32NTPClock:22:1: error: stray ‘\234’ in program

    ESP32NTPClock:22:1: error: stray ‘\342’ in program

    ESP32NTPClock:22:1: error: stray ‘\200’ in program

    ESP32NTPClock:22:1: error: stray ‘\235’ in program

    ESP32NTPClock:23:1: error: stray ‘\342’ in program

    const char password[] = “fatin241”; // WiFi password

    ^

    ESP32NTPClock:23:1: error: stray ‘\200’ in program

    ESP32NTPClock:23:1: error: stray ‘\234’ in program

    ESP32NTPClock:23:1: error: stray ‘\342’ in program

    ESP32NTPClock:23:1: error: stray ‘\200’ in program

    ESP32NTPClock:23:1: error: stray ‘\235’ in program

    ESP32NTPClock:54:1: error: stray ‘\342’ in program

    char dateBuffer[] = “”;

    ^

    ESP32NTPClock:54:1: error: stray ‘\200’ in program

    ESP32NTPClock:54:1: error: stray ‘\234’ in program

    ESP32NTPClock:54:1: error: stray ‘\342’ in program

    ESP32NTPClock:54:1: error: stray ‘\200’ in program

    ESP32NTPClock:54:1: error: stray ‘\235’ in program

    ESP32NTPClock:56:1: error: stray ‘\342’ in program

    ” Jan “, ” Feb “, ” Mar “, ” Apr “, ” May “, ” Jun “,

    ^

    ESP32NTPClock:56:1: error: stray ‘\200’ in program

    ESP32NTPClock:56:1: error: stray ‘\235’ in program

    ESP32NTPClock:56:1: error: stray ‘\342’ in program

    ESP32NTPClock:56:1: error: stray ‘\200’ in program

    ESP32NTPClock:56:1: error: stray ‘\234’ in program

    ESP32NTPClock:56:1: error: stray ‘\342’ in program

    ESP32NTPClock:56:1: error: stray ‘\200’ in program

    ESP32NTPClock:56:1: error: stray ‘\235’ in program

    ESP32NTPClock:56:1: error: stray ‘\342’ in program

    ESP32NTPClock:56:1: error: stray ‘\200’ in program

    ESP32NTPClock:56:1: error: stray ‘\234’ in program

    ESP32NTPClock:56:1: error: stray ‘\342’ in program

    ESP32NTPClock:56:1: error: stray ‘\200’ in program

    ESP32NTPClock:56:1: error: stray ‘\235’ in program

    ESP32NTPClock:56:1: error: stray ‘\342’ in program

    ESP32NTPClock:56:1: error: stray ‘\200’ in program

    ESP32NTPClock:56:1: error: stray ‘\234’ in program

    ESP32NTPClock:56:1: error: stray ‘\342’ in program

    ESP32NTPClock:56:1: error: stray ‘\200’ in program

    ESP32NTPClock:56:1: error: stray ‘\235’ in program

    ESP32NTPClock:56:1: error: stray ‘\342’ in program

    ESP32NTPClock:56:1: error: stray ‘\200’ in program

    ESP32NTPClock:56:1: error: stray ‘\234’ in program

    ESP32NTPClock:56:1: error: stray ‘\342’ in program

    ESP32NTPClock:56:1: error: stray ‘\200’ in program

    ESP32NTPClock:56:1: error: stray ‘\235’ in program

    ESP32NTPClock:56:1: error: stray ‘\342’ in program

    ESP32NTPClock:56:1: error: stray ‘\200’ in program

    ESP32NTPClock:56:1: error: stray ‘\234’ in program

    ESP32NTPClock:56:1: error: stray ‘\342’ in program

    ESP32NTPClock:56:1: error: stray ‘\200’ in program

    ESP32NTPClock:56:1: error: stray ‘\235’ in program

    ESP32NTPClock:56:1: error: stray ‘\342’ in program

    ESP32NTPClock:56:1: error: stray ‘\200’ in program

    ESP32NTPClock:56:1: error: stray ‘\234’ in program

    ESP32NTPClock:57:1: error: stray ‘\342’ in program

    ” Jul “, ” Aug “, ” Sep “, ” Oct “, ” Nov “, ” Dec ”

    ^

    ESP32NTPClock:57:1: error: stray ‘\200’ in program

    ESP32NTPClock:57:1: error: stray ‘\235’ in program

    ESP32NTPClock:57:1: error: stray ‘\342’ in program

    ESP32NTPClock:57:1: error: stray ‘\200’ in program

    ESP32NTPClock:57:1: error: stray ‘\234’ in program

    ESP32NTPClock:57:1: error: stray ‘\342’ in program

    ESP32NTPClock:57:1: error: stray ‘\200’ in program

    ESP32NTPClock:57:1: error: stray ‘\235’ in program

    ESP32NTPClock:57:1: error: stray ‘\342’ in program

    ESP32NTPClock:57:1: error: stray ‘\200’ in program

    ESP32NTPClock:57:1: error: stray ‘\234’ in program

    ESP32NTPClock:57:1: error: stray ‘\342’ in program

    ESP32NTPClock:57:1: error: stray ‘\200’ in program

    ESP32NTPClock:57:1: error: stray ‘\235’ in program

    ESP32NTPClock:57:1: error: stray ‘\342’ in program

    ESP32NTPClock:57:1: error: stray ‘\200’ in program

    ESP32NTPClock:57:1: error: stray ‘\234’ in program

    ESP32NTPClock:57:1: error: stray ‘\342’ in program

    ESP32NTPClock:57:1: error: stray ‘\200’ in program

    ESP32NTPClock:57:1: error: stray ‘\235’ in program

    ESP32NTPClock:57:1: error: stray ‘\342’ in program

    ESP32NTPClock:57:1: error: stray ‘\200’ in program

    ESP32NTPClock:57:1: error: stray ‘\234’ in program

    ESP32NTPClock:57:1: error: stray ‘\342’ in program

    ESP32NTPClock:57:1: error: stray ‘\200’ in program

    ESP32NTPClock:57:1: error: stray ‘\235’ in program

    ESP32NTPClock:57:1: error: stray ‘\342’ in program

    ESP32NTPClock:57:1: error: stray ‘\200’ in program

    ESP32NTPClock:57:1: error: stray ‘\234’ in program

    ESP32NTPClock:57:1: error: stray ‘\342’ in program

    ESP32NTPClock:57:1: error: stray ‘\200’ in program

    ESP32NTPClock:57:1: error: stray ‘\235’ in program

    ESP32NTPClock:57:1: error: stray ‘\342’ in program

    ESP32NTPClock:57:1: error: stray ‘\200’ in program

    ESP32NTPClock:57:1: error: stray ‘\235’ in program

    ESP32NTPClock:69:1: error: stray ‘\342’ in program

    Serial.print(“.”);

    ^

    ESP32NTPClock:69:1: error: stray ‘\200’ in program

    ESP32NTPClock:69:1: error: stray ‘\234’ in program

    ESP32NTPClock:69:1: error: stray ‘\342’ in program

    ESP32NTPClock:69:1: error: stray ‘\200’ in program

    ESP32NTPClock:69:1: error: stray ‘\235’ in program

    ESP32NTPClock:72:1: error: stray ‘\342’ in program

    Serial.println(“”);

    ^

    ESP32NTPClock:72:1: error: stray ‘\200’ in program

    ESP32NTPClock:72:1: error: stray ‘\234’ in program

    ESP32NTPClock:72:1: error: stray ‘\342’ in program

    ESP32NTPClock:72:1: error: stray ‘\200’ in program

    ESP32NTPClock:72:1: error: stray ‘\235’ in program

    ESP32NTPClock:73:1: error: stray ‘\342’ in program

    Serial.println(“WiFi connected.”);

    ^

    ESP32NTPClock:73:1: error: stray ‘\200’ in program

    ESP32NTPClock:73:1: error: stray ‘\234’ in program

    ESP32NTPClock:73:1: error: stray ‘\342’ in program

    ESP32NTPClock:73:1: error: stray ‘\200’ in program

    ESP32NTPClock:73:1: error: stray ‘\235’ in program

    ESP32NTPClock:74:1: error: stray ‘\342’ in program

    Serial.println(“IP address: “);

    ^

    ESP32NTPClock:74:1: error: stray ‘\200’ in program

    ESP32NTPClock:74:1: error: stray ‘\234’ in program

    ESP32NTPClock:74:1: error: stray ‘\342’ in program

    ESP32NTPClock:74:1: error: stray ‘\200’ in program

    ESP32NTPClock:74:1: error: stray ‘\234’ in program

    ESP32NTPClock:83:1: error: stray ‘\342’ in program

    DotMatrix.displayText(“NTP Clock by Idris”, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);

    ^

    ESP32NTPClock:83:1: error: stray ‘\200’ in program

    ESP32NTPClock:83:1: error: stray ‘\234’ in program

    ESP32NTPClock:83:1: error: stray ‘\342’ in program

    ESP32NTPClock:83:1: error: stray ‘\200’ in program

    ESP32NTPClock:83:1: error: stray ‘\235’ in program

    ESP32NTPClock:99:1: error: stray ‘\342’ in program

    if (currentMillis – previousMillis > interval &&

    ^

    ESP32NTPClock:99:1: error: stray ‘\200’ in program

    ESP32NTPClock:99:1: error: stray ‘\223’ in program

    ESP32NTPClock:111:1: error: stray ‘\342’ in program

    month = monthArray[month.toInt() – 1];

    ^

    ESP32NTPClock:111:1: error: stray ‘\200’ in program

    ESP32NTPClock:111:1: error: stray ‘\223’ in program

    ESP32NTPClock:114:1: error: stray ‘\342’ in program

    dateStamp = year + “, ” + date + month;

    ^

    ESP32NTPClock:114:1: error: stray ‘\200’ in program

    ESP32NTPClock:114:1: error: stray ‘\234’ in program

    ESP32NTPClock:114:1: error: stray ‘\342’ in program

    ESP32NTPClock:114:1: error: stray ‘\200’ in program

    ESP32NTPClock:114:1: error: stray ‘\235’ in program

    ESP32NTPClock:129:1: error: stray ‘\342’ in program

    hour = String(hour.toInt() – 12);

    ^

    ESP32NTPClock:129:1: error: stray ‘\200’ in program

    ESP32NTPClock:129:1: error: stray ‘\223’ in program

    ESP32NTPClock:22:24: error: ‘TINKER’ was not declared in this scope

    const char ssid[] = “TINKER”; // WiFi name

    ^

    ESP32NTPClock:23:28: error: ‘fatin241’ was not declared in this scope

    const char password[] = “fatin241”; // WiFi password

    ^

    ESP32NTPClock:54:27: error: expected primary-expression before ‘;’ token

    char dateBuffer[] = “”;

    ^

    ESP32NTPClock:56:5: error: ‘Jan’ was not declared in this scope

    ” Jan “, ” Feb “, ” Mar “, ” Apr “, ” May “, ” Jun “,

    ^

    ESP32NTPClock:56:18: error: ‘Feb’ was not declared in this scope

    ” Jan “, ” Feb “, ” Mar “, ” Apr “, ” May “, ” Jun “,

    ^

    ESP32NTPClock:56:31: error: ‘Mar’ was not declared in this scope

    ” Jan “, ” Feb “, ” Mar “, ” Apr “, ” May “, ” Jun “,

    ^

    ESP32NTPClock:56:44: error: ‘Apr’ was not declared in this scope

    ” Jan “, ” Feb “, ” Mar “, ” Apr “, ” May “, ” Jun “,

    ^

    ESP32NTPClock:56:57: error: ‘May’ was not declared in this scope

    ” Jan “, ” Feb “, ” Mar “, ” Apr “, ” May “, ” Jun “,

    ^

    ESP32NTPClock:56:70: error: ‘Jun’ was not declared in this scope

    ” Jan “, ” Feb “, ” Mar “, ” Apr “, ” May “, ” Jun “,

    ^

    ESP32NTPClock:57:5: error: ‘Jul’ was not declared in this scope

    ” Jul “, ” Aug “, ” Sep “, ” Oct “, ” Nov “, ” Dec ”

    ^

    ESP32NTPClock:57:18: error: ‘Aug’ was not declared in this scope

    ” Jul “, ” Aug “, ” Sep “, ” Oct “, ” Nov “, ” Dec ”

    ^

    ESP32NTPClock:57:31: error: ‘Sep’ was not declared in this scope

    ” Jul “, ” Aug “, ” Sep “, ” Oct “, ” Nov “, ” Dec ”

    ^

    ESP32NTPClock:57:44: error: ‘Oct’ was not declared in this scope

    ” Jul “, ” Aug “, ” Sep “, ” Oct “, ” Nov “, ” Dec ”

    ^

    ESP32NTPClock:57:57: error: ‘Nov’ was not declared in this scope

    ” Jul “, ” Aug “, ” Sep “, ” Oct “, ” Nov “, ” Dec ”

    ^

    ESP32NTPClock:57:70: error: ‘Dec’ was not declared in this scope

    ” Jul “, ” Aug “, ” Sep “, ” Oct “, ” Nov “, ” Dec ”

    ^

    C:\Users\Asus\Documents\Arduino\ESP32NTPClock\ESP32NTPClock.ino: In function ‘void setup()’:

    ESP32NTPClock:69:17: error: expected primary-expression before ‘.’ token

    Serial.print(“.”);

    ^

    ESP32NTPClock:69:21: error: expected unqualified-id before ‘)’ token

    Serial.print(“.”);

    ^

    ESP32NTPClock:73:24: error: expected ‘)’ before ‘connected’

    Serial.println(“WiFi connected.”);

    ^

    ESP32NTPClock:73:37: error: no matching function for call to ‘HardwareSerial::println(WiFiClass&)’

    Serial.println(“WiFi connected.”);

    ^

    In file included from C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Stream.h:26:0,

    from C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Arduino.h:147,

    from sketch\ESP32NTPClock.ino.cpp:1:

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:96:12: note: candidate: size_t Print::println(const __FlashStringHelper*)

    size_t println(const __FlashStringHelper *);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:96:12: note: no known conversion for argument 1 from ‘WiFiClass’ to ‘const __FlashStringHelper*’

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:97:12: note: candidate: size_t Print::println(const String&)

    size_t println(const String &s);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:97:12: note: no known conversion for argument 1 from ‘WiFiClass’ to ‘const String&’

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:98:12: note: candidate: size_t Print::println(const char*)

    size_t println(const char[]);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:98:12: note: no known conversion for argument 1 from ‘WiFiClass’ to ‘const char*’

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:99:12: note: candidate: size_t Print::println(char)

    size_t println(char);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:99:12: note: no known conversion for argument 1 from ‘WiFiClass’ to ‘char’

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:100:12: note: candidate: size_t Print::println(unsigned char, int)

    size_t println(unsigned char, int = DEC);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:100:12: note: no known conversion for argument 1 from ‘WiFiClass’ to ‘unsigned char’

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:101:12: note: candidate: size_t Print::println(int, int)

    size_t println(int, int = DEC);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:101:12: note: no known conversion for argument 1 from ‘WiFiClass’ to ‘int’

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:102:12: note: candidate: size_t Print::println(unsigned int, int)

    size_t println(unsigned int, int = DEC);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:102:12: note: no known conversion for argument 1 from ‘WiFiClass’ to ‘unsigned int’

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:103:12: note: candidate: size_t Print::println(long int, int)

    size_t println(long, int = DEC);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:103:12: note: no known conversion for argument 1 from ‘WiFiClass’ to ‘long int’

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:104:12: note: candidate: size_t Print::println(long unsigned int, int)

    size_t println(unsigned long, int = DEC);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:104:12: note: no known conversion for argument 1 from ‘WiFiClass’ to ‘long unsigned int’

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:105:12: note: candidate: size_t Print::println(long long int, int)

    size_t println(long long, int = DEC);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:105:12: note: no known conversion for argument 1 from ‘WiFiClass’ to ‘long long int’

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:106:12: note: candidate: size_t Print::println(long long unsigned int, int)

    size_t println(unsigned long long, int = DEC);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:106:12: note: no known conversion for argument 1 from ‘WiFiClass’ to ‘long long unsigned int’

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:107:12: note: candidate: size_t Print::println(double, int)

    size_t println(double, int = 2);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:107:12: note: no known conversion for argument 1 from ‘WiFiClass’ to ‘double’

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:108:12: note: candidate: size_t Print::println(const Printable&)

    size_t println(const Printable&);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:108:12: note: no known conversion for argument 1 from ‘WiFiClass’ to ‘const Printable&’

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:109:12: note: candidate: size_t Print::println(tm*, const char*)

    size_t println(struct tm * timeinfo, const char * format = NULL);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:109:12: note: no known conversion for argument 1 from ‘WiFiClass’ to ‘tm*’

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:110:12: note: candidate: size_t Print::println()

    size_t println(void);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Print.h:110:12: note: candidate expects 0 arguments, 1 provided

    ESP32NTPClock:74:19: error: ‘IP’ was not declared in this scope

    Serial.println(“IP address: “);

    ^

    ESP32NTPClock:83:26: error: ‘NTP’ was not declared in this scope

    DotMatrix.displayText(“NTP Clock by Idris”, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);

    ^

    C:\Users\Asus\Documents\Arduino\ESP32NTPClock\ESP32NTPClock.ino: In function ‘void loop()’:

    ESP32NTPClock:99:23: error: expected ‘)’ before ‘previousMillis’

    if (currentMillis – previousMillis > interval &&

    ^

    ESP32NTPClock:111:38: error: expected ‘]’ before numeric constant

    month = monthArray[month.toInt() – 1];

    ^

    ESP32NTPClock:111:38: error: expected ‘;’ before numeric constant

    ESP32NTPClock:114:23: error: expected primary-expression before ‘,’ token

    dateStamp = year + “, ” + date + month;

    ^

    ESP32NTPClock:114:29: error: no match for ‘operator+’ (operand type is ‘String’)

    dateStamp = year + “, ” + date + month;

    ^

    In file included from C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/Arduino.h:146:0,

    from sketch\ESP32NTPClock.ino.cpp:1:

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h:178:34: note: candidate: StringSumHelper& operator+(const StringSumHelper&, const __FlashStringHelper*)

    friend StringSumHelper & operator +(const StringSumHelper &lhs, const __FlashStringHelper *rhs);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h:178:34: note: candidate expects 2 arguments, 1 provided

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h:177:34: note: candidate: StringSumHelper& operator+(const StringSumHelper&, double)

    friend StringSumHelper & operator +(const StringSumHelper &lhs, double num);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h:177:34: note: candidate expects 2 arguments, 1 provided

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h:176:34: note: candidate: StringSumHelper& operator+(const StringSumHelper&, float)

    friend StringSumHelper & operator +(const StringSumHelper &lhs, float num);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h:176:34: note: candidate expects 2 arguments, 1 provided

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h:175:34: note: candidate: StringSumHelper& operator+(const StringSumHelper&, long unsigned int)

    friend StringSumHelper & operator +(const StringSumHelper &lhs, unsigned long num);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h:175:34: note: candidate expects 2 arguments, 1 provided

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h:174:34: note: candidate: StringSumHelper& operator+(const StringSumHelper&, long int)

    friend StringSumHelper & operator +(const StringSumHelper &lhs, long num);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h:174:34: note: candidate expects 2 arguments, 1 provided

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h:173:34: note: candidate: StringSumHelper& operator+(const StringSumHelper&, unsigned int)

    friend StringSumHelper & operator +(const StringSumHelper &lhs, unsigned int num);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h:173:34: note: candidate expects 2 arguments, 1 provided

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h:172:34: note: candidate: StringSumHelper& operator+(const StringSumHelper&, int)

    friend StringSumHelper & operator +(const StringSumHelper &lhs, int num);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h:172:34: note: candidate expects 2 arguments, 1 provided

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h:171:34: note: candidate: StringSumHelper& operator+(const StringSumHelper&, unsigned char)

    friend StringSumHelper & operator +(const StringSumHelper &lhs, unsigned char num);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h:171:34: note: candidate expects 2 arguments, 1 provided

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h:170:34: note: candidate: StringSumHelper& operator+(const StringSumHelper&, char)

    friend StringSumHelper & operator +(const StringSumHelper &lhs, char c);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h:170:34: note: candidate expects 2 arguments, 1 provided

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h:169:34: note: candidate: StringSumHelper& operator+(const StringSumHelper&, const char*)

    friend StringSumHelper & operator +(const StringSumHelper &lhs, const char *cstr);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h:169:34: note: candidate expects 2 arguments, 1 provided

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h:168:34: note: candidate: StringSumHelper& operator+(const StringSumHelper&, const String&)

    friend StringSumHelper & operator +(const StringSumHelper &lhs, const String &rhs);

    ^

    C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h:168:34: note: candidate expects 2 arguments, 1 provided

    ESP32NTPClock:129:14: error: expected primary-expression before ‘(‘ token

    hour = String(hour.toInt() – 12);

    ^

    ESP32NTPClock:129:32: error: expected ‘)’ before numeric constant

    hour = String(hour.toInt() – 12);

    ^

    Multiple libraries were found for “WiFi.h”

    Used: C:\Users\Asus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\libraries\WiFi

    Not used: C:\Users\Asus\Downloads\arduino-1.8.15-windows\arduino-1.8.15\libraries\WiFi

    exit status 1

    stray ‘\342’ in program

    This report would have more information with
    “Show verbose output during compilation”
    option enabled in File -> Preferences.

  2. exit status 1
    ‘class NTPClient’ has no member named ‘getFormattedDate’ tengo este error como puedo solucionar ???

  3. Is there any difference if I use ESP8266 ? Because it seems that it does not working for me. I dont know why.

  4. Okay it works now. Here you go. For reference. Sorry, I just learned Arduino yesterday. So total newbie.

    /*
    Project: Dot matrix clock with NTP server using ESP32
    Board: ESP32 Dev Module (Node32 Lite)

    Connections:
    ESP32 | Dot Matrix
    RAW – VCC
    GND – GND
    27 – DIN
    26 – CS
    25 – CLK

    External libraries:
    – MD_MAX72XX by majicDesigns Version 3.2.1 (Manager)
    – MD_Parola by majicDesigns Version 3.3.0 (Manager)
    – NTPClient by Fabrice Weinberg Version 3.1.0 (Zip)
    https://github.com/taranais/NTPClient/archive/master.zip
    */

    #include
    #include
    const char ssid[] = “wifi name”; // WiFi name
    const char password[] = “password”; // WiFi password

    #include
    #include
    WiFiUDP ntpUDP;
    NTPClient timeClient(ntpUDP);

    #include
    #include
    #include

    //#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
    #define HARDWARE_TYPE MD_MAX72XX::FC16_HW
    #define MAX_DEVICES 4
    #define CLK_PIN 25 // 18 or 25
    #define DATA_PIN 27 // 16 or 27
    #define CS_PIN 26 // 17 or 26

    MD_Parola DotMatrix = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

    uint8_t scrollSpeed = 50; // default frame delay value
    textEffect_t scrollEffect = PA_SCROLL_LEFT;
    textPosition_t scrollAlign = PA_LEFT;
    uint16_t scrollPause = 3000; // in milliseconds

    long currentMillis = 0;
    long previousMillis = 0;
    int interval = 1000;
    String formattedDate;
    String timeStamp, hour, minute, second;
    String dateStamp, year, month, date;
    char dateBuffer[] = “”;
    String monthArray[12] = {
    ” Jan “, ” Feb “, ” Mar “, ” Apr “, ” May “, ” Jun “,
    ” Jul “, ” Aug “, ” Sep “, ” Oct “, ” Nov “, ” Dec ”
    };
    enum {TIME, DATE};
    boolean displayMode = TIME;

    void setup()
    {
    Serial.begin(115200);

    WiFi.begin(ssid, password);
    while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(“.”);
    }

    Serial.println(“”);
    Serial.println(“WiFi connected.”);
    Serial.println(“IP address: “);
    Serial.println(WiFi.localIP());

    DotMatrix.begin();
    DotMatrix.setIntensity(0);

    timeClient.begin();
    timeClient.setTimeOffset(28800); // Set offset time in seconds, GMT+8 = 28800

    DotMatrix.displayText(“NTP Clock by Idris”, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);
    displayMode = DATE;
    }

    void loop()
    {
    while (!timeClient.update()) {
    timeClient.forceUpdate();
    }

    if (displayMode == DATE && DotMatrix.displayAnimate()) {
    DotMatrix.displayReset();
    displayMode = TIME;
    }

    currentMillis = millis();
    if (currentMillis – previousMillis > interval &&
    displayMode == TIME) {
    previousMillis = millis();

    // The formattedDate comes with the following format:
    // 2018-05-28T16:00:13Z
    formattedDate = timeClient.getFormattedDate();
    Serial.println(formattedDate);

    // Extract date
    year = formattedDate.substring(0, 4);
    month = formattedDate.substring(5, 7);
    month = monthArray[month.toInt() – 1];
    date = formattedDate.substring(8, 10);
    date = String(date.toInt());
    dateStamp = year + “, ” + date + month;
    dateStamp.toCharArray(dateBuffer, dateStamp.length()+1);

    // Extract time
    hour = formattedDate.substring(11, 13);
    minute = formattedDate.substring(14, 16);
    second = formattedDate.substring(17, 19);

    if (hour.toInt() == 0) {
    hour = String(hour.toInt() + 12);
    }
    else if (hour.toInt() < 13) {
    hour = String(hour.toInt());
    }
    else {
    hour = String(hour.toInt() – 12);
    }

    if (second.toInt() == 0) {
    displayMode = DATE;
    DotMatrix.displayClear();
    DotMatrix.displayText(dateBuffer, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);
    return;
    }
    else if (second.toInt() % 2) {
    timeStamp = hour + ":" + minute;
    }
    else {
    timeStamp = hour + " " + minute;
    }

    DotMatrix.setTextAlignment(PA_CENTER);
    DotMatrix.print(timeStamp);
    }
    }

  5. This is the error..log I suppose.

    =====================================================================================

    Arduino: 1.8.13 (Windows 10), Board: “ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None”

    ESP32-ntpclock-dotmatrix-test1:99:3: error: stray ‘\342’ in program

    if (currentMillis – previousMillis > interval &&

    ^

    ESP32-ntpclock-dotmatrix-test1:99:3: error: stray ‘\200’ in program

    ESP32-ntpclock-dotmatrix-test1:99:3: error: stray ‘\223’ in program

    ESP32-ntpclock-dotmatrix-test1:111:5: error: stray ‘\342’ in program

    month = monthArray[month.toInt() – 1];

    ^

    ESP32-ntpclock-dotmatrix-test1:111:5: error: stray ‘\200’ in program

    ESP32-ntpclock-dotmatrix-test1:111:5: error: stray ‘\223’ in program

    ESP32-ntpclock-dotmatrix-test1:129:7: error: stray ‘\342’ in program

    hour = String(hour.toInt() – 12);

    ^

    ESP32-ntpclock-dotmatrix-test1:129:7: error: stray ‘\200’ in program

    ESP32-ntpclock-dotmatrix-test1:129:7: error: stray ‘\223’ in program

    C:\Users\LemonKicker\Documents\Arduino\ESP32-ntpclock-dotmatrix-test1\ESP32-ntpclock-dotmatrix-test1.ino: In function ‘void loop()’:

    ESP32-ntpclock-dotmatrix-test1:99:25: error: expected ‘)’ before ‘previousMillis’

    if (currentMillis – previousMillis > interval &&

    ^

    ESP32-ntpclock-dotmatrix-test1:105:32: error: ‘class NTPClient’ has no member named ‘getFormattedDate’

    formattedDate = timeClient.getFormattedDate();

    ^

    ESP32-ntpclock-dotmatrix-test1:111:42: error: expected ‘]’ before numeric constant

    month = monthArray[month.toInt() – 1];

    ^

    ESP32-ntpclock-dotmatrix-test1:111:42: error: expected ‘;’ before numeric constant

    ESP32-ntpclock-dotmatrix-test1:129:20: error: expected primary-expression before ‘(‘ token

    hour = String(hour.toInt() – 12);

    ^

    ESP32-ntpclock-dotmatrix-test1:129:38: error: expected ‘)’ before numeric constant

    hour = String(hour.toInt() – 12);

    ^

    Multiple libraries were found for “WiFi.h”

    Used: C:\Users\LemonKicker\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi

    Not used: C:\Program Files (x86)\Arduino\libraries\WiFi

    Multiple libraries were found for “NTPClient.h”

    Used: C:\Users\LemonKicker\Documents\Arduino\libraries\NTPClient

    Not used: C:\Users\LemonKicker\Documents\Arduino\libraries\NTPClient-master

    exit status 1

    stray ‘\342’ in program

    This report would have more information with
    “Show verbose output during compilation”
    option enabled in File -> Preferences.

  6. I got an error on line 129. Can somebody please help me by telling whats wrong with that line?

    hour = String(hour.toInt() – 12);

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

TinyML on Arduino using Edge Impulse
DIY Interactive Robot Using REKA:BIT With Micro:bit
BLTouch Installation for Ender 3 with 32-bit V4.2.2 Board
Pick and Send Random Meal’s Option and Locations through Telegram Bot Using Grove WiFi 8266 on micro:bit
DIY Automated Vacuum Cleaner Using REKA:BIT With Micro:bit
Tutorials of Cytron Technologies Scroll to Top