Basics · 8 min read

ESP32 NTP Time Zone and Daylight Saving with POSIX TZ Strings

ESP32 NTP time zone and daylight saving: read a POSIX TZ string, ready strings for Berlin, London, New York and Mexico City, configTzTime code and a DST test.

Setting up the ESP32 NTP time zone and daylight saving time takes a single line of text, yet most examples get it wrong. The ESP32 always receives the time from internet NTP servers as UTC; to show your city's time, you have to tell it the time zone and the daylight saving time (DST) rules. If you do that with a short piece of text called a POSIX TZ string, the ESP32 applies the March and October/November changes by itself every year, and you never have to touch the code again.

In this article we take the TZ string apart letter by letter, give ready-made strings for Berlin, Paris, Rome, Madrid, London, New York, Los Angeles, Mexico City and Latin America in one table, write working code with configTzTime and show how to test the clock change without waiting for months. If you want the NTP basics, showing the time on an OLED and an RTC backup first, have a look at ESP32 NTP Internet Time.

ESP32 development board
The ESP32 converts the UTC time it gets over NTP into local time using the rules in the TZ string; no extra code is needed for daylight saving.

Why does daylight saving time cause trouble on the ESP32?

The most common mistake is writing the offset as a fixed number, as in configTime(3600, 3600, ...). The second number means "add one hour when daylight saving is on", but it never says when it is on. As a result, the clock is either one hour ahead all year or runs on winter time all summer. Countries without DST, such as Turkey (fixed UTC+3 since 2016), never notice this; but anyone who builds a clock for Germany, Spain or the US gets the first surprise at the end of March. The right fix is to give the rule itself, not a number.

What is a POSIX TZ string and how do you read it?

A POSIX TZ string describes, in one line, the standard time name, the UTC offset, the daylight saving name and the day and hour when daylight saving starts and ends. The ESP32's C library reads this string and works out on every localtime call whether it is currently winter or summer time. Let's break down the Central European string:

PartMeaning
CETAbbreviation of standard (winter) time
-1UTC offset with the sign reversed: -1 for UTC+1
CESTAbbreviation of summer time; with no offset given it is 1 hour ahead of standard
M3.5.0DST start: month 3 (March), week 5 (last), day 0 (Sunday)
(no time)Without a start time, 02:00 local time is assumed
M10.5.0/3End: last Sunday of October at 03:00 (summer time)

In the Mm.w.d format, m is the month (1–12), w is the week (1–5; 5 always means "the last" week of the month) and d is the day of the week (0 Sunday, 6 Saturday). So M3.5.0 means "last Sunday of March" and M3.2.0 means "second Sunday of March". The switch time comes after a slash; /3 means 03:00 and /1 means 01:00. If a zone name contains digits or signs, it goes in angle brackets: Turkey's string <+03>-3 is written like that and has no DST rule.

The sign in a TZ string is the opposite of what you are used to. Turkey at UTC+3 gets -3, and New York at UTC-5 gets 5. If you "correct" the sign and write +3 for UTC+3, the clock ends up 6 hours off; this is the most common mistake on this topic.

Ready TZ strings: Europe, North America and Latin America

CityTZ stringWinter / summerDST period
Istanbul<+03>-3UTC+3 (fixed)None (since 2016)
Berlin, Paris, Rome, MadridCET-1CEST,M3.5.0,M10.5.0/3UTC+1 / UTC+2Last Sunday of March – last Sunday of October
LondonGMT0BST,M3.5.0/1,M10.5.0UTC+0 / UTC+1Last Sunday of March – last Sunday of October
LisbonWET0WEST,M3.5.0/1,M10.5.0UTC+0 / UTC+1Last Sunday of March – last Sunday of October
New York, TorontoEST5EDT,M3.2.0,M11.1.0UTC-5 / UTC-42nd Sunday of March – 1st Sunday of November
ChicagoCST6CDT,M3.2.0,M11.1.0UTC-6 / UTC-52nd Sunday of March – 1st Sunday of November
Los AngelesPST8PDT,M3.2.0,M11.1.0UTC-8 / UTC-72nd Sunday of March – 1st Sunday of November
PhoenixMST7UTC-7 (fixed)None
Mexico CityCST6UTC-6 (fixed)None (since 2022)
Bogotá, Lima<-05>5UTC-5 (fixed)None
Buenos Aires, São Paulo<-03>3UTC-3 (fixed)None
SydneyAEST-10AEDT,M10.1.0,M4.1.0/3UTC+10 / UTC+111st Sunday of October – 1st Sunday of April

Two things stand out in the table. First, all European countries switch at the same moment, 01:00 UTC: in Berlin the clock jumps from 02:00 to 03:00, in London from 01:00 to 02:00. In the US, every city switches at 02:00 its own local time. Second, rules change: Mexico dropped DST in 2022, Brazil in 2019 and Turkey in 2016. A string copied from an old example may be wrong today; if a country changes its law, you only update this one line. In the southern hemisphere (Sydney), DST starts in October and ends in April, and the ESP32 handles that correctly too.

Step by step: automatic daylight saving with configTzTime

  1. Make sure the ESP32 board package is installed in the Arduino IDE and select ESP32 Dev Module as the board.
  2. Replace the Wi-Fi name and password in the code with your own; the ESP32 only connects to 2.4 GHz networks.
  3. Paste your city's string from the table into the TZ_INFO line.
  4. Upload the code, open the Serial Monitor at 115200 baud and check that CET or CEST appears next to the time.
C++ (Arduino IDE)
1#include <WiFi.h>
2#include <time.h>
3
4const char* WIFI_SSID = "AgAdi";       // Wi-Fi adı / Wi-Fi name
5const char* WIFI_PASS = "Sifre123";    // Wi-Fi şifresi / Wi-Fi password
6// Berlin, Paris, Roma, Madrid: kış UTC+1, yaz UTC+2 / winter UTC+1, summer UTC+2
7const char* TZ_INFO = "CET-1CEST,M3.5.0,M10.5.0/3";
8
9void setup() {
10  Serial.begin(115200);
11  WiFi.begin(WIFI_SSID, WIFI_PASS);
12  while (WiFi.status() != WL_CONNECTED) {    // bağlanana kadar bekle / wait until connected
13    delay(500);
14    Serial.print(".");
15  }
16  Serial.println(" Wi-Fi OK");
17
18  // Saat dilimi + NTP sunucuları tek satırda / time zone + NTP servers in one line
19  configTzTime(TZ_INFO, "pool.ntp.org", "time.cloudflare.com");
20
21  struct tm t;
22  while (!getLocalTime(&t)) {                // ilk eşitlemeyi bekle / wait for the first sync
23    Serial.println("NTP bekleniyor / waiting for NTP");
24  }
25}
26
27void loop() {
28  struct tm t;
29  if (getLocalTime(&t)) {
30    // %Z kısaltmayı (CET/CEST) yazar, tm_isdst yaz saatinde 1 olur
31    // %Z prints the abbreviation (CET/CEST), tm_isdst is 1 in summer time
32    Serial.print(&t, "%d.%m.%Y %H:%M:%S %Z");
33    Serial.printf("  yaz saati / DST: %s\n", t.tm_isdst > 0 ? "evet / yes" : "hayir / no");
34  }
35  delay(1000);
36}

configTzTime does two jobs at once: it sets the TZ string as an environment variable and starts the SNTP client with the servers you give it. From then on, every getLocalTime call takes the UTC time, checks the rule and hands you local time. The tm_isdst field is 1 in summer time and 0 in winter; use it if you want a "DST" icon on a display. The %Z format specifier prints the abbreviation from the string (CET, CEST, EST, EDT). This code works the same way on the 2.x and 3.x versions of the ESP32 Arduino core.

configTime vs configTzTime

MethodExampleDaylight savingWhen to use it
configTime(sec, dst_sec, ...)configTime(3600, 3600, "pool.ntp.org")Always on or always offCountries without DST
configTime(0, 0, ...) + setenv/tzsetsetenv("TZ", string, 1); tzset();AutomaticChanging the time zone later
configTzTime(string, ...)configTzTime("CET-1CEST,M3.5.0,M10.5.0/3", ...)AutomaticRecommended

The second parameter of configTime is not a rule but a fixed addition, so in a country with DST it shows the wrong time for half of the year. In a place with a fixed offset, such as Turkey, configTime(3 * 3600, 0, ...) works fine too, but getting used to configTzTime makes your code portable to any country.

Testing the DST change without Wi-Fi

You don't have to wait for the end of March to see that your code works. You set the system clock a few seconds before the switch with settimeofday and print the time every second. The code below simulates the European changes in spring and autumn 2027; it needs no Wi-Fi or NTP, only the USB cable.

C++ (Arduino IDE)
1#include <time.h>
2#include <sys/time.h>
3
4// Wi-Fi gerekmez: saati elle geçişin 5 sn öncesine kurup izleriz
5// No Wi-Fi needed: set the clock 5 s before the switch and watch it
6const char* TZ_INFO = "CET-1CEST,M3.5.0,M10.5.0/3";
7
8const time_t SPRING_2027 = 1806195600;   // 28.03.2027 01:00 UTC: 02:00 CET -> 03:00 CEST
9const time_t AUTUMN_2027 = 1824944400;   // 31.10.2027 01:00 UTC: 03:00 CEST -> 02:00 CET
10
11void watchSwitch(time_t moment) {
12  struct timeval tv = { moment - 5, 0 };  // geçişten 5 sn önce / 5 s before the switch
13  settimeofday(&tv, nullptr);
14  for (int i = 0; i < 10; i++) {
15    time_t now = time(nullptr);
16    struct tm t;
17    localtime_r(&now, &t);                // UTC'den yerel saate / UTC to local time
18    char line[40];
19    strftime(line, sizeof(line), "%d.%m.%Y %H:%M:%S %Z", &t);
20    Serial.println(line);
21    delay(1000);
22  }
23  Serial.println("----");
24}
25
26void setup() {
27  Serial.begin(115200);
28  delay(500);
29  setenv("TZ", TZ_INFO, 1);               // saat dilimini ayarla / set the time zone
30  tzset();
31  watchSwitch(SPRING_2027);               // 01:59:59 -> 03:00:00 beklenir / expected
32  watchSwitch(AUTUMN_2027);               // 02:59:59 CEST -> 02:00:00 CET beklenir / expected
33}
34
35void loop() {
36}
TestBefore the switchAfter the switch
Spring (28.03.2027)01:59:59 CET03:00:00 CEST
Autumn (31.10.2027)02:59:59 CEST02:00:00 CET
New York spring (14.03.2027)01:59:59 EST03:00:00 EDT
In Europe, the hour from 02:00 to 02:59 happens twice on the autumn night (in the US it is 01:00–01:59). A task that runs every day at that time can fire twice that night; make it run once per day using the day number (tm_yday) or pick a time away from the switch. In spring, 02:00–02:59 never happens, so an alarm set inside that hour will not ring.

Changing and saving the time zone at runtime

If your device will travel between countries, let the user pick the time zone from a list instead of hard-coding it. Calling setenv("TZ", ...) followed by tzset() applies the new rule immediately; you don't have to restart NTP because the system clock is already UTC, and only the rule for converting to local time changes. If you save the choice to flash with the Preferences library, the ESP32 remembers it after a restart. In the example below you switch cities by typing a digit from 0 to 6 in the Serial Monitor.

C++ (Arduino IDE)
1#include <WiFi.h>
2#include <Preferences.h>
3#include <time.h>
4
5const char* WIFI_SSID = "AgAdi";
6const char* WIFI_PASS = "Sifre123";
7
8struct Zone { const char* city; const char* tz; };
9const Zone ZONES[] = {
10  { "Istanbul",    "<+03>-3" },
11  { "Berlin",      "CET-1CEST,M3.5.0,M10.5.0/3" },
12  { "London",      "GMT0BST,M3.5.0/1,M10.5.0" },
13  { "New York",    "EST5EDT,M3.2.0,M11.1.0" },
14  { "Los Angeles", "PST8PDT,M3.2.0,M11.1.0" },
15  { "Mexico City", "CST6" },
16  { "Sydney",      "AEST-10AEDT,M10.1.0,M4.1.0/3" },
17};
18const int ZONE_COUNT = sizeof(ZONES) / sizeof(ZONES[0]);
19
20Preferences prefs;
21int zoneIndex = 0;
22
23void applyZone(int i) {
24  zoneIndex = i;
25  setenv("TZ", ZONES[i].tz, 1);           // yeni kural / new rule
26  tzset();                                // hemen geçerli olsun / take effect now
27  prefs.putInt("zone", i);                // kalıcı belleğe yaz / save to flash (NVS)
28  Serial.printf("Saat dilimi / time zone: %s\n", ZONES[i].city);
29}
30
31void setup() {
32  Serial.begin(115200);
33  prefs.begin("clock", false);
34  int saved = prefs.getInt("zone", 0);    // yoksa İstanbul / Istanbul if nothing saved
35  if (saved < 0 || saved >= ZONE_COUNT) saved = 0;
36
37  WiFi.begin(WIFI_SSID, WIFI_PASS);
38  while (WiFi.status() != WL_CONNECTED) delay(500);
39  configTzTime(ZONES[saved].tz, "pool.ntp.org");
40  applyZone(saved);
41
42  for (int i = 0; i < ZONE_COUNT; i++) {  // menüyü göster / show the menu
43    Serial.printf("%d = %s\n", i, ZONES[i].city);
44  }
45}
46
47void loop() {
48  if (Serial.available()) {               // Seri Monitör'den 0-6 yaz / type 0-6 in the Serial Monitor
49    char c = Serial.read();
50    if (c >= '0' && c < '0' + ZONE_COUNT) applyZone(c - '0');
51  }
52  static unsigned long last = 0;
53  if (millis() - last >= 1000) {
54    last = millis();
55    struct tm t;
56    if (getLocalTime(&t, 0)) {
57      Serial.print(&t, "%H:%M:%S %Z  ");
58      Serial.println(ZONES[zoneIndex].city);
59    }
60  }
61}

Notice that the time zone list is made of plain strings only; adding a city means adding one more line to the array. If the saved value is corrupt or outside the list, the code falls back to Istanbul, so the device never starts with an undefined rule. You can hook the same structure up to a drop-down menu on a web page, a rotary encoder or two buttons. Changing the selection does not trigger a new NTP sync and not even a second is lost, because the ESP32 keeps a single UTC clock and every city is just a different view of it.

Daylight saving time on the Raspberry Pi Pico W

The time module in MicroPython doesn't understand TZ strings; ntptime.settime() sets the internal clock to UTC and leaves the rest to you. So on the Pico W you calculate DST yourself with a small function: find that year's switch moments in UTC and check whether the current time falls in that range. The code below contains the European rules (last Sunday of March and October, 01:00 UTC) and the US Eastern rules (2nd Sunday of March, 1st Sunday of November, 02:00 local).

Python
1import network
2import ntptime
3import time
4
5SSID = "AgAdi"
6PASS = "Sifre123"
7ZONE = "EU"                    # "EU" = Berlin/Paris/Roma/Madrid, "US" = New York
8
9def last_sunday(year, month):  # ayın son pazarı / last Sunday of the month
10    t = time.mktime((year, month, 31, 12, 0, 0, 0, 0))
11    wd = time.localtime(t)[6]  # 0 = Pazartesi ... 6 = Pazar / 0 = Monday ... 6 = Sunday
12    return 31 - (wd + 1) % 7
13
14def nth_sunday(year, month, n):  # ayın n. pazarı / n-th Sunday of the month
15    wd = time.localtime(time.mktime((year, month, 1, 12, 0, 0, 0, 0)))[6]
16    return 1 + (6 - wd) % 7 + 7 * (n - 1)
17
18def local_time(utc):           # UTC saniyesinden yerel saate / UTC seconds to local time
19    year = time.localtime(utc)[0]
20    if ZONE == "EU":           # AB: geçiş 01:00 UTC'de / EU: switch at 01:00 UTC
21        std = 1
22        start = time.mktime((year, 3, last_sunday(year, 3), 1, 0, 0, 0, 0))
23        end = time.mktime((year, 10, last_sunday(year, 10), 1, 0, 0, 0, 0))
24    else:                      # ABD Doğu: 02:00 yerel saatte / US Eastern: at 02:00 local
25        std = -5
26        start = time.mktime((year, 3, nth_sunday(year, 3, 2), 7, 0, 0, 0, 0))   # 02:00 EST = 07:00 UTC
27        end = time.mktime((year, 11, nth_sunday(year, 11, 1), 6, 0, 0, 0, 0))   # 02:00 EDT = 06:00 UTC
28    dst = start <= utc < end
29    return time.localtime(utc + (std + (1 if dst else 0)) * 3600), dst
30
31wlan = network.WLAN(network.STA_IF)
32wlan.active(True)
33wlan.connect(SSID, PASS)
34while not wlan.isconnected():  # bağlanana kadar bekle / wait until connected
35    time.sleep(0.5)
36
37for attempt in range(5):       # NTP bazen zaman aşımına uğrar / NTP may time out
38    try:
39        ntptime.settime()      # dahili RTC'yi UTC'ye kurar / sets the internal RTC to UTC
40        break
41    except OSError:
42        time.sleep(2)
43
44while True:
45    t, dst = local_time(time.time())
46    print("{:02d}.{:02d}.{} {:02d}:{:02d}:{:02d} {}".format(t[2], t[1], t[0], t[3], t[4], t[5], "DST" if dst else "STD"))
47    time.sleep(1)

The last_sunday function checks which weekday the 31st falls on and counts back; in MicroPython 0 is Monday and 6 is Sunday, so the math uses (day + 1) % 7. Comparing in UTC seconds avoids confusion during the autumn hour that happens twice in local time. We covered Wi-Fi and a web server on the Pico W in Pico W Wi-Fi Web Server.

Project ideas that need the right time

  • A word clock for a relative in Europe that switches to summer time by itself; see ESP32 Word Clock for the letter layout.
  • A world clock showing several cities at once: each line calls localtime with a different TZ string.
  • An irrigation timer that opens the water at 07:00 and stays correct during summer time.
  • A data logger that keeps going with an RTC module when the internet drops and stores UTC in the RTC.
  • A battery-powered sensor that wakes up every hour to measure; set the sleep time with ESP32 Deep Sleep.

Common mistakes and how to fix them

SymptomCauseFix
Clock exactly 6 hours behind+3 written for UTC+3 (Turkey)Reverse the sign: <+03>-3
1 hour behind in summer, right in winterconfigTime(3600, 0, ...) usedUse configTzTime and a full TZ string
1 hour ahead in winterA fixed 3600 DST offset passed to configTimeUse a string with the M rule instead of a fixed offset
Clock shows 1970NTP hasn't arrived yetWait until getLocalTime returns true, check Wi-Fi
1 hour ahead in Mexico in summerPre-2022 string CST6CDT usedUse CST6
Task ran twice in autumnThe hour that was set back happened twiceLimit the task to once per day with tm_yday
When logging timestamps, always store UTC (time(nullptr)) and convert to local time only for display. That way your log doesn't get mixed up at the DST change, and your charts won't show gaps or overlapping hours.

Once the right TZ string is in place, the ESP32 shows the correct time for years. In the BlueGrays app you can open ESP32 NTP clock, RTC digital clock and temperature logger projects with step-by-step wiring diagrams and ready code, and add the time zone line from this article to your own project.

Frequently asked questions

Does the ESP32 switch to daylight saving time automatically?

Yes, if you pass a POSIX TZ string that includes a DST rule to configTzTime. For Germany, the string CET-1CEST,M3.5.0,M10.5.0/3 moves the clock forward and back on the last Sundays of March and October by itself. Passing fixed seconds to configTime does not give you automatic switching.

What is the TZ string for New York on the ESP32?

Use EST5EDT,M3.2.0,M11.1.0. It means UTC-5 in winter and UTC-4 from the second Sunday of March to the first Sunday of November, switching at 02:00 local time. The same rule with CST6CDT, MST7MDT or PST8PDT covers Chicago, Denver and Los Angeles.

What is the difference between configTime and configTzTime?

configTime takes the offset and the DST addition as fixed seconds and doesn't know when DST starts or ends. configTzTime takes a full TZ string and calculates the switch dates every year by itself. In countries with daylight saving you should use configTzTime.

Why is my ESP32 clock one hour off?

Usually DST was added as a fixed value or not added at all. Check the TZ string, make sure the sign is reversed and use configTzTime instead of configTime. If the country's rule changed recently (like Mexico in 2022), an old string causes this offset too.

How can I test the daylight saving change on an ESP32?

Set the system clock with settimeofday to a UTC time a few seconds before the switch and print localtime every second. For Europe, at 01:00 UTC on 28 March 2027 you should see the clock jump from 01:59:59 CET to 03:00:00 CEST. No Wi-Fi is needed for this test.

How do I set the time zone on a Raspberry Pi Pico W?

MicroPython doesn't support TZ strings, and ntptime sets the clock to UTC. To get local time you add the offset to UTC, and for DST you write a small function that works out that year's switch days, such as the last Sunday of March.

See all projects
Real-Time Clock from the Internet via ESP32 NTP
ES-26Advanced
Premium

Real-Time Clock from the Internet via ESP32 NTP

The ESP32 connects to Wi-Fi and fetches the real time from NTP (Network Time Protocol) servers with millisecond precision. configTzTime() applies the Turkey time zone (TRT, UTC+3) automatically, and in countries with daylight saving time the DST switch is handled by a POSIX TZ string. The time is printed both to the Serial Monitor and to an optional I2C LCD.

4.5(13)
22
Digital Clock with ESP32 and DS1307 RTC (I2C + LCD)
ES-18Intermediate
Premium

Digital Clock with ESP32 and DS1307 RTC (I2C + LCD)

In this project, we display the time and date on a 16x2 I2C LCD screen using the DS1307 real-time clock (RTC) module. The DS1307 is a battery-backed RTC that maintains the time even if the ESP32 is powered off. Both modules share the same I2C bus (SDA/SCL), allowing us to learn how to control multiple devices using just two signal wires. Through this project, you will gain practical knowledge of the I2C communication protocol, RTC module operation, and dynamic data display on an LCD screen.

4.6(26)
40
ESP32 Wi-Fi STA Connection (with LCD Screen)
ES-25Advanced

ESP32 Wi-Fi STA Connection (with LCD Screen)

In this project, we connect the ESP32 to the home Wi-Fi network in Station (STA) mode in a secure, fault-tolerant manner. We store the SSID and password in a separate secrets.h file to prevent leaking to Git, set up an auto-reconnect mechanism, and display the RSSI signal level and IP address on an I2C LCD screen. The internal LED works as a status indicator. It is a production-grade connection manager.

4.4(21)
40
ESP32 HTTPClient + Weather API (with SSD1306 OLED Display)
ES-32Advanced
Premium

ESP32 HTTPClient + Weather API (with SSD1306 OLED Display)

In this project the ESP32 makes a REST API call over the internet to a weather API (wttr.in) using HTTPClient.h. Unlike the I2C LCD version, it uses an SSD1306 OLED (128×64) display, with large text and vector icons for a richer look. Seven weather icons (sunny, rainy, snowy and more) are drawn on the fly, with no bitmap files.

4.3(10)
22
ESP32 HTTPClient + Weather API (with LCD Screen)
ES-31Advanced
Premium

ESP32 HTTPClient + Weather API (with LCD Screen)

In this project the ESP32 makes a REST API call over the internet to a weather API (wttr.in) using HTTPClient.h. The JSON response is parsed with ArduinoJson v7, and the city, temperature, humidity, weather and wind are shown on an I2C LCD. wttr.in needs no API key; just type the name of any city.

4.7(13)
20
ESP32 Deep Sleep — Battery Saving (OLED + RTC RAM Counter)
ES-33Advanced
Premium

ESP32 Deep Sleep — Battery Saving (OLED + RTC RAM Counter)

The ESP32's Deep Sleep mode shuts down the CPU and most peripherals, cutting current draw to about 10µA, which is vital for battery-powered IoT devices. This project uses three wake-up sources: a timer (15 s), an external pin (EXT0, the button on GPIO 33) and a touch pin (T0/GPIO 4). Counters marked with RTC_DATA_ATTR survive deep sleep.

4.3(10)
17
ESP32 Temperature Data Logger (DHT22 + DS1307 RTC + microSD + OLED)
ES-40Advanced
Premium

ESP32 Temperature Data Logger (DHT22 + DS1307 RTC + microSD + OLED)

Build a timed temperature and humidity logger with the ESP32! A DHT22 sensor reads temperature and humidity once a minute, and each reading is saved to a microSD card in CSV format with a real-time stamp from the DS1307 RTC module. The OLED display shows the latest temperature, humidity, timestamp and total number of records live, in large text.

4.7(7)
12
ESP32 I2C LCD Display (16x2)
ES-17Intermediate
Premium

ESP32 I2C LCD Display (16x2)

In this project we connect a 16x2 character LCD to the ESP32 over I2C and display text. With I2C, just 2 data pins (SDA and SCL) control the screen, instead of the 6+ pins a classic parallel connection wastes. The code prints a fixed message on the first line and a counter that goes up every second on the second. At startup an I2C scanner also prints the display's address to the Serial Monitor (usually 0x27 or 0x3F).

4.9(23)
40