Learning Goals 5 min
End-to-end: register a board as a Device, create a Thing, add two Properties (one read-only sensor, one read-write toggle), upload the auto-generated sketch, and watch the values update in real time. By the end of this lesson you will:
- Register a supported board (UNO R4 WiFi, MKR WiFi 1010, Nano 33 IoT, Nano ESP32) as an Arduino Cloud Device.
- Create a Thing, attach the device, and add two Properties.
- Upload the auto-generated sketch and confirm the sensor reading appears in the Property's value field within seconds.
Warm-Up 10 min
Have ready:
- A supported board (see L04-07 list). For this lesson we'll assume Nano ESP32.
- USB cable.
- A potentiometer on A0 (the "sensor") and an LED on D2 with a 220 Ω resistor (the "actuator").
- WiFi credentials for the network the board will use.
- Arduino account, signed into
create.arduino.cc.
Mental map of the steps
- Register the device — give the cloud an ID for this specific board.
- Create a Thing — name + add Properties.
- Configure network — enter WiFi SSID + password (stored as secrets).
- Auto-generate sketch — IoT Cloud writes thingProperties.h for you.
- Upload — via the web IDE or your local IDE.
- Watch the Property update.
New Concept · Walkthrough 25 min
Step 1 — Devices tab
In IoT Cloud → Devices → Add Device. Pick "Arduino board" (vs "Third-party device", which is for ESP8266 / non-Arduino ESP32). The wizard auto-detects boards plugged in via USB.
Pick your board model. The wizard installs the Arduino Cloud Agent (a small helper app), assigns a unique Device ID and a secret Device Key. Save these somewhere safe — the key is shown ONCE and never again.
Step 2 — Things tab
Things → Create Thing. Name it (e.g. "DeskMonitor"). Attach the Device you just registered.
Step 3 — Add Properties
- potValue: integer, READ permission, On Change update policy.
- ledOn: boolean, READWRITE permission, On Change.
Each Property has:
- Variable name (becomes a C++ variable in the sketch).
- Type (int, bool, float, String, or a domain type like Temperature).
- Permission: READ (sketch → cloud), WRITE (cloud → sketch), READWRITE (bidirectional).
- Update policy: On Change (push when value differs) or Periodically (push every N seconds).
Step 4 — Network
Click the Network field. Enter SSID + password. These become SECRET_SSID and SECRET_OPTIONAL_PASS — stored encrypted on the cloud side and injected into the sketch at upload time. Never visible in plain text in your codebase.
Step 5 — Sketch
The Sketch tab shows the auto-generated .ino. You can edit it in the browser or download it.
#include "thingProperties.h"
void setup() {
Serial.begin(9600);
delay(1500);
initProperties();
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
pinMode(2, OUTPUT);
}
void loop() {
ArduinoCloud.update();
potValue = analogRead(A0);
}
void onLedOnChange() {
digitalWrite(2, ledOn ? HIGH : LOW);
Serial.print("LED -> ");
Serial.println(ledOn ? "ON" : "OFF");
}Step 6 — Upload
From the web IDE: click Upload. Watch the build log + the board's status (Devices tab shows "online" / "offline").
From your local IDE: download the sketch + thingProperties.h, open as a normal Arduino project. The libraries (ArduinoIoTCloud + Arduino_ConnectionHandler) must be installed locally; auto-installed if you compile from the web IDE.
Step 7 — Watch the Property
In the Thing's Properties tab: potValue should update every second or so as you turn the pot. ledOn has a switch you can toggle; the LED on D2 should respond within ~1 s.
Worked Example · DeskMonitor in 15 minutes 25 min
Follow the §3 steps live. Verify everything works.
If it didn't work
| Symptom | Likely cause |
|---|---|
| Board not detected by wizard | Cloud Agent not running, or wrong USB driver. Reinstall Cloud Agent. |
| Upload starts but stalls | Web IDE compile timeout. Switch to local IDE for now. |
| Sketch uploaded but Property never updates | Either WiFi failed to connect (check serial monitor for "Connecting" loop) or ArduinoCloud.update() isn't being called. |
| LED doesn't respond to dashboard toggle | Callback function name doesn't match on<PropertyName>Change — check spelling. |
Add a third Property
Now add uptime (int, READ, Periodically every 10 s). Update in loop():
uptime = millis() / 1000;The IoT Cloud handles the periodic publishing — you don't need a millis() timer.
Watch the serial monitor
The Cloud library is chatty when setDebugMessageLevel(2) is set. You'll see:
Connecting to "your-wifi" Connected to WiFi Connecting to Arduino IoT Cloud Connected to Arduino IoT Cloud *** Tx properties (~1 s) *** *** Rx properties ***
If you see "Connecting" forever, the WiFi credentials are wrong or the network is unreachable.
Try It Yourself 15 min
Goal: Add a String property called status. In loop(), set it to "HIGH" if potValue > 512 else "LOW". Watch it update in the cloud.
Goal: Add a Temperature property (float-derived). Wire a TMP36 (or any temperature sensor). Read it; assign to the property. The cloud will display it with °C units.
Goal: Add a CloudColor property bound to an RGB LED. The dashboard's colour-picker widget should set the LED's colour live.
Hint
void onColorChange() {
uint8_t r, g, b;
color.getValue().getRGB(r, g, b);
analogWrite(R_PIN, r);
analogWrite(G_PIN, g);
analogWrite(B_PIN, b);
}Mini-Challenge · Document your Thing 10 min
- Open the Things tab → click your Thing → Properties view.
- Take a screenshot.
- Paste into a notebook page (digital or paper) and label each Property: name, type, permission, what it physically does.
- Tomorrow we build dashboards around these properties.
Recap 5 min
Setting up a Thing is: register device → create Thing → add properties → set WiFi → upload generated sketch. The hidden thingProperties.h file holds all the boilerplate (WiFi, device key, MQTT). Your .ino stays tiny — just sensor reads and callback bodies. Tomorrow we visualise the properties with dashboard widgets.
- Cloud Agent
- Small helper app on your computer that lets the web IDE upload to USB-connected boards.
- Device ID / Device Key
- Unique per-device credentials used to authenticate the board to the cloud. The Key is shown once at registration.
- Update policy
- How / when a property pushes. "On Change" = whenever value differs. "Periodically" = every N seconds regardless.
- Permission
- READ = device pushes only. WRITE = cloud pushes only. READWRITE = both directions.
- Callback (on<Name>Change)
- Function called when a READWRITE property is updated from the cloud. Name must match the property:
onLedOnChange()forledOn. - Secret
- Sensitive value (WiFi password, API key) stored in the cloud's secrets manager, never visible in shared sketches.
- thingProperties.h
- Auto-generated header with property declarations, WiFi setup, and the initProperties() function.
Homework 5 min
- Get DeskMonitor working end-to-end. Screenshot the Properties view with values updating.
- Read ahead to ARD-L04-09 (Cloud Dashboards). Tomorrow we add widgets.