update: improve documentation and restructure code for modular hardware integration, add CAN communication to HAL, and update KiCad layouts
This commit is contained in:
@@ -6,22 +6,84 @@ description: "a description"
|
||||
tags: ["mqtt", "esp"]
|
||||
---
|
||||
# MQTT
|
||||
An Mqtt server can be configured and will be used to dump all kinds of statistical data.
|
||||
A configured MQTT server will receive statistical and status data from the controller.
|
||||
|
||||
|Topic|Example|Description|
|
||||
|/firmware/address|
|
||||
### Topics
|
||||
|
||||
| Topic | Example | Description |
|
||||
|----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------|
|
||||
| firmware/address | 192.168.1.2 | The Ip address in station mode |
|
||||
| firmware/githash | feature/esp32c6@1ce4d74a | The branch and hash during build time |
|
||||
| firmware/buildtime | 2025-01-21T20:56:18.168163570Z | Compile time |
|
||||
| firmware/last_online | 2025-01-22T08:56:46.664+01:00 | Last time this board was online |
|
||||
| firmware/ota_state | Partition state is ESP_OTA_IMG_VALID | The OTA state, relevant for rollback |
|
||||
| firmware/partition_address | 0x10000 | The OTA partition used, 0x10000 is ota_1 |
|
||||
| state | online | Current State, expected are online or sleep |
|
||||
| battery | {<br/>"voltage_milli_volt":"12860",<br/>"current_milli_ampere":"-16",<br/>"cycle_count":"12",<br/>"design_milli_ampere":"6000",<br/>"remaining_milli_ampere":"806",<br/>"state_of_charge":"15",<br/>"state_of_health":"93",<br/>"temperature":"2957"<br/>} | Dump of battery data |
|
||||
| water | {<br/>"enough_water":true,<br/>"warn_level":false,<br/>"left_ml":1337,<br/>"sensor_error":false,<br/>"raw":0,"water_frozen":<br/>"tank sensor error"<br/>} | Water Status dump |
|
||||
| plant1 | {<br/>"a":"disabled",<br/>"a_raw":"0",<br/>"b":"disabled",<br/>"b_raw":"0",<br/>"mode":"OFF",<br/>"consecutive_pump_count":0,<br/>"dry":false,<br/>"active":false,<br/>"pump_error":false,<br/>"not_effective":false,<br/>"cooldown":false,<br/>"out_of_work_hour":false,<br/>"last_pump":"N/A",<br/>"next_pump":"N/A"<br/>} | Plant status dump |
|
||||
| light | {<br/>"active":false,<br/>"out_of_work_hour":true,<br/>"battery_low":true,<br/>"is_day":false<br/>} | Light status dump |
|
||||
| deepsleep | night 1h | Why and how long the ESP will sleep |
|
||||
| Topic | Example | Description |
|
||||
|-------|---------|-------------|
|
||||
| `firmware/address` | `192.168.1.2` | IP address in station mode |
|
||||
| `firmware/state` | `VersionInfo { ... }` | Debug information about the current firmware and OTA slots |
|
||||
| `firmware/last_online` | `2025-01-22T08:56:46.664+01:00` | Last time the board was online |
|
||||
| `state` | `online` | Current state of the controller |
|
||||
| `mppt` | `{"current_ma":1200,"voltage_ma":18500}` | MPPT charging metrics |
|
||||
| `battery` | `{"Info":{"voltage_milli_volt":12860,"average_current_milli_ampere":-16,...}}` | Battery health and charge data |
|
||||
| `water` | `{"enough_water":true,"warn_level":false,"left_ml":1337,...}` | Water tank status |
|
||||
| `plant{1-8}` | `{"sensor_a":...,"sensor_b":...,"mode":"TargetMoisture",...}` | Detailed status for each plant slot |
|
||||
| `pump{1-8}` | `{"enabled":true,"pump_ineffective":false,...}` | Metrics for the last pump activity |
|
||||
| `light` | `{"enabled":true,"active":true,...}` | Night light status |
|
||||
| `deepsleep` | `night 1h` | Why and how long the ESP will sleep |
|
||||
|
||||
### Data Structures
|
||||
|
||||
#### Firmware State (`firmware/state`)
|
||||
Contains a debug dump of the `VersionInfo` struct:
|
||||
- `git_hash`: Branch and commit hash
|
||||
- `build_time`: Compilation timestamp
|
||||
- `current`: Current running partition
|
||||
- `slot0_state`: State of OTA slot 0
|
||||
- `slot1_state`: State of OTA slot 1
|
||||
|
||||
#### MPPT (`mppt`)
|
||||
- `current_ma`: Solar charging current in mA
|
||||
- `voltage_ma`: Solar panel voltage in mV
|
||||
|
||||
#### Battery (`battery`)
|
||||
Can be `"Unknown"` or an `Info` object:
|
||||
- `voltage_milli_volt`: Battery voltage
|
||||
- `average_current_milli_ampere`: Current draw/charge
|
||||
- `design_milli_ampere_hour`: Battery capacity
|
||||
- `remaining_milli_ampere_hour`: Remaining capacity
|
||||
- `state_of_charge`: Charge percentage (0-100)
|
||||
- `state_of_health`: Health percentage (0-100)
|
||||
- `temperature`: Temperature in degrees Celsius
|
||||
|
||||
#### Water (`water`)
|
||||
- `enough_water`: Boolean, true if level is above empty threshold
|
||||
- `warn_level`: Boolean, true if level is below warning threshold
|
||||
- `left_ml`: Estimated remaining water in ml
|
||||
- `percent`: Estimated fill level in percent
|
||||
- `raw`: Raw sensor voltage in mV
|
||||
- `sensor_error`: Details if the level sensor fails
|
||||
- `water_frozen`: Boolean, true if temperature is below freezing
|
||||
- `water_temp`: Water temperature in degrees Celsius
|
||||
- `temp_sensor_error`: Details if the temperature sensor fails
|
||||
|
||||
#### Plant (`plant{1-8}`)
|
||||
- `sensor_a` / `sensor_b`: Moisture sensor status
|
||||
- `Disabled`
|
||||
- `{"MoistureValue":{"raw_hz":5000,"moisture_percent":65}}`
|
||||
- `{"SensorError":{"ShortCircuit":{"hz":...,"max":...}}}`
|
||||
- `mode`: Watering mode (`Off`, `TargetMoisture`, `MinMoisture`, `TimerOnly`)
|
||||
- `do_water`: Boolean, true if watering is currently required
|
||||
- `dry`: Boolean, true if moisture is below target
|
||||
- `cooldown`: Boolean, true if the pump is in cooldown period
|
||||
- `out_of_work_hour`: Boolean, true if currently outside allowed watering hours
|
||||
- `consecutive_pump_count`: Number of pump cycles without reaching target
|
||||
- `pump_error`: Details if the pump is failing
|
||||
- `last_pump`: Timestamp of last activity
|
||||
- `next_pump`: Estimated timestamp for next allowed activity
|
||||
|
||||
#### Pump (`pump{1-8}`)
|
||||
- `enabled`: Boolean, pump was active
|
||||
- `pump_ineffective`: Boolean, no flow detected during pumping
|
||||
- `median_current_ma`: Median pump current
|
||||
- `max_current_ma`: Peak pump current
|
||||
- `min_current_ma`: Minimum pump current
|
||||
|
||||
#### Light (`light`)
|
||||
- `enabled`: Boolean, is enabled in config
|
||||
- `active`: Boolean, led is currently on
|
||||
- `out_of_work_hour`: Boolean, led should not be on at this time of day
|
||||
- `battery_low`: Boolean, battery is low so led usage is restricted
|
||||
- `is_day`: Boolean, the sun is up (determined by solar panel voltage)
|
||||
Reference in New Issue
Block a user