External sensors (#153)

* proof of principle, a DS18B20 is read and its value is transferred via MQTT, also discovery message works

* added names for ext sensors

* bugfix for names: there was a problem with the topics & added SHT21 support

* catch exceptions if a problem during readout occurs, shrink comments in config-file

* include ext_sensors in README file

* work in progress

* bugfix, also for ID of ds18b20 sensor

* Revert "bugfix, also for ID of ds18b20 sensor"

This reverts commit 1353b840b0b6142670ec59438db4b33fab764b8e.

file was intended for another branch

* Revert "work in progress"

This reverts commit b3e884f79f5356b79f64931cb4d45a150bfce2c7.

these changes were intended for another branch

* bugfix for ID of ds18b20 sensor
This commit is contained in:
pallago
2024-11-05 22:26:05 +01:00
committed by GitHub
parent 3e05c4f763
commit 95fcc7f1db
6 changed files with 368 additions and 12 deletions

View File

@@ -29,6 +29,7 @@ The easiest way to track your Raspberry Pi or Ubuntu computer system health and
- [Automated](#automated)
- [Manual](#manual)
- [Configuration](#configuration)
- [External Sensors](#external-sensors)
- [Test Raspberry Pi MQTT Monitor](#test-raspberry-pi-mqtt-monitor)
- [Schedule Raspberry Pi MQTT Monitor execution as a service](#schedule-raspberry-pi-mqtt-monitor-execution-as-a-service)
- [Schedule Raspberry Pi MQTT Monitor execution](#schedule-raspberry-pi-mqtt-monitor-execution)
@@ -166,6 +167,18 @@ The group message looks like this:
1.3, 47.1, 12, 1.2, 600, nan, 14.1, 12, 50, -60
```
### External Sensors
External sensors (currently DS18B20 for temperature and SHT21 for temperature and humdity) can be read out.
Therefore the ```ext_sensor```key in the config file must be configured.
A list of sensors with properties ```[name, sensor_type, ID, default_value]``` must be given.
The default_value is returned if the Raspberry fails to read the external sensor. The default value is either a scalar or a list, e.g. temperature and humidity. Examples:
* 1x ds18b20 sensor located in the RPi housing: ```ext_sensors = [["Housing", "ds18b20", "0014531448ff", -300]]```
* If the ID in unkown and if there is only 1 ds18b20 sensor, then use: ```ext_sensors = [["Housing", "ds18b20", 0, -300]]```
* If there are two sensors, one DS18B20 and one SHT21 (via I2C), then use: ```ext_sensors = [["Housing", "ds18b20", "0014531448ff", -300], ["Outside", "sht21", 0, [-300, 0]]]```, where the -300 is the default value for temperature and 0 is the default value for humidity.
default option is ```False```
## Test Raspberry Pi MQTT Monitor
Run Raspberry Pi MQTT Monitor (this will work only if you used the automated installer or created the shortcut manually)