Connect a sensor reading to an edge dashboard

Run a supplied producer, HTTP receiver, and dashboard; test disconnects and download the readings.

Guided walkthrough·Intermediate·5 min read

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.py

Open http://127.0.0.1:8080. In another terminal, enter the same directory and run:

python3 send.py

The 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.

Checkpoint 1 of 3

The dashboard shows 23.6 degC with status STALE. What do you know about the temperature right now?

Commit to an answer. Every choice explains itself.

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.

Checkpoint 2 of 3

You stop the sender and start it again. Its first sample has sequence 0. An earlier run already sent sequence 0 from the same source. How does the receiver respond?

Commit to an answer. Every choice explains itself.

Optional: deploy to an edge device

Stop the local receiver with Ctrl+C. From the downloaded directory:

wendy run --build-type docker

Select 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.jsonl

The 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.

Checkpoint 3 of 3

One record has capture_ms 12500. A record from a second device has capture_ms 12000. Can you conclude the second was captured half a second earlier?

Commit to an answer. Every choice explains itself.

Troubleshooting

  • Connection refused: start the receiver and check the address and port.
  • HTTP 400: use numeric values, degC or count, and a boolean validity flag; faults require value: 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.

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

Previous: Compare two survey flights in a simulated construction yard
All lessons in this topic
  1. 1. Find a warehouse object with camera rays
  2. 2. Locate a thermal event in a digital twin
  3. 3. Build a robot guide that knows when it is uncertain
  4. 4. Compare two survey flights in a simulated construction yard
  5. 5. Connect a sensor reading to an edge dashboard

Ask Wendy

Answers about Wendy and WendyOS

What would you like to know?

Ask about devices, development, and deployment.

Check linked docs for technical details.