Arduino IoT Cloud ESP32 Tutorial: Dashboard, Widgets and Code
Arduino IoT Cloud ESP32 tutorial: add a device and Thing, variables, auto-generated code, gauge and switch widgets, free plan, Blynk vs RainMaker.
Arduino IoT Cloud (now simply called Arduino Cloud) is Arduino's own cloud platform that lets you put Wi-Fi boards like the ESP32 online in a few clicks and control them from a browser or a phone. You only define the variables; the platform generates the code that keeps those variables in sync between the board and the cloud, and you build a dashboard by dragging and dropping gauges and switches. There's no server to set up, no MQTT broker to manage and no web page to write.
In this guide you'll learn how Arduino Cloud works (device, Thing, variables and dashboard), how to add an ESP32 as a third-party device, what the variable types and update settings mean, and what the generated code does line by line. Then you'll build an ESP32 dashboard with a DHT22 temperature and humidity sensor, an LED switch and an adjustable alarm threshold, try the phone app, learn the free plan limits and compare Arduino Cloud with Blynk and ESP RainMaker.

What is Arduino IoT Cloud and how does it work?
Arduino Cloud is made of four parts. The device is your real board; the ESP32 counts as a third-party device on the platform and connects to the cloud with a Device ID and a Secret Key. The Thing is the board's digital twin in the cloud: it holds which variables it carries, which Wi-Fi network it joins and which device it is paired with. Variables are values synced automatically between the board and the cloud; when you write sicaklik = 24.5 in your code, the value shows up on the dashboard shortly after, and when you flip a switch on the dashboard, the led variable on the board changes and its function runs. The dashboard is the screen made of widgets linked to those variables. Behind the scenes the ArduinoIoTCloud library uses a TLS-encrypted MQTT connection, but you don't write any of that by hand.
| Concept | What it does | Example in this guide |
|---|---|---|
| Device | Identifies the real board, issues an ID and a key | ESP32 Dev Module, name: salon-esp32 |
| Thing | The board's twin in the cloud: variables, network settings, paired device | Living Room Station |
| Variable | A value synced between the board and the cloud | sicaklik, nem, led, alarmEsigi, alarmDurumu |
| Dashboard | A screen of widgets linked to variables | Two gauges, a switch, a slider, an LED |
| Sketch | The code generated by the platform and completed by you | Main .ino, thingProperties.h, arduino_secrets.h |
| IoT Remote | App that opens dashboards on your phone | iOS and Android |
Free plan limits
Arduino Cloud has a free plan for personal use, and it's enough to learn or to build a small home project. The limit you'll feel most is 5 variables per Thing and 2 Things in total: the project in this guide uses all 5 variables. The second important limit is data retention; on the free plan history is kept for only 1 day, so if you want a week-long temperature chart you'll have to write the data somewhere else as well or move to a paid plan. The paid Maker plan offers 25 Things and 3 months of data retention. The values below are the ones listed on Arduino's plans page in November 2026; plan terms change from time to time, so check the current page before building a long-term project.
| Limit | Free plan | What it means in practice |
|---|---|---|
| Things | 2 | Two separate boards or projects |
| Variables | 5 per Thing | The project in this guide uses the full limit |
| Data retention | 1 day | Charts show only the last 24 hours |
| Compilations in the cloud editor | 25 per day | If you compile locally in the Arduino IDE this limit doesn't apply |
| Notifications (triggers) | 100 per day | Alarm emails and app notifications |
| Over-the-air updates (OTA) | Paid plans | On the free plan code is uploaded over USB |
| Users | 1 | Dashboard sharing and team features are on paid plans |
Step by step: adding the ESP32 as a device
- Create a free Arduino account at cloud.arduino.cc and open Arduino Cloud.
- To program boards from the browser, install the Arduino Cloud Agent on your computer; if you'll upload code with the Arduino IDE, you can skip this step.
- Go to Devices in the left menu and press the + Device button.
- In the window that opens, choose Third party device, then ESP32, and ESP32 Dev Module as the board model.
- Give the device a name such as salon-esp32; the Device ID and Secret Key appear on screen.
- Copy both values or download them as a PDF, then tick the checkbox and finish the setup.
Creating the Thing and defining variables
In the Things section press + Thing and give it a name such as Living Room Station. In the Associated Device field on the right, pick the salon-esp32 you just added; in the Network field, enter your Wi-Fi name, password and the device's Secret Key. The ESP32 can only join 2.4 GHz networks, so don't enter a 5 GHz network name. Then add the five variables below with the ADD VARIABLE button. For each variable you choose a name, a type, a permission and an update policy.
| Variable | Type | Permission | Update | Widget to link |
|---|---|---|---|---|
| sicaklik | Floating Point Number | Read Only | Periodic, 10 s | Gauge |
| nem | Floating Point Number | Read Only | Periodic, 10 s | Gauge |
| led | Boolean | Read & Write | On change | Switch |
| alarmEsigi | Integer Number | Read & Write | On change | Slider (20–40) |
| alarmDurumu | Boolean | Read Only | On change | LED |
The permission decides who can change the value: a Read Only variable is written only by the board and shown by the dashboard; a Read & Write variable can also be changed from the dashboard, which triggers a callback function on the board. The update policy says when the value is sent: On change sends it when the value changes (you can also set a threshold, e.g. only on 0.5 degree changes), while Periodically sends it every number of seconds you choose. Besides the basic types there are special ones such as CloudTemperatureSensor, CloudSwitch, CloudColor or CloudLocation; these are needed for the Alexa and Google Home integration. Don't name a variable after a function that already exists in the C libraries, such as alarm; the ESP32 compiler rejects it with a "redeclared as different kind of symbol" error, which is why the example uses alarmDurumu.
Wiring: DHT22 sensor and ESP32
| Component | Pin | ESP32 connection | Note |
|---|---|---|---|
| DHT22 | VCC (+) | 3V3 | Works at 3.3 V |
| DHT22 | DATA (OUT) | GPIO 4 | 10 kΩ pull-up between DATA and VCC on a bare sensor; built into modules |
| DHT22 | GND (-) | GND | Common ground |
| LED | Onboard | GPIO 2 | Onboard LED on most ESP32 boards; otherwise an external LED with 220 Ω |
Auto-generated code and the full sketch
Once you've added the variables and switch to the Sketch tab, Arduino Cloud has prepared three files for you. thingProperties.h contains the variable definitions, the initProperties() function and the Wi-Fi connection object; the platform rewrites this file every time you change a variable, so don't edit it by hand. arduino_secrets.h (the Secret tab in the cloud editor) holds the Wi-Fi password and the Secret Key. The main .ino file has setup(), loop() and an empty function such as onLedChange() for every Read & Write variable; that's where your code goes. You can upload from the cloud editor through the Arduino Cloud Agent, or download the sketch and open it in the Arduino IDE; in the IDE you only need to install the ArduinoIoTCloud library from the Library Manager, and dependencies such as Arduino_ConnectionHandler come with it. For the DHT22, also install Adafruit's DHT sensor library. The editor sometimes writes variables as addProperty(led, READWRITE, ON_CHANGE, onLedChange); this older form still works, but newer versions of the library flag it with a "deprecated" warning. The code below uses the newer form that does the same job (Permission::ReadWrite and onUpdate) and merges the three files into a single sketch so you can copy it and compile it directly.
1// Arduino Cloud + ESP32: DHT22 göstergeleri, LED anahtarı ve alarm eşiği
2// Arduino Cloud + ESP32: DHT22 gauges, LED switch and alarm threshold
3// Editörün ürettiği 3 dosya burada tek sketch'te birleştirildi
4// The 3 files generated by the editor are merged into one sketch here
5#include <ArduinoIoTCloud.h>
6#include <Arduino_ConnectionHandler.h>
7#include <DHT.h>
8
9// ---- arduino_secrets.h ----
10#define SECRET_SSID "WIFI_ADIN" // Wi-Fi adı / Wi-Fi name
11#define SECRET_OPTIONAL_PASS "WIFI_SIFREN" // Wi-Fi şifresi / Wi-Fi password
12#define SECRET_DEVICE_KEY "CIHAZ_GIZLI_ANAHTARI" // Secret Key (yalnız bir kez gösterilir / shown only once)
13
14// ---- thingProperties.h ----
15const char DEVICE_LOGIN_NAME[] = "CIHAZ_KIMLIGI"; // Device ID
16const char SSID[] = SECRET_SSID;
17const char PASS[] = SECRET_OPTIONAL_PASS;
18const char DEVICE_KEY[] = SECRET_DEVICE_KEY;
19
20void onLedChange();
21void onAlarmEsigiChange();
22
23float sicaklik; // Read Only, Gauge
24float nem; // Read Only, Gauge
25bool led; // Read & Write, Switch
26int alarmEsigi; // Read & Write, Slider (20-40)
27bool alarmDurumu; // Read Only, LED widget
28
29void initProperties() {
30 ArduinoCloud.setBoardId(DEVICE_LOGIN_NAME);
31 ArduinoCloud.setSecretDeviceKey(DEVICE_KEY);
32 ArduinoCloud.addProperty(sicaklik, Permission::Read).publishEvery(10 * SECONDS); // 10 sn'de bir / every 10 s
33 ArduinoCloud.addProperty(nem, Permission::Read).publishEvery(10 * SECONDS);
34 ArduinoCloud.addProperty(led, Permission::ReadWrite).onUpdate(onLedChange);
35 ArduinoCloud.addProperty(alarmEsigi, Permission::ReadWrite).onUpdate(onAlarmEsigiChange);
36 ArduinoCloud.addProperty(alarmDurumu, Permission::Read).publishOnChange(0); // değişince / on change
37}
38
39WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);
40
41// ---- ana sketch / main sketch ----
42const int LED_PIN = 2; // çoğu ESP32 kartında dahili LED / onboard LED on most ESP32 boards
43const int DHT_PIN = 4; // DHT22 veri pini / DHT22 data pin
44DHT dht(DHT_PIN, DHT22);
45unsigned long sonOlcum = 0;
46
47void setup() {
48 Serial.begin(115200);
49 delay(1500); // Seri Monitör'ü bekle / wait for the Serial Monitor
50 pinMode(LED_PIN, OUTPUT);
51 dht.begin();
52 alarmEsigi = 30; // ilk eşik, °C / initial threshold, °C
53
54 initProperties();
55 ArduinoCloud.begin(ArduinoIoTPreferredConnection);
56 setDebugMessageLevel(2); // bağlantı adımlarını yazdır / print connection steps
57 ArduinoCloud.printDebugInfo();
58}
59
60void loop() {
61 ArduinoCloud.update(); // buluta bağlı kal, değişkenleri eşitle / stay connected, sync variables
62
63 if (millis() - sonOlcum >= 2000) { // DHT22 en fazla 2 sn'de bir / DHT22 at most every 2 s
64 sonOlcum = millis();
65 float t = dht.readTemperature();
66 float h = dht.readHumidity();
67 if (!isnan(t) && !isnan(h)) {
68 sicaklik = t;
69 nem = h;
70 alarmDurumu = sicaklik >= alarmEsigi; // eşik aşıldı mı / threshold exceeded?
71 }
72 }
73}
74
75// Panelden anahtar değişince çalışır / runs when the switch changes on the dashboard
76void onLedChange() {
77 digitalWrite(LED_PIN, led ? HIGH : LOW);
78}
79
80// Kaydırıcı değişince çalışır / runs when the slider changes
81void onAlarmEsigiChange() {
82 alarmDurumu = sicaklik >= alarmEsigi;
83}
84| Code part | What it does |
|---|---|
| DEVICE_LOGIN_NAME, DEVICE_KEY | Device ID and Secret Key; prove the board's identity to the cloud |
| addProperty(sicaklik, Permission::Read).publishEvery(10 * SECONDS) | Sends the read-only variable every 10 seconds |
| addProperty(led, Permission::ReadWrite).onUpdate(onLedChange) | Calls onLedChange() when it changes on the dashboard |
| WiFiConnectionHandler | Sets up the Wi-Fi connection and reconnects by itself if it drops |
| ArduinoCloud.update() | Keeps the connection alive and syncs variables both ways; must run on every loop |
| setDebugMessageLevel(2) | Prints the connection steps to the Serial Monitor; raise it to 4 when troubleshooting |
| 2 s measurement with millis() | Reads the DHT22 at its limit without blocking the loop with delay() |
Dashboard and widgets
In the Dashboards section press + Dashboard, pick widgets from the ADD menu in edit mode and link each one to its variable with Link Variable. In the Gauge widget, set the minimum and maximum (0–50 for temperature, 0–100 for humidity); for the Slider, set the lower limit to 20 and the upper limit to 40. The dashboard can be arranged separately for desktop and phone views. With the board connected, the gauges update every 10 seconds; when you press the Switch the LED lights up almost instantly, and when you drag the slider below room temperature the alarm LED turns red.
| Widget | Linked variable type | In this project | Note |
|---|---|---|---|
| Gauge | int, float (Read Only) | sicaklik, nem | Half-circle gauge with adjustable min and max |
| Switch | bool (Read & Write) | led | To turn a relay or LED on and off |
| Slider | int, float (Read & Write) | alarmEsigi | Threshold, speed or brightness setting |
| LED | bool (Read Only) | alarmDurumu | Status indicator; colour can be chosen |
| Value | Any type | Not used | Shows the number or text as it is |
| Chart | int, float | Not used | Time chart; last 1 day on the free plan |
| Push Button | bool (Read & Write) | Not used | true for as long as it's held down |
| Messenger | String | Not used | Text messaging between the board and the dashboard |
Phone app: Arduino IoT Remote
Install the free Arduino IoT Remote app for iOS or Android and log in with the same account: the dashboards you've built appear on your phone ready to use, with no separate phone interface to design. The app also has a "use your phone as a device" feature that sends the phone's own sensors (accelerometer, GPS, light) to Arduino Cloud. This feature creates a new Thing and uses one of your 2 free Things; if you turn it on for both a phone and a tablet, both slots can fill up. Arduino Cloud can also talk to Amazon Alexa and Google Home: variables of special types such as CloudSwitch or CloudTemperatureSensor appear as devices in the voice assistant. For other ways of connecting an ESP32 to a voice assistant, see the ESP32 Alexa and Google Home article.
Arduino Cloud vs Blynk vs ESP RainMaker
| Feature | Arduino Cloud | Blynk | ESP RainMaker |
|---|---|---|---|
| Free plan | 2 Things, 5 variables per Thing, 1 day of data | 5 devices, 100,000 messages a month, 1 week of data | Free for personal use |
| Supported boards | Arduino boards, ESP32, ESP8266 and others | ESP32, ESP8266, Arduino, Pico W and others | Espressif chips only (ESP32, S2, S3, C3, C6) |
| Dashboard | Drag-and-drop widgets on the web, IoT Remote on the phone | Widget templates on web and mobile | The app builds a ready-made UI from the device type |
| Code structure | Auto-generated sketch, variable sync | Virtual pins (V0, V1) and virtualWrite | RMaker library, device and parameter objects |
| Wi-Fi setup | Credentials written in the code | In the code or from the app with Edgent | From the phone app with a QR code (BLE or SoftAP) |
| Voice assistant | Alexa and Google Home | Not built in | Alexa and Google Assistant |
| Best for | The Arduino ecosystem, fast dashboards, education | Phone-centred control, wide board support | Product-like ESP32 smart home devices |
In short: if you use the Arduino ecosystem and want a nice dashboard quickly, go for Arduino Cloud; if you want to connect more devices for free and design a custom interface in the phone app, Blynk; if you only use the ESP32 and want a product-like device set up from the phone with a QR code and working with voice assistants, ESP RainMaker is the better fit. If you want to keep data for a long time and study it with charts and analysis, look at the ESP32 ThingSpeak method; if you want a system that runs at home without depending on any cloud, see the Home Assistant ESP32 projects.
Arduino IoT Cloud project ideas
- Smart plug or relay panel: switch a lamp from your phone with the Switch widget and run it automatically at set times with the Scheduler widget (ESP32 smart plug).
- Plant watering station: watch soil moisture on a Gauge and run the pump by hand with a Push Button or automatically with a threshold slider (ESP32 automatic plant watering).
- Greenhouse or incubator monitor: get an email or phone notification through a Trigger when the temperature threshold is exceeded.
- Location tracking: show the coordinates from a GPS module on a map with a CloudLocation variable and the Map widget.
- Door and motion alarm: light the LED widget and send a notification when a PIR sensor is triggered.
Common mistakes and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Device always Offline on the dashboard | Wrong Device ID or Secret Key, or a 5 GHz network | Check the keys, use a 2.4 GHz network; if needed, delete and re-add the device |
| ArduinoIoTCloud.h not found error | Library not installed | Install ArduinoIoTCloud with its dependencies from the Library Manager |
| Can't add a new variable | Free plan limit of 5 variables per Thing | Delete an unneeded variable or use the second Thing |
| Dashboard values update late | Long delay() in loop() or a long period | Use millis() instead of delay(), shorten the period |
| Upload from the browser fails | Arduino Cloud Agent not installed or not running | Install and start the Agent, or upload the code with the Arduino IDE |
| redeclared as different kind of symbol | Variable name matches a C function (e.g. alarm, time) | Rename the variable (e.g. alarmDurumu) |
| Thing slots filled up unexpectedly | The phone was added as a device in IoT Remote | Delete the Thing created by the phone |
An easier way: BlueGrays IoT
Arduino IoT Cloud is a flexible, powerful platform with widgets like Trigger, Scheduler and Map. But if all you want is to switch a relay from your phone or watch a sensor, you don't have to create a Thing, define cloud variables, copy the Device ID and Secret Key and build the dashboard widget by widget. In the BlueGrays app, go to Workshop › My devices › Add new device and pick a ready template such as relay lamp, temperature and humidity, or soil moisture + pump. Ohmi prepares the code with your device key, you upload it once from the Arduino IDE with the BlueGraysIoT library, and the switches, live values and charts appear on your phone. It works with the ESP32 and Raspberry Pi Pico W, needs 2.4 GHz Wi-Fi, and your first device is free; see the guide to controlling an ESP32 from your phone for details.
If you'd like to test the ESP32's Wi-Fi connection, the DHT22 reading and LED control separately before moving to Arduino Cloud, the BlueGrays app has the ESP32 LED, button LED control, DHT22 temperature and humidity, and Wi-Fi STA connection projects with step-by-step circuit diagrams and code; once those pieces work, connecting to the cloud takes only a few minutes.
Frequently asked questions
Is Arduino IoT Cloud free?
Yes, there's a free plan for personal use. It gives you 2 Things, 5 variables per Thing and 1 day of data retention, and you can compile 25 times a day in the cloud editor. For more devices, longer history and over-the-air updates you need the paid Maker plan.
Does the ESP32 work with Arduino IoT Cloud?
Yes. The ESP32 is added as a third-party device in the Devices section and connects to the cloud with a Device ID and a Secret Key. ESP8266 boards are supported the same way. For the code you only need the ArduinoIoTCloud library and the ESP32 board package.
Are Arduino IoT Cloud and Arduino Cloud the same thing?
Yes. In 2023 Arduino brought IoT Cloud, the Web Editor and its other services under one roof and renamed it Arduino Cloud. The concepts of Things, variables and dashboards stayed the same, so guides written under the old name are still largely valid.
What if I lose the Arduino Cloud Secret Key?
The Secret Key is shown only once, when you add the device, and can't be viewed later. If you've lost it, delete the device in the Devices section, add it again and put the new key into the Thing's network settings and your code. You don't need to delete the Thing or the dashboard; you just pair the device again.
Is Arduino Cloud better than Blynk?
If you use the Arduino ecosystem and want the code generated for you, Arduino Cloud is more practical. Blynk offers more devices and longer data history on its free plan and is more flexible for designing a phone interface. The choice depends on how many devices you have and how long you want to keep your data.
Does Arduino Cloud work without the internet?
No. All communication between the board and the dashboard goes through Arduino's servers, so both the board and the phone must be online. If the internet goes down the board keeps running but can't be controlled from the dashboard; for a system that runs locally, Home Assistant or ESPHome is a better fit.
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 LED Control with Push Button (Push)
The LED lights up when the button is pressed and turns off when released. Shows how the ESP32's digital input pin and internal pull-up resistor are used. The INPUT_PULLUP mode eliminates the need for an external resistor.

ESP32 LED Control with Pushbutton (Toggle)
Each time the button is pressed the state of the LED changes: if it is on it turns off, if it is off it turns on. Classic toggle pattern. With debounce we clean up the mechanical noise of the pushbutton to ensure a single toggle with a single press.

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.

Automatic Lighting with the ESP32 PIR Motion Sensor
In this project an HC-SR501 PIR motion sensor detects someone entering the room and turns on an LED automatically. millis() tracks how long the LED stays on: each HIGH reading refreshes the last-motion time, and the LED turns off at least 10 seconds after the last HIGH. The code also waits 50 ms with delay(50) in every loop, so the loop is not fully non-blocking. Great for stairs, hallways, bathrooms or closet lighting.

ESP32 Smart Lighting (PIR + LDR + Relay + OLED)
With an ESP32, a PIR motion sensor, an LDR light sensor and a relay module, we turn your hallway, bathroom or pantry into smart lighting. If the room is already bright, the light stays off even when there is motion, so it never wastes energy during the day. The light stays on for 30 seconds, and the time extends automatically while motion continues.
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

