ArduinoJson Tutorial: Read and Write JSON with v7 Examples
ArduinoJson 7 tutorial: JsonDocument, deserializeJson error codes, nested objects and arrays, filters, Uno vs ESP32 memory, plus weather API and MQTT examples.
ArduinoJson is the most widely used C++ library for reading (parsing) and creating JSON on boards such as Arduino, ESP32, ESP8266 and the Raspberry Pi Pico. You need JSON whenever you want to decode a reply from a weather API, send a sensor reading over MQTT or store settings in a file; ArduinoJson turns that text into variables in a few lines, and turns variables back into JSON text in one.
This tutorial is based on the current ArduinoJson 7. You'll see how to read and write with JsonDocument, what the error codes returned by deserializeJson mean, how to walk through nested objects and arrays, how memory differs between the Uno and the ESP32, how to shrink large replies with a filter, a real weather and MQTT example, and finally how to update old version 6 code. All Arduino sketches were compiled with ArduinoJson 7.4.
What is JSON and how does ArduinoJson work?
JSON is a simple format that carries data as text. Curly braces { } mark an object and square brackets [ ] mark an array; objects contain "key": value pairs. ArduinoJson reads the text and builds a tree in memory, called a JsonDocument. Building the tree from text is called deserializing (parsing), and producing text from the tree is called serializing. You reach each branch of the tree with square brackets such as doc["key"] or doc[0].
| JSON type | Example | Reading it in ArduinoJson |
|---|---|---|
| Object | {"sehir":"Ankara"} | doc["sehir"] or JsonObject |
| Array | [6.9, 6.1, 5.8] | doc["saatlik"][0] or JsonArray |
| String | "Ankara" | const char* or String |
| Number | 7.4, 81 | float, int, long |
| Boolean | true, false | bool |
| Null | null | doc["x"].isNull() returns true |
Installing ArduinoJson
- In the Arduino IDE, open Tools > Manage Libraries (Ctrl+Shift+I).
- Type ArduinoJson in the search box and find the library by Benoit Blanchon.
- Pick the newest release of the 7.x series from the version list and click Install.
- Add #include <ArduinoJson.h> at the top of your sketch. To see which version is installed, you can print Serial.println(ARDUINOJSON_VERSION).
- If you use PlatformIO, add the line lib_deps = bblanchon/ArduinoJson@^7 to platformio.ini.
Reading JSON: deserializeJson
The first example parses JSON stored in a string and reads the city name, temperature, humidity, the nested wind speed and the hourly forecast array. It needs no internet and runs unchanged on the Arduino Uno, Nano, ESP32 and Pico. Open the Serial Monitor at 115200 baud:
1// ArduinoJson 7: metindeki JSON'u oku (Uno, Nano, ESP32, Pico'da çalışır)
2// ArduinoJson 7: read JSON from text (works on Uno, Nano, ESP32 and Pico)
3#include <ArduinoJson.h>
4
5const char girdi[] =
6 "{\"sehir\":\"Ankara\",\"sicaklik\":7.4,\"nem\":81,"
7 "\"ruzgar\":{\"hiz\":12.5,\"yon\":\"KB\"},"
8 "\"saatlik\":[6.9,6.1,5.8]}";
9
10void setup() {
11 Serial.begin(115200);
12 while (!Serial) {} // USB'li kartlarda port açılsın / wait for the port on USB boards
13
14 JsonDocument doc; // boyut yok: bellek kendiliğinden ayrılır / no size: memory grows by itself
15 DeserializationError hata = deserializeJson(doc, girdi);
16 if (hata) { // Ok değilse dur / stop if not Ok
17 Serial.print(F("JSON hatasi / JSON error: "));
18 Serial.println(hata.c_str()); // ör. InvalidInput, NoMemory / e.g. InvalidInput, NoMemory
19 return;
20 }
21
22 const char* sehir = doc["sehir"]; // metin / string
23 float sicaklik = doc["sicaklik"]; // ondalık sayı / float
24 int nem = doc["nem"] | -1; // anahtar yoksa -1 / -1 if the key is missing
25 float ruzgar = doc["ruzgar"]["hiz"]; // iç içe nesne / nested object
26 float ilkSaat = doc["saatlik"][0]; // dizinin ilk elemanı / first array element
27
28 Serial.print(sehir);
29 Serial.print(F(": "));
30 Serial.print(sicaklik, 1);
31 Serial.print(F(" C, nem / humidity %"));
32 Serial.println(nem);
33 Serial.print(F("Ruzgar / wind: "));
34 Serial.print(ruzgar, 1);
35 Serial.print(F(" km/h, 1 saat sonra / in 1 h: "));
36 Serial.println(ilkSaat, 1);
37
38 JsonArray saatlik = doc["saatlik"]; // dizide gez / loop over the array
39 for (float t : saatlik) {
40 Serial.print(t, 1);
41 Serial.print(' ');
42 }
43 Serial.println();
44
45 if (doc["basinc"].is<float>()) { // anahtar var mı? (v6'daki containsKey) / does the key exist? (containsKey in v6)
46 Serial.println(F("Basinc var / pressure present"));
47 }
48}
49
50void loop() {
51}| Line | What does it do? |
|---|---|
| JsonDocument doc; | Creates an empty document; memory grows automatically as needed |
| deserializeJson(doc, girdi) | Parses the text and returns the result as a DeserializationError |
| if (hata) | False when there's no error; hata.c_str() gives the error name |
| doc["nem"] | -1 | Uses -1 if the key is missing or has the wrong type |
| doc["ruzgar"]["hiz"] | Reaches a field inside a nested object |
| for (float t : saatlik) | Walks through every element of the array |
| doc["basinc"].is<float>() | Returns true if the key exists and holds a number |
deserializeJson error codes and fixes
deserializeJson always returns a DeserializationError. Writing if (hata) is enough, because the result is false only when it's Ok. To react differently to each error, compare it, for example hata.code() == DeserializationError::NoMemory. The most common codes and their fixes:
| Error code | Meaning | Likely cause | Fix |
|---|---|---|---|
| Ok | Success | - | Read the values |
| EmptyInput | The input is empty | The server returned an empty reply or no data arrived from the stream | Check the HTTP code and increase the wait with Serial.setTimeout |
| IncompleteInput | The JSON ended halfway | The connection dropped, a timeout hit or the buffer was too small | Use a bigger buffer, read from the stream and keep the connection open until the document ends |
| InvalidInput | Not valid JSON | An HTML error page, a chunked HTTP reply or hidden characters in the text | Print the reply first; use useHTTP10(true) with HTTPClient |
| NoMemory | Out of memory | The document is large and the board has little free RAM | Use a filter, skip unneeded fields and keep the document inside a function |
| TooDeep | Too many nesting levels | Objects nested deeper than 10 levels | Raise the limit with DeserializationOption::NestingLimit(20) |
Creating and sending JSON: serializeJson
Writing is the reverse of reading: you assign keys to an empty JsonDocument, use doc["konum"].to<JsonObject>() for a nested object and doc["son"].to<JsonArray>() for an array, then turn it into text with serializeJson. The sketch below builds a room sensor message and prints it in three ways:
1// ArduinoJson 7: JSON oluştur ve yazdır / build and print JSON
2#include <ArduinoJson.h>
3
4void setup() {
5 Serial.begin(115200);
6 while (!Serial) {}
7
8 JsonDocument doc;
9 doc["cihaz"] = "salon"; // metin / string
10 doc["sicaklik"] = 22.6; // sayı / number
11 doc["pencereAcik"] = false; // mantıksal / boolean
12
13 JsonObject konum = doc["konum"].to<JsonObject>(); // iç içe nesne (v6: createNestedObject) / nested object
14 konum["kat"] = 2;
15 konum["oda"] = "salon";
16
17 JsonArray son = doc["son"].to<JsonArray>(); // dizi (v6: createNestedArray) / array
18 son.add(22.1);
19 son.add(22.4);
20 son.add(22.6);
21
22 if (doc.overflowed()) { // bellek yetmediyse true / true if memory ran out
23 Serial.println(F("Bellek yetmedi / out of memory"));
24 return;
25 }
26
27 serializeJson(doc, Serial); // tek satır: ağ ve MQTT için / one line: for network and MQTT
28 Serial.println();
29 serializeJsonPretty(doc, Serial); // girintili: okumak için / indented: for reading
30 Serial.println();
31
32 char tampon[128]; // sabit tampon (String yerine) / fixed buffer (instead of String)
33 size_t uzunluk = serializeJson(doc, tampon, sizeof(tampon));
34 Serial.print(F("Bayt / bytes: "));
35 Serial.print(uzunluk);
36 Serial.print(F(" / gerekli / needed: "));
37 Serial.println(measureJson(doc));
38}
39
40void loop() {
41}serializeJson accepts Serial, a char array, a String or any stream such as a WiFiClient as its target, and returns the number of bytes written. measureJson calculates in advance how many bytes the same document will take; that's handy for filling the Content-Length header of an HTTP request or checking whether a buffer is big enough. serializeJsonPretty gives indented, readable output, but the whitespace makes it longer; use the single-line serializeJson for anything you send over the network. doc.overflowed() returns true if memory ran out while the document was being built.
Memory usage: JsonDocument on the Uno and the ESP32
In version 7, JsonDocument takes memory from the heap in small pools and grows as needed; unlike version 6, you don't have to calculate a capacity. Every value in the document takes one slot; object members use two slots, one for the key and one for the value, and parsed strings are also copied into the document. A slot is 6 bytes on 8-bit boards and 8 bytes on 32-bit boards. For example, a small object with six members takes about 12 × 8 = 96 bytes on the ESP32, plus its strings. When the first example was compiled for the Arduino Uno it used 10,962 bytes of flash (33 percent) and 474 bytes of global RAM; the document itself comes from the heap at run time on top of that.
| Feature | Arduino Uno (ATmega328P) | ESP32 |
|---|---|---|
| Total RAM | 2 KB | 520 KB SRAM (hundreds of KB of free heap) |
| Slot size | 6 bytes | 8 bytes |
| Memory pool block | 96 bytes (16 slots) | 1 KB (128 slots) |
| Decimal numbers | float (about 7 digits) | double (about 15 digits) |
| Longest string | 255 characters | 65,535 characters |
| Comfortable document size | A few hundred bytes | Tens of KB |
Weather API on the ESP32: streams and filters
In real projects JSON usually comes from the internet. The sketch below fetches the current temperature, humidity and weather code, plus the day's 24-hour temperature forecast, from a weather service that needs no API key. Instead of copying the reply into a String first, it passes http.getStream() straight to deserializeJson, so no second buffer is allocated for the whole reply. The useHTTP10(true) line stops the server from sending a chunked reply; without it, the chunk lengths mixed into the body break the JSON and you get InvalidInput. The basics of working with APIs are in ESP32 Weather API.
1// ESP32: hava durumu API'sinden JSON'u akış olarak oku, filtreyle yalnız gerekeni sakla
2// ESP32: read the weather API JSON as a stream, keep only what you need with a filter
3#include <WiFi.h>
4#include <HTTPClient.h>
5#include <ArduinoJson.h>
6
7const char* WIFI_SSID = "AgAdi";
8const char* WIFI_PASS = "Sifre123";
9const char* URL = "http://api.open-meteo.com/v1/forecast?latitude=41.01&longitude=28.98"
10 "¤t=temperature_2m,relative_humidity_2m,weather_code"
11 "&hourly=temperature_2m&forecast_days=1&timezone=auto";
12
13void havaDurumu() {
14 HTTPClient http;
15 http.useHTTP10(true); // parçalı (chunked) yanıt gelmesin / avoid chunked replies
16 http.begin(URL);
17 int kod = http.GET();
18 if (kod != HTTP_CODE_OK) {
19 Serial.printf("HTTP hatasi / HTTP error: %d\n", kod);
20 http.end();
21 return;
22 }
23
24 JsonDocument filtre; // yalnız true olan alanlar saklanır / only fields set to true are kept
25 filtre["current"]["temperature_2m"] = true;
26 filtre["current"]["relative_humidity_2m"] = true;
27 filtre["current"]["weather_code"] = true;
28 filtre["hourly"]["temperature_2m"][0] = true; // dizinin her elemanına uygulanır / applies to every element
29
30 JsonDocument doc;
31 DeserializationError hata = deserializeJson(doc, http.getStream(),
32 DeserializationOption::Filter(filtre));
33 http.end();
34 if (hata) {
35 Serial.printf("JSON hatasi / JSON error: %s\n", hata.c_str());
36 return;
37 }
38
39 float sicaklik = doc["current"]["temperature_2m"];
40 int nem = doc["current"]["relative_humidity_2m"];
41 int kodHava = doc["current"]["weather_code"];
42 JsonArray saatlik = doc["hourly"]["temperature_2m"];
43 float enYuksek = -100;
44 for (float t : saatlik) { // günün en yüksek sıcaklığı / the day's maximum
45 if (t > enYuksek) enYuksek = t;
46 }
47 Serial.printf("%.1f C, %%%d, kod / code %d, en yuksek / max %.1f C (%u saat / hours)\n",
48 sicaklik, nem, kodHava, enYuksek, saatlik.size());
49}
50
51void setup() {
52 Serial.begin(115200);
53 WiFi.mode(WIFI_STA);
54 WiFi.begin(WIFI_SSID, WIFI_PASS);
55 while (WiFi.status() != WL_CONNECTED) delay(250);
56 havaDurumu();
57}
58
59void loop() {
60 delay(600000); // 10 dakikada bir / every 10 minutes
61 havaDurumu();
62}A filter is also a JsonDocument: you set the fields you want to keep to true, and everything else is skipped while parsing. For arrays, setting the first element to true is enough; the rule applies to every element. Even though the service returns many extra fields such as time, units and location, only four values and a 24-number array end up in the document, which is why the same approach also works on small boards like the Uno.
Sending and reading MQTT messages as JSON
Smart home systems that use MQTT usually expect readings as JSON. The sketch below uses the PubSubClient library to publish temperature, humidity, signal strength and uptime in a single JSON message every 30 seconds; it also parses a command like {"led":"on"} arriving on the ev/salon/komut topic and switches the LED. Because incoming MQTT data isn't null-terminated, you must pass its length to deserializeJson along with the data. PubSubClient's default packet limit is 256 bytes, topic included; for longer messages add mqtt.setBufferSize(512). We cover the Home Assistant side in ESP32 MQTT and Home Assistant.
1// ESP32 + MQTT: ölçümü JSON olarak yayınla, gelen JSON komutunu çöz
2// ESP32 + MQTT: publish a reading as JSON, decode an incoming JSON command
3#include <WiFi.h>
4#include <PubSubClient.h>
5#include <ArduinoJson.h>
6
7const char* WIFI_SSID = "AgAdi";
8const char* WIFI_PASS = "Sifre123";
9const char* BROKER = "192.168.1.10"; // broker'ın IP adresi / the broker's IP address
10const int LED_PIN = 2;
11
12WiFiClient ag;
13PubSubClient mqtt(ag);
14unsigned long sonGonderim = 0;
15
16void mesajGeldi(char* konu, byte* veri, unsigned int uzunluk) {
17 JsonDocument doc;
18 DeserializationError hata = deserializeJson(doc, veri, uzunluk); // veri sonu sıfırla bitmez, uzunluk şart / payload isn't null-terminated, length is required
19 if (hata) {
20 Serial.printf("Komut okunamadi / bad command: %s\n", hata.c_str());
21 return;
22 }
23 const char* led = doc["led"] | ""; // {"led":"on"} ya da {"led":"off"} / {"led":"on"} or {"led":"off"}
24 if (strcmp(led, "on") == 0) digitalWrite(LED_PIN, HIGH);
25 if (strcmp(led, "off") == 0) digitalWrite(LED_PIN, LOW);
26}
27
28void baglan() {
29 while (!mqtt.connected()) {
30 if (mqtt.connect("esp32-salon")) {
31 mqtt.subscribe("ev/salon/komut");
32 } else {
33 delay(5000); // 5 sn sonra yeniden dene / retry after 5 s
34 }
35 }
36}
37
38void setup() {
39 Serial.begin(115200);
40 pinMode(LED_PIN, OUTPUT);
41 WiFi.mode(WIFI_STA);
42 WiFi.begin(WIFI_SSID, WIFI_PASS);
43 while (WiFi.status() != WL_CONNECTED) delay(250);
44 mqtt.setServer(BROKER, 1883);
45 mqtt.setCallback(mesajGeldi);
46}
47
48void loop() {
49 baglan();
50 mqtt.loop();
51
52 if (millis() - sonGonderim > 30000) { // 30 sn'de bir ölçüm / a reading every 30 s
53 sonGonderim = millis();
54 JsonDocument doc;
55 doc["sicaklik"] = 22.6; // burada sensörünü oku / read your sensor here
56 doc["nem"] = 48;
57 doc["rssi"] = WiFi.RSSI();
58 doc["sure"] = millis() / 1000;
59
60 char tampon[128];
61 serializeJson(doc, tampon, sizeof(tampon)); // sonuna sıfır eklenir / null-terminated
62 mqtt.publish("ev/salon/durum", tampon); // paket sınırı 256 bayt (konu dahil) / packet limit 256 bytes (topic included)
63 }
64}Migrating from ArduinoJson 6 to 7
Version 7 still compiles most old code but gives "deprecated" warnings for the removed constructs. The warnings don't stop your code from working today, but since these constructs may disappear completely in the next major version, it's best to update. We verified the equivalents in the table below by compiling them with ArduinoJson 7.4:
| Version 6 | Version 7 | Note |
|---|---|---|
| StaticJsonDocument<256> doc; | JsonDocument doc; | The document always lives on the heap; no size is given |
| DynamicJsonDocument doc(1024); | JsonDocument doc; | Capacity grows by itself |
| doc.createNestedObject("k") | doc["k"].to<JsonObject>() | For arrays, to<JsonArray>() |
| doc.createNestedArray("k") | doc["k"].to<JsonArray>() | Inside an array, add<JsonArray>() |
| doc.containsKey("k") | doc["k"].is<T>() | Deprecated since 7.2; also checks the type |
| Capacity from JSON_OBJECT_SIZE(3) | Not needed | The macros were removed |
| doc.memoryUsage() | doc.overflowed() | memoryUsage now always returns 0 |
| Zero-copy with a char* input | Gone | Strings are always copied into the document |
JSON on the Raspberry Pi Pico and in MicroPython
If you program the Pico with the Arduino IDE, the ArduinoJson sketches above work unchanged. In MicroPython you don't need an extra library: the built-in json module turns text into a Python dict with json.loads and a dict into text with json.dumps. Replies from the requests module can be parsed directly with r.json(). If you're new to MicroPython, see MicroPython Basics, and for MQTT on the Pico W, Pico W MQTT.
1# MicroPython (Pico W): yerleşik json modülü / built-in json module
2import json
3
4metin = '{"sehir":"Ankara","sicaklik":7.4,"ruzgar":{"hiz":12.5},"saatlik":[6.9,6.1,5.8]}'
5doc = json.loads(metin) # metin -> sözlük / text -> dict
6print(doc["sehir"], doc["ruzgar"]["hiz"])
7print(max(doc["saatlik"])) # dizi Python listesi olur / the array becomes a list
8basinc = doc.get("basinc", -1) # anahtar yoksa -1 / -1 if the key is missing
9
10paket = json.dumps({"cihaz": "pico", "sicaklik": 21.5, "son": [21.1, 21.3]})
11print(paket) # MQTT ya da HTTP ile gönderilebilir / ready for MQTT or HTTP
12
13# İnternetten: requests ile gelen yanıt doğrudan çözülür / from the internet: decode the reply directly
14# import requests
15# r = requests.get("http://api.open-meteo.com/v1/forecast?latitude=41.01&longitude=28.98¤t=temperature_2m")
16# print(r.json()["current"]["temperature_2m"])
17# r.close()Common mistakes and fixes
- Wrong library: compiling an ArduinoJson example with Arduino_JSON installed gives a "JsonDocument was not declared" error. Install the right library; removing the wrong one also avoids confusion.
- A missing key returns 0: if doc["sicaklik"] doesn't exist, 0 is written to the float and looks like a real reading. Use the | operator for a default value or check with is<float>().
- A number in quotes: in JSON, "12" is a string; reading it as an int gives 0. Fix the sender or read the text and convert it with atoi.
- Forgetting the length of MQTT data: parsing the byte array from the callback without its length makes the parser read random bytes past the end and produces InvalidInput or wrong values.
- Chunked HTTP reply: when reading from the stream without useHTTP10(true), chunk lengths get mixed into the reply and the JSON breaks.
- Making the document global: a long-lived global JsonDocument keeps growing as new fields are added. Create the document inside the function that uses it; the memory is released automatically when it's done.
Once you know ArduinoJson, projects that fetch data from the internet, send messages to your phone or talk to your smart home are within reach. In the BlueGrays app you can browse ESP32 projects that fetch the weather from the internet and show it on an LCD or OLED display, along with other Wi-Fi projects, each with a step-by-step circuit diagram and ready-to-use code, and try the JSON examples from this article directly in them.
Frequently asked questions
Which version of ArduinoJson should I install?
For new projects, install the latest release of the 7.x series. Version 7 manages memory by itself and needs no capacity calculation. If an old sketch you found online was written for version 6, it usually still compiles, but use the equivalents in the migration table to get rid of the warnings.
Why does StaticJsonDocument give a deprecated warning?
In ArduinoJson 7, StaticJsonDocument and DynamicJsonDocument were merged into a single JsonDocument class. The old names still compile for compatibility but produce a warning. Delete the old declaration together with its size parameter and simply write JsonDocument doc; instead.
Why does deserializeJson return NoMemory?
NoMemory is returned when the heap doesn't have the memory needed to build the document. On boards with 2 KB of RAM like the Uno, large API replies are the most common cause. Use a filter to keep only the fields you need, create the document inside a function and, if possible, move the job to a board with more memory such as the ESP32.
Does ArduinoJson work on the Arduino Uno?
Yes. The reading example in this article used about 11 KB of flash and 474 bytes of global RAM when compiled for the Uno. On the Uno, decimal numbers are stored as float and strings can be at most 255 characters; documents of a few hundred bytes are handled without trouble.
How do I check whether a key exists in ArduinoJson?
In version 7, use the is() check on doc["key"] with the type you expect, such as int or float; it returns true if the key exists and the type matches. The old containsKey() still compiles but is deprecated. If you only want a default value, int nem = doc["nem"] | -1; is shorter.
What's the difference between ArduinoJson and Arduino_JSON?
They are two different libraries. ArduinoJson, written by Benoit Blanchon, uses JsonDocument and is the most widely used. Arduino_JSON is the Arduino team's simpler library based on JSONVar. Their code isn't interchangeable, so install the one that matches the include line in your example.
Projects to build after reading this
See all projects
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 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.

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().

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 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.

ESP32 Motion Alarm System (PIR + Buzzer + LED + Telegram)
A smart security alarm: when the PIR sensor detects motion, it sounds the buzzer, lights the LED and sends the owner an instant Telegram notification. A 30-second cooldown limits how often the alarm repeats; it does not filter out the PIR sensor's false detections. Use it at home, in a garage, a storeroom or a study.

ESP32 mDNS: Accessing the Device via bluegrays-esp.local (with LCD Screen)
In this project we add an mDNS (Multicast DNS) service to the ESP32, so you reach it by a readable host name like bluegrays-esp.local instead of an IP address. Even if the IP assigned by DHCP changes, the device always answers to the same name. A small web server on the board lets you control the LED from your browser at http://bluegrays-esp.local/.
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, ESP8266, Pico, mBot and micro:bit 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

