Sensors¶
Sensors are drivers in the greenthumb-rpi5 package. The node picks the driver for each wired part at runtime, from the registry_key of its catalog row (component_model).
v1 prototype
The v1 prototype is a single bench rig. Not every supported component is fitted, and probes and dosing pumps must be calibrated before automatic dosing is used.
Looking for Actuators?
For lights, fans and pumps, see the Actuators page.
Supported Sensors¶
| Component | Registry key | Interface | Measures |
|---|---|---|---|
| TSL2561 | TSL2561 |
I2C | Light intensity, broadband, infrared |
| BMP280 | BMP280 |
I2C | Temperature, pressure |
| AHT10 | AHT10 |
I2C | Temperature, humidity |
| DS18B20 | DS18B20 |
1-Wire | Water temperature |
| Float switch | FLOAT_SWITCH |
GPIO | Reservoir level (on/off) |
| pH probe | PH_PROBE |
Analog, through an ADS1115 | pH (plus the raw probe voltage) |
| TDS probe | TDS_PROBE |
Analog, through an ADS1115 | Total dissolved solids, electrical conductivity (plus the raw probe voltage) |
| USB webcam | WEBCAM_REDRAGON_HITMAN |
USB | Photos (no measurements) |
What each model measures is data: one component_capability row per variable in the catalog seed of the database repository.
Wiring Is Data¶
How a part is wired to a node is a device_component row, not code: its interface, its address (I2C address, BCM pin or camera index), its parent component (an ADS1115 for the analog probes) and its instance_config. Rewiring a part means editing that row; the driver stays the same.
Calibration¶
The pH and TDS probes convert volts to a reading with the coefficients from their newest calibration_log row. An uncalibrated probe reports no value. The raw probe voltage is still recorded, so readings can be recomputed once a calibration exists.
Enable the Interfaces¶
On the Pi (Linux):
sudo raspi-config
# Interface Options > I2C > Enable
# Interface Options > 1-Wire > Enable (for the DS18B20)
sudo reboot
Check that the I2C sensors answer:
The api container is given /dev/i2c-1, /dev/video0 and the GPIO chip and runs privileged (see rasp5/compose.yaml).
Adding a New Sensor¶
-
Write the driver. In
greenthumb_rpi5/sensor.py, subclassSensor, implement_init_hardwareandread_data, and register it under a new key:from greenthumb_rpi5.component import Sensor, register_component @register_component("MY_KEY") class MySensor(Sensor): def _init_hardware(self): # Open the hardware. Shared handles such as the I2C bus come from self.bus. ... def read_data(self, **_) -> dict: # One key per capability: the variable name, lower case, spaces as underscores. return {"temperature": ...} -
Add it to the catalog. In the
databaserepository, add acomponent_modelrow withregistry_key = 'MY_KEY'and onecomponent_capabilityrow per variable it measures. - Wire it. Add a
device_componentrow for the node. -
Restart the API. On the Pi (Linux):
Troubleshooting¶
Sensor Not Detected¶
- Check the wiring and power (3.3V, not 5V, for the I2C sensors).
- Check that I2C is enabled:
ls /dev/i2c*. - Check the
addresson the part'sdevice_componentrow.
Permission Denied¶
On the Pi (Linux):