Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
Dosing: temperature and level sensor drivers (DS18B20, SHT31/BME280, float switches) as Reading sources #608
Merged 40d 3h ago
This adds the sensor drivers and logs their readings into the grow log book. The dosing controller from #586 isn't on main, so nothing here talks to it yet.
-
Reviews
Changes requested — before the latest pushThe drivers are careful: CRC checks, the 85 °C power-on guard, strict config validation, injected commands, and one failing sensor stops nothing. Several items on the list are missing, though.
- Both doors / reachable. A person cannot see a sensor anywhere. There is no page card and no
src/tty.tscommand for the sensors' last values or errors. The only route isGET /grow/sensorson the arm server, and nothing proxies it to the relay or the page. A DS18B20 that is miswired shows nothing but a line on stderr. Fix first: add a sensors line to the grow/care card (label, value, 'last read N min ago' or the error) and the same in the tty, both through the relay's gating, with a test for each. - README. Nothing says how to use it. The README has no
sensors.jsonsection: no file location, no example for each driver, no note thati2ctransferandgpiogetmust be installed on the Pi, and no mention of the 1-Wire overlay. - Tests.
pullSensorsinrelay.tshas no test, and it is the only path that writes to the book. Nothing would fail if it were deleted or if it called the wrong URL. Add a relay test with a fake arm that serves/grow/sensors, and assert that bad entries are skipped and that a failing arm logs nothing. Also add a test for the full-book eviction inaddReading, so a hand's entries are shown to survive. The current test never fills the book. - Direction. Sensors going into the log book is reasonable. The bench
fake-servechange is fine. The PR text says 'dosing' but the controller isn't there, so say plainly in the description that this only feeds the log book.
The unauthenticated
/grow/sensorson the arm server matches the arm server's other reads. Once it is shown on the page, gate it on the relay likeGET /grow.ApprovedApproved from the diff and tests. The preview has no sensors.json and /grow is owner-only, so I could not see the card there. The drivers are validated at the boundary, the CRC and 85 °C guards are tested, and the card and terminal escape and bound what they show. They share the gated /grow path, so the terminal matches the page. The log book never loses a hand-written entry, and the README covers wiring and setup.
Two things to do next:
- Guard Sensors.tick against overlap. If i2ctransfer or gpioget hangs, a 60 s interval will stack reads. Skip a tick while one is still running, and cap the run time.
- Make pullSensors check options.care explicitly instead of relying on the inner catch to swallow a TypeError. Also move the .sensors li.bad colour onto the page's existing error token so the design lint and contrast checks cover it.
Smaller point: GET /grow/sensors on the arm server is unauthenticated like its other reads, and nothing public reaches it. If the arm server ever faces a network wider than the relay, gate it.
- Both doors / reachable. A person cannot see a sensor anywhere. There is no page card and no
-
Checks
shipped merged
-
History
- Sensors on the Grow card and /grow in the terminal, relay and eviction tests, README section fee0a31
- Grow sensors: DS18B20, SHT31, BME280 and float-switch drivers as Reading sources, served at /grow/sensors and logged hourly into the care log book bf81689
- Grow care: a plant profile (spinach first), reminders from it, a log book, and metrics with target bands; manual now, sensors later (#598) 13887dd
- Grow stills at 1920×1080, cropped to the camera's region and colour-corrected (split from #584) (#603) d2bd69c
- so101 server: hang up after answering 413 at the body cap (#602) f5a7213
- Grow box: a still every 10 min, a scrubbable timelapse, a grow log and a canopy chart (#601) d623239
- Grow light schedule: a switch driver (smart plug, GPIO relay, or uhubctl only when it switches the light alone) with a photoperiod that runs on the Pi (#599) 0ea35e6
- Grow card: "Camera can't see the plants" hint when the camera's region is mostly blown out or black (split from #584) (#597) 315c1ae
- Pump: an interval-cycle schedule on the Switch interface (with #585) (#596) 82337a2
- The workshop: one Pi, several stations (the arm and the grow box), each with cameras and controls; works with the arm unplugged (#592) 37b3b00
- The identity line on /story and /admin/data (#594) 568b0ea
- Grow cameras: a saved camera profile per Pi camera, re-applied at every start, and a Tune panel with the box drawn once and colour correction under grow light (#591) 17c46ef
- Sign out, and every page shows who you are, even when the arm is off (#587) 1873f3c
- Closing the arm locks its owner out: keep sign-in and /admin working while closed, an Open now button on the resting card, and so101 open/close (#579) fba1312
- setup: find LeRobot calibration in its nested folders (calibration/robots/so_follower/*.json) (#577) 6da7fb9
- `so101 setup` finds both arms, asks you to wiggle the leader, reuses existing calibration, then starts teleop (#575) f44d21f
- `so101 teleop` drives the follower from the leader in one process at 60 Hz, with a joint table, lag and space to STOP (#574) 43e37d1
- The so101 CLI runs under Node: `node bin/so101 --help` and `ports` no longer reach bun:sqlite (#573) 7583cb5
- Open / Closed: the owner can close the arm, and a resting card tells visitors why (and when it is back) (#568) ab0fd8a
- The story page: an engaging write-up of the arm for anyone, with the Hugging Face SO-101 docs and the public repo (#567) aef8f48
This adds the sensor drivers and logs their readings into the grow log book. The dosing controller from #586 isn't on main, so nothing here talks to it yet. The new and related suites pass (148 tests, including src/sensors.test.ts) and the type check shows no errors in the files I touched; I didn't run the whole check, and I haven't tried any of the drivers on real hardware.
- Drivers (
src/sensors.ts):ds18b20reads the 1-Wire file for water temperature. It rejects a failed CRC and the power-on 85 °C value.sht31reads air temperature withi2ctransferand checks the sensor's CRC.bme280reads air temperature with the datasheet compensation.floatreads a GPIO float switch withgpiogetand reports level as 100 when wet and 0 when dry, with anactiveLowoption.
- Config: the sensors are listed in
sensors.jsonunderFORGE_APP_DATAand validated on load. A bad file is ignored with a message on stderr. - Arm server: it reads the sensors every 60 s and serves them at
GET /grow/sensorswith each one's last value, time and error. One sensor failing doesn't stop the others. - Log book: the relay pulls the arm's readings every 10 min in
bench/fake-serve.tsand in thestartRelayoptionsensorsMs. They go through a newCareLog.addReading, which keeps at most one reading per kind per hour, checks the same limits as manual entries, and tags themsource: "sensor". If the book is full, the oldest sensor reading is dropped first, so manual entries are never the ones lost.
The /grow/sensors route isn't owner-gated on the arm server, so any caller that reaches the arm can read it.
This adds temperature and level sensor drivers (DS18B20, SHT31, BME280, float switch) and logs their readings into the care log book. It does not touch the dosing controller from #586, which isn't on main. The new tests, the readme, terminal and light-endpoint suites pass, and the type check shows nothing in the touched files. I didn't run the whole check or try any driver on real hardware.
- Drivers: each sensor is a reading source for water temperature, air temperature or water level. The list lives in
sensors.jsonunderFORGE_APP_DATA. The CRC checks, the 85 °C power-on guard and the validation of that file are unchanged from before. - Sensor values:
- The arm server reads the sensors every minute and serves them in
GET /grow(andGET /grow/sensors). - The relay pulls the last good reading of each into the care log book, at most one per kind per hour, marked as a sensor's.
- The pull is a relay option,
sensorsMs, which onlybench/fake-serve.tssets (every 10 minutes).
- The arm server reads the sensors every minute and serves them in
- Seeing it:
- /admin → Grow has a "Sensors" list. Each line shows the value and how long ago it was read, or the error, for example a miswired probe "not on the 1-Wire bus".
- The terminal's
/growprints the same lines. - The sensors ride in
GET /grow, so both go through the relay's existing owner-only gating;readGrowskips malformed entries, and the page escapes the labels.
- Readme: a new "Sensors" section covers where
sensors.jsongoes, an example for each driver, the 1-Wire overlay and wiring, and thati2c-tools(i2ctransfer) andgpiod(gpioget) must be installed on the Pi. - Tests:
src/sensors-relay.test.tsruns a relay against a fake arm. Good readings are logged, bad ones (out of range, wrong type, unknown kind, null) are skipped, and an arm that has gone away logs nothing.- A full-book test shows only sensor readings are evicted and a hand's entries survive. With none left to evict,
addReadingthrows. - Further tests cover the sensor line, the card and terminal output, and
GET /growcarrying the sensors.
I left GET /grow/sensors unauthenticated on the arm server, like its other reads. Nothing a person reaches serves it unguarded, because the card and terminal use the gated /grow.
🤖 Generated with Claude Code
This adds the sensor drivers and logs their readings into the grow log book. The dosing controller from #586 isn't on main, so nothing here talks to it yet. The new and related suites pass (148 tests, including
src/sensors.test.ts) and the type check shows no errors in the files I touched; I didn't run the whole check, and I haven't tried any of the drivers on real hardware.src/sensors.ts):ds18b20reads the 1-Wire file for water temperature. It rejects a failed CRC and the power-on 85 °C value.sht31reads air temperature withi2ctransferand checks the sensor's CRC.bme280reads air temperature with the datasheet compensation.floatreads a GPIO float switch withgpiogetand reports level as 100 when wet and 0 when dry, with anactiveLowoption.sensors.jsonunderFORGE_APP_DATAand validated on load. A bad file is ignored with a message on stderr.GET /grow/sensorswith each one's last value, time and error. One sensor failing doesn't stop the others.bench/fake-serve.tsand in thestartRelayoptionsensorsMs. They go through a newCareLog.addReading, which keeps at most one reading per kind per hour, checks the same limits as manual entries, and tags themsource: "sensor". If the book is full, the oldest sensor reading is dropped first, so manual entries are never the ones lost.The
/grow/sensorsroute isn't owner-gated on the arm server, so any caller that reaches the arm can read it.Closes #605