What a module is
Up to now you’ve only had fake data — the test publisher script. A module is a real, packaged classroom project: hardware + code + a lesson plan + a place on the dashboard. The platform is designed to host many of them; this is the first.
The Classroom Sensor Hub module includes:
Phase 7 also adds one new platform feature: snapshots. Tap a button on the Sensors page and the platform freezes the current state of every sensor into a row in the database. Useful for “before” / “during” / “after” comparisons during a lesson.
The Micro:bit is great for Year 7 — it’s familiar, easy, and has a built-in temperature sensor. It connects via USB so your teacher just needs the cable.
The ESP32 is a bigger jump but more grown-up: it has Wi-Fi, so each pair can run their own board independently across the room. We provide both so the lesson can scale up later.
Pull and rebuild
The platform code has new bits: a snapshots table, an API to capture them, a button on the Sensors page, and the module folder.
cd /opt/iot-platform
git pull
docker compose build api frontend
docker compose up -d
Watch the API logs:
docker compose logs -f api
You should see Alembic apply the new migration:
INFO alembic.runtime.migration Running upgrade 0001 -> 0002, snapshots
See the module tile
Open the dashboard. Click the ▦ Modules icon in the sidebar.
The Classroom Sensor Hub tile should no longer be greyed out. It now has a green LIVE badge instead of Phase 7. Tap it — you’ll be taken back to the Sensors page (because the module’s data lives there).
Also notice on the Sensors page: when you have at least one sensor reading, a Take snapshot button appears in the top-right.
Pick your hardware
Pick the path that matches your kit:
Don’t do both at the same time on your first try — pick one, get it working, then come back for the other if you have time.
Year 7s usually start with Path A (Micro:bit). Year 8–9s with Path B (ESP32). They’ll tell the class which kit you’re using today.
Path A: Micro:bit
The Micro:bit prints sensor readings over USB. The Pi listens on that USB and forwards each one as MQTT.
4a. Flash the program
- Plug the Micro:bit into the laptop with the USB cable. A new drive called MICROBIT appears.
- Open Mu Editor. Set Mode to “BBC micro:bit”.
- Open
modules/classroom-sensor-hub/microbit/main.pyfrom the platform repo. - Change
DEVICE_IDat the top to a unique name, likemicrobit-03for pair 3. - Click Flash. The yellow LED on the back flickers; a heart briefly appears on the front. Done.
4b. Plug into the Pi and run the bridge
Move the Micro:bit’s USB cable from the laptop to the Pi. The Pi will recognise it as /dev/ttyACM0. Then on the Pi:
pip install pyserial paho-mqtt
cd /opt/iot-platform/modules/classroom-sensor-hub/microbit
export MQTT_PASSWORD="<your MQTT password from .env>"
python3 serial-bridge.py /dev/ttyACM0
You should see lines tick by:
→ opening serial /dev/ttyACM0 @ 115200
→ connecting to MQTT 127.0.0.1:1883 as platform
✓ bridge running. Ctrl-C to stop.
→ classroom/sensor/microbit-03/temperature: 23 celsius
→ classroom/sensor/microbit-03/light: 145 lux
4c. Watch the dashboard
Switch to the dashboard. Within a second you’ll see two new cards: microbit-03 / temperature and microbit-03 / light. Cover the Micro:bit with your hand — the light value should drop sharply.
The Micro:bit’s “temperature sensor” is actually reading the chip itself, which runs hot. You’ll see numbers like 25–30 °C in a 20 °C room. That’s a teaching moment: real-world sensors have quirks — the data isn’t lying, it just isn’t measuring what you expect.
Tap the temperature card. The chart updates in real time. Tap Explain this reading — Claude will write a sensible-sounding explanation. (Claude doesn’t know about the chip-warmth quirk; it might claim the room is warm. Discuss this in class!)
Path B: ESP32
An ESP32 has Wi-Fi built in. It connects directly to the platform’s MQTT broker over the school network — no Pi-side bridge.
5a. Wire the DHT22
Three jumper wires:
DHT22 pin ESP32 pin
--------- ---------
VCC -> 3V3
DATA -> GPIO 4
GND -> GND
5b. Flash the sketch
- Open the Arduino IDE.
- If you don’t have ESP32 board support yet, follow the README in
modules/classroom-sensor-hub/esp32/— it’s a one-time install. - Open
modules/classroom-sensor-hub/esp32/sensor-hub.ino. - Edit the configuration block at the top:
WIFI_SSID,WIFI_PASS— school Wi-Fi.MQTT_HOST— your Pi’s hostname (e.g.pi-iot-01.local).MQTT_PASS— the MQTT password from.env.DEVICE_ID— unique per board.
- Plug the ESP32 in. Tools → Board → ESP32 Dev Module; Tools → Port → the new device.
- Click Upload.
- Open Tools → Serial Monitor (115200 baud) and watch it boot.
5c. Watch the dashboard
Once the serial monitor shows MQTT: connecting… ok, two new cards appear on the dashboard: esp32-XX / temperature and esp32-XX / humidity. Breathe near the DHT22 — the humidity should jump.
The most common causes: wrong password (re-check .env on the Pi), school Wi-Fi blocking port 1883 (try a phone hotspot), or the ESP32 can’t resolve .local (use the Pi’s IP address instead).
Snapshots through the lesson
Once the room has at least one sensor publishing, take three snapshots through the lesson:
- Start of class — before anyone’s warmed the room up.
- Middle — mid-experiment.
- End — after the lesson’s activity.
Each tap of Take snapshot writes a row to the snapshots table with every sensor’s current value. You’ll see a confirmation like “Saved snapshot #1 (4 sensors)” appear next to the button.
To browse them, go to Settings → Recent snapshots. They’re listed newest first with their ID, label, timestamp, and sensor count.
You can also pull a specific snapshot via the API:
curl -s http://pi-iot-XX.local/api/snapshots/1 | python3 -m json.tool
You’ll get the full set of readings as they were at that moment — perfect for class discussion or a science write-up.
Real scientists save their measurements with timestamps so they can prove what they did. Snapshots are exactly that. Phase 4’s database stores every individual reading; snapshots are just marker pins that say “the room looked like this at this moment”.
Final verification
The class should be able to do everything below. Tick each one before declaring Phase 7 (and the whole course!) done.