Df robot temp moist ec
DFRobot RS485 soil temperature, humidity, and EC sensor implementation.
Reads soil moisture (%RH), temperature (°C), and electrical conductivity (μS/cm) from a DFRobot RS485/MODBUS soil sensor. Communication uses MODBUS RTU holding registers.
Each physical sensor has a configurable MODBUS device ID (2–253). Sensors
ship with a default ID of 1, which should be changed before deployment to
avoid address collisions. The change_id setup action handles this.
Config kwargs
device_id: MODBUS device ID of the sensor (2–253 recommended). tbr: Time between reads in seconds.
DFRobotRS485SoilTemperatureHumidityECSensor
¶
Bases: Sensor, MODBUSInterface, HasSetupFunctionsMixin
DFRobot RS485 soil sensor measuring moisture, temperature, and EC.
Communicates over MODBUS RTU, reading three holding registers per
measurement cycle. Reports three sub-parameters named
<parameter>.moisture, <parameter>.temperature, and
<parameter>.electrical_conductivity.
This sensor includes a setup action (change_device_id) for
reassigning the sensor's MODBUS address, which is necessary before
deploying multiple sensors on the same bus.
Attributes:
| Name | Type | Description |
|---|---|---|
parameter |
Base parameter name (sub-parameters are derived from it). |
|
bus |
The MODBUS bus instance used for communication. |
|
db_save_function |
Async callable for persisting measurements. |
|
config_save_function |
Callable for saving config changes to disk. |
|
device_id |
MODBUS device address of this sensor. |
|
time_between_reads |
Interval between measurement cycles (seconds). |
Source code in pt/controller_3/src/plant_controller/sensors/df_robot_temp_moist_ec.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
__init__(parameter, bus, db_save_function, config_save_function, device_id, tbr, **_kwargs)
¶
Initialize the DFRobot soil sensor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameter
|
str
|
Base name for the measured parameters (e.g. 'soil'). |
required |
bus
|
MODBUS
|
MODBUS bus instance for register reads/writes. |
required |
db_save_function
|
Callable[[Datapoint | list[Datapoint]], None]
|
Async function to persist measurements to the DB. |
required |
config_save_function
|
Callable
|
Callable for saving config changes (e.g. updated device_id) back to the plant's JSON config file. |
required |
device_id
|
int
|
MODBUS device address (2–253 recommended; 1 is the factory default and triggers a warning). |
required |
tbr
|
int
|
Time between reads in seconds. |
required |
**_kwargs
|
Any
|
Ignored; allows forward-compatible config expansion. |
{}
|
Source code in pt/controller_3/src/plant_controller/sensors/df_robot_temp_moist_ec.py
read()
async
¶
Read moisture, temperature, and EC registers and save as Measurements.
The blocking MODBUS register reads are offloaded to a worker thread to avoid stalling the async event loop.
Source code in pt/controller_3/src/plant_controller/sensors/df_robot_temp_moist_ec.py
get_capabilities()
¶
Return capabilities for the three sub-parameters.
Returns:
| Type | Description |
|---|---|
|
Dict with entries for |
|
|
|
|
|
|
Source code in pt/controller_3/src/plant_controller/sensors/df_robot_temp_moist_ec.py
change_id()
async
¶
Interactive procedure to change the sensor's MODBUS device ID.
Guides the user through safely reassigning the sensor's address on the MODBUS bus. Validates that the new ID is in the range 2–253 and writes it to the sensor's ID register. On success, updates the in-memory device_id and persists the change via config_save_function.
Source code in pt/controller_3/src/plant_controller/sensors/df_robot_temp_moist_ec.py
setup_functions()
¶
Return available setup actions for this sensor.
Returns:
| Type | Description |
|---|---|
dict[str, dict[str, Any]]
|
Dict with a |
dict[str, dict[str, Any]]
|
sensor's MODBUS address. |