Learning Goals 5 min
Cluster B's capstone: a wall-mounted live IoT dashboard for your room. Temperature, humidity, light, with historical charts and phone-app access. The polished combination of everything in L04-07..11. By the end of this lesson you will be able to:
- Wire 3 sensors (DHT11 for temp + humidity, LDR for light) to a Cloud-capable board.
- Define a Thing with at least 4 Properties (temperatureC, humidityPct, lightPct, uptime).
- Build a polished dashboard with gauges, charts, and at-a-glance value cards — ready to share publicly or via per-user invite.
Warm-Up 10 min
Hardware:
- Supported Cloud board (Nano ESP32, MKR WiFi 1010, UNO R4 WiFi).
- DHT11 (cheap, ±5% RH, ±2 °C). Or DHT22 / BME280 for higher precision.
- LDR voltage divider on A0.
- 10 kΩ resistor for the LDR divider.
- USB power supply for permanent install.
- (Optional) An OLED on I²C for local display in addition to the cloud.
Install libraries
If using DHT11 / DHT22: Library Manager → "DHT sensor library" (Adafruit). For DHT22 you may also want "Adafruit Unified Sensor".
New Concept · The polished IoT product 20 min
Architecture review
- Sensor reads happen at a slow rate (every 10–30 s — DHT11 is slow).
- Property assignments push to the cloud automatically.
- Dashboard shows current value (Gauge) + 24h history (Chart).
- Phone app reads the same dashboard remotely.
- Optional local OLED + LED for "at home, no internet" reliability.
Properties
| Property | Type | Update | Purpose |
|---|---|---|---|
| temperatureC | Temperature (float) | On Change | Room temp |
| humidityPct | RelativeHumidity (float) | On Change | Room humidity |
| lightPct | Percentage (float) | On Change | Brightness 0–100 |
| tempAlarmThreshold | Temperature (float) | READWRITE | Configurable hot-room alert |
| uptime | int | Periodically (60s) | Device alive indicator |
Dashboard layout
- Three big Gauges side-by-side: Temp, Humidity, Light.
- One Chart underneath spanning full width — Temperature over 24h.
- One Chart — Humidity over 24h.
- One Slider for tempAlarmThreshold (with the current threshold visible).
- One Value at the bottom-right — uptime.
Worked Example · The full build 30 min
Step 1 — wire
| Component | Pin |
|---|---|
| DHT11 data | D2 |
| DHT11 VCC, GND | 3V3, GND |
| LDR voltage divider (LDR + 10 kΩ to GND) | Midpoint → A0; LDR top → 3V3 |
Step 2 — create the Thing
Name: RoomMonitor. Attach device. Add the 5 properties from §3.
Step 3 — the sketch
#include "thingProperties.h"
#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
const int LDR_PIN = A0;
const int LDR_DARK = 100;
const int LDR_BRIGHT = 900;
unsigned long lastSensorAt = 0;
const unsigned long SENSOR_PERIOD_MS = 15000;
void setup() {
Serial.begin(9600);
delay(1500);
initProperties();
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
setDebugMessageLevel(2);
dht.begin();
tempAlarmThreshold = 28.0; // default
}
void loop() {
ArduinoCloud.update();
unsigned long now = millis();
if (now - lastSensorAt >= SENSOR_PERIOD_MS) {
lastSensorAt = now;
float t = dht.readTemperature();
float h = dht.readHumidity();
if (!isnan(t)) temperatureC = t;
if (!isnan(h)) humidityPct = h;
int raw = analogRead(LDR_PIN);
raw = constrain(raw, LDR_DARK, LDR_BRIGHT);
lightPct = map(raw, LDR_DARK, LDR_BRIGHT, 0, 100);
uptime = now / 1000;
Serial.print("t="); Serial.print(temperatureC);
Serial.print(" h="); Serial.print(humidityPct);
Serial.print(" l="); Serial.println(lightPct);
// Local action on alarm
if (temperatureC > tempAlarmThreshold) {
Serial.println("HOT");
// Could also trigger a webhook here (L03-36 pattern).
}
}
}
void onTempAlarmThresholdChange() {
Serial.print("Threshold changed to ");
Serial.println(tempAlarmThreshold);
}Step 4 — dashboard build
Three Gauges + two Charts + Slider + Value, arranged as in §3. Save.
Step 5 — open the phone app
Arduino IoT Remote → RoomMonitor dashboard. Walk around the house. The values track the actual room temperature / humidity / light. Cover the LDR — lightPct drops. Breathe on the DHT11 (or use a hair dryer carefully) — temp + humidity react.
Step 6 — share publicly
Generate a read-only public link. This is your "live room monitor" URL. Bookmark on phone home screen.
Step 7 — leave it running for a day
USB-powered, on a shelf, plugged in. Come back later — the charts have a day's worth of data. Note overnight cooling, daytime warmth, the brightness spike when you turn on lights.
Try It Yourself 15 min
Goal: Change the sensor period to 5 s. Confirm the chart fills up faster. Note: keep at least 1 s between DHT11 reads.
Goal: Add a BME280 (more accurate, supports barometric pressure) in place of the DHT11. Use the Adafruit_BME280 library. Add a fourth property: pressureHpa.
Goal: Send an IFTTT alert (L03-37 pattern) when temperatureC crosses tempAlarmThreshold. The IoT Cloud doesn't do IFTTT directly — wire it in your sketch's sensor block.
Hint
Track bool wasAlarm. When alarm transitions to active (and wasn't before), call the IFTTT POST helper from L03-36. Don't spam: same once-per-event suppression as L03-38.
Mini-Challenge · Ship the monitor 10 min
- Mount the device in a tidy enclosure with sensors poking through.
- Set up a wall-mounted tablet showing the dashboard in kiosk mode.
- Hand the phone-app link to a family member; ask them to add the dashboard to their home screen.
- Take photos / video of the finished build + the live dashboard.
Ship-ready test:
- Can a non-coder add the public link to their phone's home screen and check the temperature?
- Does the chart show a sensible 24h trend without missing chunks?
- Is the device still alive after 24 hours of continuous operation?
Cluster B done. Cluster C (MQTT + Home Integration) starts in L04-13.
Recap 5 min
IoT Room Monitor combines Cluster B's ideas into a polished product: 3 sensors, 5 properties, gauges + charts + slider, public link + phone app. Code is ~50 lines; the cloud infrastructure carries everything else. This is the IoT pattern that scales — measure, push, visualise, alert. Tomorrow: a heavier-duty cousin called MQTT, which is what every "real" smart-home device uses under the hood.
- DHT11 / DHT22
- Cheap combined temperature + humidity sensors. DHT11 = ±2 °C, ±5% RH. DHT22 = ±0.5 °C, ±2% RH.
- Sensor period
- How often you read the sensor. Slow sensors (DHT, BME) have minimum periods.
- Calibration constants
- Measured values (LDR_DARK, LDR_BRIGHT) used in
map()to convert raw ADC readings to friendly units. - Threshold property (READWRITE)
- A configurable value (alarm threshold) that the user changes from the dashboard. Survives reboot if persisted; otherwise resets to a default on each boot.
- Kiosk mode
- Wall-mounted tablet showing dashboard fullscreen. Use a public read-only link.
- Once-per-event suppression
- Fire alert once on threshold crossing; don't fire again until recovery. From L03-36.
Homework 5 min
- Install the IoT Room Monitor. Run for at least 24 hours. Screenshot the 24h chart.
- Share the public link with two people. Ask them to add it to their phone home screen.
- Read ahead to ARD-L04-13 (MQTT Concepts). Cluster C starts.