Guides · 10 min read

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.

ESP32 development board connecting to Arduino IoT Cloud
The ESP32 connects to Arduino Cloud as a third-party device using a Device ID and a Secret Key; no extra module is needed.

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.

ConceptWhat it doesExample in this guide
DeviceIdentifies the real board, issues an ID and a keyESP32 Dev Module, name: salon-esp32
ThingThe board's twin in the cloud: variables, network settings, paired deviceLiving Room Station
VariableA value synced between the board and the cloudsicaklik, nem, led, alarmEsigi, alarmDurumu
DashboardA screen of widgets linked to variablesTwo gauges, a switch, a slider, an LED
SketchThe code generated by the platform and completed by youMain .ino, thingProperties.h, arduino_secrets.h
IoT RemoteApp that opens dashboards on your phoneiOS 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.

LimitFree planWhat it means in practice
Things2Two separate boards or projects
Variables5 per ThingThe project in this guide uses the full limit
Data retention1 dayCharts show only the last 24 hours
Compilations in the cloud editor25 per dayIf you compile locally in the Arduino IDE this limit doesn't apply
Notifications (triggers)100 per dayAlarm emails and app notifications
Over-the-air updates (OTA)Paid plansOn the free plan code is uploaded over USB
Users1Dashboard sharing and team features are on paid plans

Step by step: adding the ESP32 as a device

  1. Create a free Arduino account at cloud.arduino.cc and open Arduino Cloud.
  2. 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.
  3. Go to Devices in the left menu and press the + Device button.
  4. In the window that opens, choose Third party device, then ESP32, and ESP32 Dev Module as the board model.
  5. Give the device a name such as salon-esp32; the Device ID and Secret Key appear on screen.
  6. Copy both values or download them as a PDF, then tick the checkbox and finish the setup.
The Secret Key is shown only once, on this screen, and can't be viewed later. If you lose it, you have to delete the device and add it again. Don't share the key along with your code on a forum or GitHub; anyone who knows it can connect their own board as your device and change the values on your dashboard.

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.

VariableTypePermissionUpdateWidget to link
sicaklikFloating Point NumberRead OnlyPeriodic, 10 sGauge
nemFloating Point NumberRead OnlyPeriodic, 10 sGauge
ledBooleanRead & WriteOn changeSwitch
alarmEsigiInteger NumberRead & WriteOn changeSlider (20–40)
alarmDurumuBooleanRead OnlyOn changeLED

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

ComponentPinESP32 connectionNote
DHT22VCC (+)3V3Works at 3.3 V
DHT22DATA (OUT)GPIO 410 kΩ pull-up between DATA and VCC on a bare sensor; built into modules
DHT22GND (-)GNDCommon ground
LEDOnboardGPIO 2Onboard 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.

C++ (Arduino IDE)
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 partWhat it does
DEVICE_LOGIN_NAME, DEVICE_KEYDevice 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
WiFiConnectionHandlerSets 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()
Don't use long delay() calls inside loop(). If ArduinoCloud.update() doesn't run regularly, the connection drops, the device shows as offline on the dashboard and switch commands arrive late. Always do your timing with millis(). When the board starts, it's normal for 10–30 seconds to pass before you see the Connected to Arduino IoT Cloud line in the Serial Monitor.

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.

WidgetLinked variable typeIn this projectNote
Gaugeint, float (Read Only)sicaklik, nemHalf-circle gauge with adjustable min and max
Switchbool (Read & Write)ledTo turn a relay or LED on and off
Sliderint, float (Read & Write)alarmEsigiThreshold, speed or brightness setting
LEDbool (Read Only)alarmDurumuStatus indicator; colour can be chosen
ValueAny typeNot usedShows the number or text as it is
Chartint, floatNot usedTime chart; last 1 day on the free plan
Push Buttonbool (Read & Write)Not usedtrue for as long as it's held down
MessengerStringNot usedText 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

FeatureArduino CloudBlynkESP RainMaker
Free plan2 Things, 5 variables per Thing, 1 day of data5 devices, 100,000 messages a month, 1 week of dataFree for personal use
Supported boardsArduino boards, ESP32, ESP8266 and othersESP32, ESP8266, Arduino, Pico W and othersEspressif chips only (ESP32, S2, S3, C3, C6)
DashboardDrag-and-drop widgets on the web, IoT Remote on the phoneWidget templates on web and mobileThe app builds a ready-made UI from the device type
Code structureAuto-generated sketch, variable syncVirtual pins (V0, V1) and virtualWriteRMaker library, device and parameter objects
Wi-Fi setupCredentials written in the codeIn the code or from the app with EdgentFrom the phone app with a QR code (BLE or SoftAP)
Voice assistantAlexa and Google HomeNot built inAlexa and Google Assistant
Best forThe Arduino ecosystem, fast dashboards, educationPhone-centred control, wide board supportProduct-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

SymptomLikely causeFix
Device always Offline on the dashboardWrong Device ID or Secret Key, or a 5 GHz networkCheck the keys, use a 2.4 GHz network; if needed, delete and re-add the device
ArduinoIoTCloud.h not found errorLibrary not installedInstall ArduinoIoTCloud with its dependencies from the Library Manager
Can't add a new variableFree plan limit of 5 variables per ThingDelete an unneeded variable or use the second Thing
Dashboard values update lateLong delay() in loop() or a long periodUse millis() instead of delay(), shorten the period
Upload from the browser failsArduino Cloud Agent not installed or not runningInstall and start the Agent, or upload the code with the Arduino IDE
redeclared as different kind of symbolVariable name matches a C function (e.g. alarm, time)Rename the variable (e.g. alarmDurumu)
Thing slots filled up unexpectedlyThe phone was added as a device in IoT RemoteDelete the Thing created by the phone
For connection problems, first set setDebugMessageLevel(4) and watch the Serial Monitor at 115200 baud. If it can't join Wi-Fi, the problem is the network (see the ESP32 won't connect to Wi-Fi article); if Wi-Fi connects but the cloud doesn't, the problem is the Device ID or the Secret Key. If the sensor returns NaN, follow the steps in the DHT sensor not reading guide.

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.

See all projects
LED Blink with ESP32
ES-1Beginner

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.

4.7(38)
114
ESP32 LED Control with Push Button (Push)
ES-2Beginner

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.

4.6(36)
57
ESP32 LED Control with Pushbutton (Toggle)
ES-3Beginner

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.

4.6(39)
61
ESP32 DHT22 Temperature and Humidity (with LCD Display)
ES-15Intermediate

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.

4.8(38)
57
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
Automatic Lighting with the ESP32 PIR Motion Sensor
ES-19Intermediate
Premium

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.

4.4(25)
38
ESP32 Smart Lighting (PIR + LDR + Relay + OLED)
ES-37Advanced
Premium

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.

4.3(6)
11