ESP32 Firebase Guide: Write Sensor Data and Control an LED
ESP32 Firebase Realtime Database setup: create a project, email authentication, write DHT22 data, control an LED with a stream, plus a Pico W REST example.
ESP32 and Firebase are one of the fastest ways to get sensor data onto the internet and control your device from anywhere in the world. Google's Firebase Realtime Database is a cloud database that stores data as a JSON tree and pushes every change to all connected clients, usually in under a second. The ESP32 writes temperature and humidity readings there, and a web page or app on your phone sees the same data instantly. The reverse works too: set the led value in the database to true and the LED on the ESP32 lights up right away.
In this guide you'll create a Firebase project from scratch, enable email and password authentication, write the security rules correctly and install the Firebase ESP Client library in the Arduino IDE. Then we'll go step by step through code that writes DHT22 sensor data to the database every 30 seconds, and a second example that listens for database changes with a stream and lights the LED instantly. In the final sections you'll do the same job on a Raspberry Pi Pico W in MicroPython over the REST API, compare Firebase with Google Sheets and collect fixes for the most common error messages. If you're new to the ESP32, first take a look at What Is the ESP32?.

What is Firebase Realtime Database and how does it work?
Unlike classic table-based (SQL) databases, Realtime Database keeps data as one big JSON tree. Each piece of data is addressed by a path; for example, the path /cihazlar/UID/son/sicaklik can hold a number, and /cihazlar/UID/led can hold true or false. The ESP32 writes to and reads from these paths over an encrypted HTTPS connection. Its real strength is the stream (listening) feature: the device subscribes to a path, the connection stays open, and the moment the value at that path changes the server sends the new data on its own. You don't need a loop that polls every second, so both latency and data traffic go down.
| Feature | Value / Description |
|---|---|
| Data model | JSON tree (NoSQL), path-based access |
| Connection | HTTPS (TLS); an open HTTP connection for streams |
| Free Spark plan | 1 GB storage, 10 GB download per month, 100 simultaneous connections |
| Latency | Changes usually arrive in under 1 second |
| Authentication | Email/password, anonymous sign-in, Google account and others |
| Security | JSON security rules that run on the server side |
| Supported boards | ESP32 and ESP8266 (with the library); Pico W (via REST API) |
Creating a Firebase project step by step
- Sign in to the Firebase console with your Google account and click Create a project. Give it a name such as esp32-sera; Google Analytics isn't needed for this project, so you can turn it off.
- In the left menu go to Build > Realtime Database and press Create Database.
- Choose the database location. If you're in Europe, europe-west1 (Belgium) gives lower latency; in that case the address looks like https://your-project-default-rtdb.europe-west1.firebasedatabase.app. For a US location, the address ends with -default-rtdb.firebaseio.com.
- Choose Locked mode as the security mode; you'll write the rules yourself in a moment. Copy the address at the top of the page that opens: this is your DATABASE_URL.
- Go to Build > Authentication, click Get started and enable the Email/Password provider on the Sign-in method tab.
- On the Users tab, create a user for the ESP32 with Add user (for example [email protected] and a password of at least 6 characters). Note the User UID value in the new row.
- Click the gear icon at the top left, go to Project settings > General and copy the Web API Key; this is your API_KEY.
Authentication and security rules
The Web API key on its own is not a secret password; it only tells Firebase which project a request belongs to. The real protection is the security rules that run on the Firebase server. When the ESP32 signs in with email and password, Firebase gives it an ID token valid for one hour; the library renews the token automatically before it expires. Inside the rules, the auth.uid expression gives the identity of the user sending the request. The table below shows three different rules you can put in the Realtime Database > Rules tab, and what they mean. The recommended structure is the third one: each device can access only the branch under its own UID, so even if one device's password is stolen, the other devices' data stays safe.
| Rule (Rules tab) | Meaning |
|---|---|
| {"rules": {".read": true, ".write": true}} | Anyone can read and write. Only for a few minutes of testing; never leave it open. |
| {"rules": {".read": "auth != null", ".write": "auth != null"}} | Every signed-in user can access the whole database. Enough for small single-user projects. |
| {"rules": {"cihazlar": {"$uid": {".read": "$uid === auth.uid", ".write": "$uid === auth.uid"}}}} | Each user can read and write only the /cihazlar/their-own-UID branch. The code in this post is written for this structure. |
Library installation and settings
- Make sure the ESP32 board package is installed in the Arduino IDE (Tools > Board > esp32). The code in this post works with both 2.x and 3.x core versions.
- In the Library Manager, search for Firebase ESP Client and install Mobizt's Firebase Arduino Client Library for ESP8266 and ESP32. The code uses the Firebase_ESP_Client.h interface of this library; the same developer's newer library called FirebaseClient has a different interface, so don't mix the two.
- From the same manager, install Adafruit's DHT sensor library; if it asks about the Adafruit Unified Sensor dependency, add that too.
- Replace the six settings at the top of the code (Wi-Fi name and password, API key, database address, user email and password) with your own values.
| Setting | Where to get it | Example |
|---|---|---|
| API_KEY | Project settings > General > Web API Key | A 39-character string starting with AIza |
| DATABASE_URL | Top of the Realtime Database page | https://your-project-default-rtdb.europe-west1.firebasedatabase.app |
| USER_EMAIL | Authentication > Users | [email protected] |
| USER_PASSWORD | The password you set when adding the user | At least 6 characters |
| WIFI_SSID / WIFI_PASSWORD | Your router settings | 2.4 GHz network only (the ESP32 doesn't support 5 GHz) |
Circuit: wiring the DHT22 and LED
| Connection | ESP32 | Raspberry Pi Pico W |
|---|---|---|
| DHT22 VCC | 3V3 | 3V3(OUT) |
| DHT22 DATA | GPIO 4 | GP15 |
| DHT22 GND | GND | GND |
| LED anode (through a 220 Ω resistor) | GPIO 26 | GP14 |
| LED cathode | GND | GND |
Writing sensor data to Firebase
The code below connects to Wi-Fi, signs in to Firebase with email and password, and writes the DHT22 reading to two places every 30 seconds: the /cihazlar/UID/son node holds the latest reading, overwritten each time, while the /cihazlar/UID/kayit node holds the history records added with push. The UID is taken automatically from the library after sign-in, so you don't need to type it in.
1#include <WiFi.h>
2#include <Firebase_ESP_Client.h>
3#include "addons/TokenHelper.h" // token durumunu Seri Monitör'e yazar / prints token status to Serial
4#include <DHT.h>
5
6// Kendi bilgilerinle değiştir / Replace with your own values
7#define WIFI_SSID "WIFI_ADIN"
8#define WIFI_PASSWORD "WIFI_SIFREN"
9#define API_KEY "WEB_API_KEY"
10#define DATABASE_URL "https://proje-adin-default-rtdb.europe-west1.firebasedatabase.app"
11#define USER_EMAIL "[email protected]"
12#define USER_PASSWORD "sifre123"
13
14#define DHT_PIN 4
15
16DHT dht(DHT_PIN, DHT22);
17FirebaseData fbdo; // istek nesnesi / request object
18FirebaseAuth auth; // kullanıcı bilgisi / user credentials
19FirebaseConfig config; // proje ayarları / project settings
20
21unsigned long sonGonderim = 0;
22const unsigned long ARALIK = 30000; // 30 saniye / 30 seconds
23
24void setup() {
25 Serial.begin(115200);
26 dht.begin();
27
28 WiFi.mode(WIFI_STA);
29 WiFi.setAutoReconnect(true); // kopunca yeniden bağlan / reconnect on drop
30 WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
31 Serial.print("Wi-Fi baglaniyor");
32 while (WiFi.status() != WL_CONNECTED) {
33 delay(300);
34 Serial.print(".");
35 }
36 Serial.println();
37 Serial.print("IP: ");
38 Serial.println(WiFi.localIP());
39
40 config.api_key = API_KEY;
41 config.database_url = DATABASE_URL;
42 auth.user.email = USER_EMAIL;
43 auth.user.password = USER_PASSWORD;
44 config.token_status_callback = tokenStatusCallback; // giriş durumunu izle / watch sign-in status
45
46 Firebase.begin(&config, &auth); // arka planda giriş yapar / signs in in the background
47}
48
49void loop() {
50 if (!Firebase.ready()) return; // token hazır değil / token not ready
51 if (millis() - sonGonderim < ARALIK) return;
52 sonGonderim = millis();
53
54 float t = dht.readTemperature();
55 float h = dht.readHumidity();
56 if (isnan(t) || isnan(h)) {
57 Serial.println("DHT22 okunamadi / read failed");
58 return;
59 }
60
61 FirebaseJson json;
62 json.set("sicaklik", t);
63 json.set("nem", h);
64 json.set("zaman/.sv", "timestamp"); // sunucu saati / server timestamp
65
66 String kok = String("/cihazlar/") + auth.token.uid.c_str();
67 String yolSon = kok + "/son";
68 String yolKayit = kok + "/kayit";
69
70 if (Firebase.RTDB.setJSON(&fbdo, yolSon.c_str(), &json)) { // son ölçümü güncelle / update latest
71 Serial.printf("Yazildi: %.1f C, %.0f %%\n", t, h);
72 } else {
73 Serial.println(fbdo.errorReason());
74 }
75
76 if (!Firebase.RTDB.pushJSON(&fbdo, yolKayit.c_str(), &json)) { // geçmişe ekle / append to history
77 Serial.println(fbdo.errorReason());
78 }
79}| Line / function | What it does |
|---|---|
| Firebase.begin(&config, &auth) | Loads the settings, signs in in the background and gets a token. |
| Firebase.ready() | Returns true if the token is ready and valid; renews it if it's about to expire. It must be called before every request. |
| Firebase.RTDB.setJSON() | Completely replaces the content at the given path with the new JSON. |
| Firebase.RTDB.pushJSON() | Adds a new record with a unique, time-ordered key under the path. |
| json.set("zaman/.sv", "timestamp") | Writes the server's own time (Unix time in milliseconds); no clock setup is needed on the ESP32. |
| fbdo.errorReason() | If the request fails, gives the reason for the error as text. |
Each record, including its key, takes about 100 bytes. One record every 30 seconds means 2,880 records a day and roughly 0.3 MB; the 1 GB of storage on the free plan wouldn't fill up at this rate for years. If you cut the interval to 1 second, you get 86,400 records a day and about 8.6 MB; on top of that, every client that reads this data uses up your 10 GB monthly download quota. That's why for live displays it's a good habit to read only the latest node and fetch the history only when drawing a chart.
Controlling an LED from the database: instant response with a stream
There are two ways to control an LED remotely. The first is to query the value every few seconds inside loop; it's simple, but every query is a new HTTPS request and the response is delayed by up to the polling interval. The second is the stream: the ESP32 subscribes once to the /cihazlar/UID/led path, the connection stays open, and the moment you change the value in the console the new value reaches the ESP32. The code below uses this method. On the ESP32 the stream callback runs in a separate task, so instead of changing the LED directly there, we change it in loop via a flag; this also prevents long operations from blocking the stream.
1#include <WiFi.h>
2#include <Firebase_ESP_Client.h>
3#include "addons/TokenHelper.h"
4
5// Kendi bilgilerinle değiştir / Replace with your own values
6#define WIFI_SSID "WIFI_ADIN"
7#define WIFI_PASSWORD "WIFI_SIFREN"
8#define API_KEY "WEB_API_KEY"
9#define DATABASE_URL "https://proje-adin-default-rtdb.europe-west1.firebasedatabase.app"
10#define USER_EMAIL "[email protected]"
11#define USER_PASSWORD "sifre123"
12
13#define LED_PIN 26
14
15FirebaseData stream; // yalnızca dinleme için / for listening only
16FirebaseAuth auth;
17FirebaseConfig config;
18
19volatile bool yeniVeri = false;
20volatile bool ledDurum = false;
21bool streamAcik = false;
22
23// Değer değişince çağrılır / Called when the value changes
24void streamCallback(FirebaseStream data) {
25 if (data.dataType() == "boolean") {
26 ledDurum = data.boolData();
27 yeniVeri = true;
28 } else if (data.dataType() == "int") {
29 ledDurum = (data.intData() != 0); // 1 ve 0 da kabul / 1 and 0 also accepted
30 yeniVeri = true;
31 }
32}
33
34// Bağlantı zaman aşımında çağrılır / Called on stream timeout
35void streamTimeoutCallback(bool timeout) {
36 if (timeout) Serial.println("Stream zaman asimi, devam ediliyor / timeout, resuming");
37 if (!stream.httpConnected()) Serial.println(stream.errorReason());
38}
39
40void setup() {
41 Serial.begin(115200);
42 pinMode(LED_PIN, OUTPUT);
43 digitalWrite(LED_PIN, LOW);
44
45 WiFi.mode(WIFI_STA);
46 WiFi.setAutoReconnect(true);
47 WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
48 while (WiFi.status() != WL_CONNECTED) {
49 delay(300);
50 Serial.print(".");
51 }
52 Serial.println();
53
54 config.api_key = API_KEY;
55 config.database_url = DATABASE_URL;
56 auth.user.email = USER_EMAIL;
57 auth.user.password = USER_PASSWORD;
58 config.token_status_callback = tokenStatusCallback;
59 Firebase.begin(&config, &auth);
60}
61
62void loop() {
63 // Giriş tamamlanınca stream'i bir kez başlat / Start the stream once after sign-in
64 if (Firebase.ready() && !streamAcik) {
65 String yol = String("/cihazlar/") + auth.token.uid.c_str() + "/led";
66 if (Firebase.RTDB.beginStream(&stream, yol.c_str())) {
67 Firebase.RTDB.setStreamCallback(&stream, streamCallback, streamTimeoutCallback);
68 streamAcik = true;
69 Serial.println("Dinleniyor / Listening: " + yol);
70 } else {
71 Serial.println(stream.errorReason());
72 delay(2000);
73 }
74 }
75
76 // Yeni değer geldiyse LED'i güncelle / Update the LED when new data arrives
77 if (yeniVeri) {
78 yeniVeri = false;
79 digitalWrite(LED_PIN, ledDurum ? HIGH : LOW);
80 Serial.println(ledDurum ? "LED ACIK / ON" : "LED KAPALI / OFF");
81 }
82}After uploading the code, open the Realtime Database page in the Firebase console, add a key named led inside your own UID under the cihazlar node, choose boolean as the value type and enter true. When the stream opens, Firebase first sends the existing value at the path and then every change, so even if the ESP32 restarts, the LED returns to the last saved state. If you apply the same structure to a relay module, you can switch a lamp, fan or water pump on and off over the internet.
Firebase with the Raspberry Pi Pico W (MicroPython)
There's no widely used Firebase library for the Pico W like the one for the ESP32, but you don't need one: Realtime Database also exposes every path as a REST address. You add .json to the end of the path and write with PUT or read with GET. For authentication, you first send the email and password to Firebase's sign-in service to get an idToken and the user ID localId, then add the token to every request with the ?auth= parameter. Because the token is valid for one hour, the code signs in again every 50 minutes. This method isn't as fast as a stream; the LED state is polled in each 10-second loop. For setting up Pico W Wi-Fi, see the Pico W Wi-Fi web server post.
1import network, time, urequests, dht
2from machine import Pin
3
4# Kendi bilgilerinle değiştir / Replace with your own values
5SSID = "WIFI_ADIN"
6SIFRE_WIFI = "WIFI_SIFREN"
7API_KEY = "WEB_API_KEY"
8DB_URL = "https://proje-adin-default-rtdb.europe-west1.firebasedatabase.app"
9EMAIL = "[email protected]"
10SIFRE = "sifre123"
11
12sensor = dht.DHT22(Pin(15))
13led = Pin(14, Pin.OUT)
14
15wlan = network.WLAN(network.STA_IF)
16wlan.active(True)
17wlan.connect(SSID, SIFRE_WIFI)
18while not wlan.isconnected(): # bağlantıyı bekle / wait for connection
19 time.sleep(0.5)
20print("IP:", wlan.ifconfig()[0])
21
22def giris():
23 # E-posta/şifre ile token al / Get a token with email/password
24 url = "https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=" + API_KEY
25 r = urequests.post(url, json={"email": EMAIL, "password": SIFRE, "returnSecureToken": True})
26 cevap = r.json()
27 r.close()
28 return cevap["idToken"], cevap["localId"] # token ve UID / token and UID
29
30token, uid = giris()
31giris_zamani = time.time()
32
33while True:
34 try:
35 if time.time() - giris_zamani > 3000: # 50 dakikada bir yenile / refresh every 50 min
36 token, uid = giris()
37 giris_zamani = time.time()
38 kok = DB_URL + "/cihazlar/" + uid
39 sensor.measure()
40 veri = {"sicaklik": sensor.temperature(), "nem": sensor.humidity(),
41 "zaman": {".sv": "timestamp"}} # sunucu saati / server timestamp
42 r = urequests.put(kok + "/son.json?auth=" + token, json=veri)
43 r.close()
44 r = urequests.get(kok + "/led.json?auth=" + token)
45 durum = r.json() # true, false ya da None / true, false or None
46 r.close()
47 led.value(1 if durum else 0)
48 print(veri["sicaklik"], veri["nem"], "LED:", durum)
49 except Exception as e:
50 print("Hata / Error:", e)
51 time.sleep(10)Firebase or Google Sheets?
| Criterion | Firebase Realtime Database | Google Sheets (Apps Script) |
|---|---|---|
| Data direction | Two-way: write, read and instant listening | Usually one-way: from the device to the sheet |
| Latency | Changes usually in under 1 second | Each request can take a few seconds |
| Device control | LED, relay, servo instantly with a stream | Not suitable; constant polling is needed |
| Charts and analysis | You have to write your own web page or app | Ready-made charts, formulas, export to Excel |
| Security | Detailed per-user rules | Anyone who knows the publicly published script address can write |
| Limits | Spark: 1 GB storage, 10 GB download per month | Up to 10 million cells per file, Apps Script quotas |
| Setup | Medium: project, authentication, rules | Easy: a sheet and a short script |
In short, if your goal is only to log readings and draw a weekly chart, the ESP32 with Google Sheets method is quicker to set up and you see your data right in the sheet. If you want to control the device remotely, monitor several devices at once or build a live display with a mobile app, Firebase is the better choice. You can also use the two together: keep the live status in Firebase and the daily summary in Sheets. If you'll connect to a home automation system, MQTT and Home Assistant is also a strong alternative.
ESP32 Firebase project ideas
- Remote greenhouse monitoring: Write temperature, humidity and soil moisture values to Firebase and run the irrigation pump with a switch in the database.
- Smart plug: Control the relay with a stream and log how long it stays on in the database; see the ESP32 smart plug post for details.
- Motion log: Each time the PIR sensor triggers, add a timestamped record with push and review the history from your phone.
- Multi-room weather station: Put an ESP32 in each room, let each write under its own UID, and watch them all live on a single web page.
- Remotely adjustable thermostat: Read the target temperature from the database and control the heater accordingly; the Arduino thermostat post is a good starting point for the logic.
- Battery-powered sensor: After writing the reading, go into deep sleep mode, and wake up every few minutes to send a new value.
Common errors and how to fix them
| Error / symptom | Likely cause | Fix |
|---|---|---|
| Permission denied | The rules don't allow the request, or test mode has expired | Check the Rules tab; make sure the path starts with /cihazlar/UID |
| EMAIL_NOT_FOUND, INVALID_PASSWORD or INVALID_LOGIN_CREDENTIALS | The user doesn't exist or the password is wrong | Verify the email and password in the Authentication > Users list |
| OPERATION_NOT_ALLOWED | The Email/Password provider isn't enabled | Enable it on the Sign-in method tab |
| API key not valid | The API key is missing or copied wrongly | Copy the key again from the Project settings page |
| token is not ready | A request was sent before sign-in finished | Check Firebase.ready() before every request; verify the Wi-Fi connection |
| connection refused, send request failed | Wrong DATABASE_URL, weak signal or a 5 GHz network | Copy the address exactly from the console; connect to a 2.4 GHz network |
| ESP32 keeps restarting | Current spike during Wi-Fi and TLS (brownout) | Use a good USB cable and a strong power supply |
| Firebase_ESP_Client.h not found | The wrong library is installed (for example FirebaseClient) | Install Mobizt's Firebase Arduino Client Library for ESP8266 and ESP32 |
An easier way: BlueGrays IoT
Firebase gives you full control over your database structure and security rules. But if you just want to switch a relay or watch a sensor from your phone, you don't have to create a project, write Realtime Database rules, add an Authentication user and copy the API key and DATABASE_URL into your code by hand. BlueGrays IoT in the BlueGrays app starts from ready templates under Workshop › My devices › Add new device: Ohmi prepares the code with your device key, you upload it once from Arduino IDE with the BlueGraysIoT library, and then you get switches, live values and charts on your phone. It works with the ESP32 and Raspberry Pi Pico W on 2.4 GHz Wi-Fi, and your first device is free; see the guide to controlling an ESP32 from your phone for details.
With Firebase, your ESP32 is no longer just a measuring device; it talks over the internet and takes commands. Run the sensor-writing example first, then add LED control with a stream, and be sure to tie the rules to authentication. In the BlueGrays app you can go through the ESP32 Wi-Fi connection, NTP clock, web server, WebSocket and DHT22 temperature logger projects step by step with circuit diagrams and code, and easily add the Firebase layer from this post on top of them.
Frequently asked questions
Is using Firebase with the ESP32 free?
Yes, Firebase's free Spark plan offers 1 GB of storage, 10 GB of downloads per month and 100 simultaneous connections for Realtime Database. Hobby projects where a few ESP32s write data every 30 seconds stay far below these limits. You can create a project without adding a credit card.
What is the difference between Firebase Realtime Database and Firestore?
Realtime Database keeps data in a single JSON tree, is simple to set up, and live listening with streams is mature in the ESP32 libraries. Firestore uses collections and documents and is stronger for complex queries, but its free plan limits daily reads and writes. For sensor data and device control, Realtime Database is usually more practical.
Why won't my ESP32 connect to Firebase?
The most common causes are a wrongly copied database address, Email/Password sign-in that isn't enabled, a wrong API key and a 5 GHz Wi-Fi network. If you get a Permission denied error, your security rules don't allow the request. Reading the tokenStatusCallback output in the Serial Monitor shows at which step the problem is.
Is it safe to keep the Firebase API key in the code?
The Web API key only identifies the project and doesn't grant access to the database on its own. The real security comes from authentication and security rules; if your rules include auth != null or a UID check, someone who knows the key can't read data without signing in. Still, remember to remove your Wi-Fi and user passwords when you share the code publicly.
How often can the ESP32 send data to Firebase?
Each HTTPS request takes a few hundred milliseconds depending on the connection, so technically writing once a second is possible. For slowly changing data such as temperature, though, an interval between 10 seconds and a few minutes protects both your quota and your energy. For control tasks that need instant response, using a stream instead of polling is more efficient.
Does the same code work with the ESP8266 (NodeMCU)?
The Firebase ESP Client library also supports the ESP8266; you only need to include ESP8266WiFi.h instead of WiFi.h. Because the ESP8266 has less RAM, TLS connections can strain memory, so you should use only one FirebaseData object at a time and combine streaming with writing carefully. If you're starting a new project, the ESP32 is the more comfortable choice.
Projects to build after reading this
See all projects
LED Blink with ESP32
Teaches basic GPIO output usage with ESP32. We achieve a blinking effect by turning an LED on and off from a digital pin. ESP32 version of the classic blink project on Arduino UNO; the basic blink commands in the Arduino environment are the same, but the ESP32's pin layout and 3.3 V GPIO levels differ from those of the Arduino UNO.

ESP32 DHT22 Temperature and Humidity (with LCD Display)
This project measures ambient temperature and humidity using a DHT22 sensor and displays the data in real time on a 16x2 I2C LCD. Data is read from the sensor using the one-wire protocol via the Adafruit DHT library. This project serves as the foundation for IoT weather stations, smart home automation, or environmental monitoring systems in greenhouses. Communication with the DHT22 is established via the ESP32's GPIO 4 pin.

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.

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.

ESP32 Asynchronous Web Server (with IP Display on LCD)
In this project, we’re turning the ESP32 into an asynchronous web server that you can control from your phone or computer on the same Wi-Fi network. Thanks to the ESPAsyncWebServer library, the server can process multiple requests simultaneously (unlike the classic WebServer.h, which blocks on a single request). You’ll be able to open the ESP32’s IP address in a browser and click the ON/OFF buttons (the /on and /off routes) to turn the LED connected to GPIO 5 on and off.

ESP32 WebSocket Counter (2 Buttons + LCD + Real-Time Web)
In this project, two buttons wired to the ESP32 (GPIO 5 counts up, GPIO 4 counts down) change a counter. The value updates instantly both on a 16x2 I2C LCD and, through the WebSocket support of ESPAsyncWebServer, in every connected browser without reloading the page. Instead of HTTP polling a single persistent connection is used, and the ESP32 sends the new value to everyone with ws.textAll().

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.

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.
More articles
BlueGrays app
Build this circuit step by step on your phone
Wiring diagram, code and parts list on one screen. 500+ Arduino, ESP32 and Pico projects ready to build.
Scan with your phone
Point your camera at the code and your phone's app store opens.
or open the store

