# Sensor dashboard workshop

Python 3.11 or newer, no packages required. Run `python3 server.py`, open
http://127.0.0.1:8080, and run `python3 send.py` in another terminal.
Stop the sender with Ctrl+C to observe STALE after three seconds.
Restart it to get a new session and a sequence starting at zero.
Stop the server with Ctrl+C when finished.

The simulator uses elapsed time since the producer process started as its
source-boot clock. An ESP32 uses elapsed time since the board booted.
Each session identifies a new source clock origin. Do not subtract these times
from receiver clocks to estimate network latency.

The receiver accepts finite values in degC or raw 12-bit ADC count. A fault uses
valid=false and value=null. Duplicate sequences, older capture times within a
session, and packets from retired sessions get HTTP 409. Malformed samples get
HTTP 400. Sequence history is in memory and starts fresh on receiver restart.
Accepted samples append to data/samples.jsonl; GET /records downloads them.
The file persists across restarts but does not reconstruct live status.
This small workshop receiver has no authentication or log rotation. Run it on
a trusted workshop network for the exercise.

## Wendy device

From this directory run `wendy run --build-type docker` and select a prepared
Linux Wendy target. Open http://DEVICE_ADDRESS:8080 and run
`python3 send.py http://DEVICE_ADDRESS:8080` on your computer. DEVICE_ADDRESS
is the target's reachable LAN address. Keep port 8080 free on that device.
The supplied persist entitlement stores records under /data on the target.
The sender remains on your computer; Docker builds only the receiver and UI.

## ESP32 alarm adapter

Save only JSON lines from the sensor-alarm lesson's firmware console to
alarm.jsonl, then run `python3 send.py --stdin < alarm.jsonl` for local replay.
For a live source, feed that same JSON-lines stream into send.py's stdin through
your board's supported console interface. This package does not configure a
serial driver. Restart the adapter after a board reboot to create a new session.

The adapter maps raw to value and keeps unit=count. It does not convert the knob
into temperature. The original firmware's local alarm keeps operating; this
dashboard displays measurement validity and freshness, not its alarm threshold.

## Recording clock boundary

On Linux, receipt_ns comes from the receiver's CLOCK_BOOTTIME. On other systems
it is tagged monotonic. Both are separate from source capture_ms.
For a Wendy Data stream sampled on the receiving Linux device, obtain its actual
CLOCK_BOOTTIME timestamp there. Multiplying source capture_ms by 1,000,000 only
changes units; it does not map the source's boot origin to the receiver's boot.
Keep original capture time and session in an opaque JSON stream if no clock
mapping has been measured. This example saves JSONL and does not automatically
submit records to Wendy Data.
