Connect a sensor reading to an edge dashboard
Run a supplied producer, HTTP receiver, and dashboard; test disconnects and download the readings.
Opening the Python editor…
Requirements and learning goals
Before you start
- Python 3.11 or newer on your computer; no sensor required
- Optional deployment: Wendy CLI, Docker, and a prepared Linux Wendy target
You will be able to
- Run a complete measurement-to-dashboard path
- Detect missing updates, reject duplicate samples, and save accepted records
An edge dashboard needs to distinguish current readings from a disconnected sensor's last value. This project includes the producer, receiver, and display. Start locally with simulated temperature, then optionally deploy the same receiver to a device.
Start the complete example
Download the sensor dashboard and unzip it. No Python packages are required. In a terminal:
cd sensor-dashboard
python3 server.pyOpen http://127.0.0.1:8080. In another terminal, enter the same directory and run:
python3 send.pyThe sender posts to /samples every half-second. The browser polls /status; accepted records append to data/samples.jsonl.
Understand the record
{"source":"bench-1","session":"boot-1","sequence":42,"value":23.5,"unit":"degC","capture_ms":12500,"clock":"source-boot","valid":true}This uses the team-and-tooling lesson's degC unit. session identifies a producer restart; sequence increases within it. capture_ms is milliseconds since that producer started, standing in for a sensor's boot clock. Each sender run creates a new session automatically.
The receiver adds its own receipt timestamp. It never subtracts the source's clock from the receiver's clock. LIVE means recent receipt of a valid sample; it does not prove low transport delay.
Check the expected results
Expect changing temperatures near 23 degC and LIVE. Stop only the sender with Ctrl+C. After three seconds, expect STALE while the previous value remains visible. Restart the sender: expect LIVE and a new sequence beginning at zero.
Send an explicit fault from another terminal:
curl --fail http://127.0.0.1:8080/samples \
-H 'Content-Type: application/json' \
-d '{"source":"fault-test","session":"boot-1","sequence":0,"value":null,"unit":"degC","capture_ms":0,"clock":"source-boot","valid":false}'Expect FAULT for fault-test, then STALE if it sends nothing else. Repeat the identical request: expect HTTP 409 because the sequence is a duplicate. Download accepted samples using the dashboard link. Rejected requests should not appear in that file.
Optional: deploy to an edge device
Stop the local receiver with Ctrl+C. From the downloaded directory:
wendy run --build-type dockerSelect your prepared Linux target. Open http://DEVICE_ADDRESS:8080 using its reachable LAN address. On your computer, run python3 send.py http://DEVICE_ADDRESS:8080. The supplied manifest persists records at /data; no dashboard code or need to be invented. Use a trusted workshop network for this unauthenticated example.
Optional: replay ESP32 alarm readings
The sensor alarm emits raw counts, not temperature. Save its JSON console lines as alarm.jsonl, then run:
python3 send.py --stdin < alarm.jsonlThe adapter maps raw to value and preserves unit: "count". A finite replay becomes STALE after it finishes. For live input, feed the same JSON lines through the board's supported console interface; restart the adapter after a board reboot. Its local alarm continues operating independently.
Keep recording clocks separate
The download contains JSONL records, not Wendy Data episodes. On Linux, receipt_ns uses the receiver's CLOCK_BOOTTIME; other systems label it monotonic. Source capture time remains unchanged inside sample.
For a later Wendy Data integration, multiplying capture_ms by a million only converts units. It cannot align two devices' boot clocks. Keep source time and session in a JSON stream until you have measured a clock mapping. The example README explains that boundary.
Troubleshooting
- Connection refused: start the receiver and check the address and port.
- HTTP 400: use numeric values,
degCorcount, and a boolean validity flag; faults requirevalue: null. - HTTP 409: check sequence order and restart sessions.
- Dashboard shows receiver disconnected: restart the receiver; current sample state is unknown until it reconnects.
Stop the sender and attached receiver with Ctrl+C when finished. Keep the downloaded file to compare displayed values with their original records.
Before you move on
Can you do each of these?
- Run a complete measurement-to-dashboard path
- Detect missing updates, reject duplicate samples, and save accepted records
0 of 3 checkpoints solved. Try checkpoint 1