Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/darwinsbuddy/tempsense
Connect several DS18B20 1wire temperature sensors to a RaspberryPi and log their measurements or send it to a home assistant
https://github.com/darwinsbuddy/tempsense
1wire ds18b20 hassio homeassistant mqtt raspberrypi
Last synced: 27 days ago
JSON representation
Connect several DS18B20 1wire temperature sensors to a RaspberryPi and log their measurements or send it to a home assistant
- Host: GitHub
- URL: https://github.com/darwinsbuddy/tempsense
- Owner: DarwinsBuddy
- Created: 2022-07-09T21:27:11.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-08T13:45:17.000Z (almost 2 years ago)
- Last Synced: 2025-01-14T02:52:14.001Z (29 days ago)
- Topics: 1wire, ds18b20, hassio, homeassistant, mqtt, raspberrypi
- Language: Python
- Homepage:
- Size: 3.51 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# tempsense
This project connects several DS18B20 1wire temperature
sensors to a RaspberryPi.Following features are supported
- [x] Rotation logging (with auto-header)
- [x] Supported formats: csv, plaintext
- [x] Timezone support
- [x] Units supported: °C, °F
- [x] Mocking of sensors (for testing)
- [x] Map device serial numbers to custom names (device_map)
- [x] custom interval for temperature measurement
- [x] (optional) MQTT publishing for Home Assistant integration## Prerequisites
* [DS18B20 sensors](https://www.amazon.de/AZDelivery-1M-Kabel-DS18B20-Parent/dp/B07ZQNTTX4)
> several 1wire devices can be connected to a single GPIO pin
>
> (default: `GPIO4`, header `7`)* RaspberryPi
* `4.7 kOhm` resistor
* solder iron, etc.See `/doc/DS18B20.pdf` for assembly instructions
![]()
![]()
## Install
```commandline
pip install -r requirements.txt
```## Usage
```
python3 -m tempsense -i=
```### Mocking
To produce test output (random) start with argument `-m`.
3 fake devices with hardware names `@Mock-1`, `@Mock-2`, `@Mock-3`
will return random gauss values.
Test integration in your systems without fiddling with hardware first. ;)### rotating file log
Use `-o=` to enable rotating file logging, if this argument is omitted `stdout` is chosen as output
> Options:
>
> `-f=(csv | plain)` choose between csv and plaintext
>
> `-rb=` how many log files should be kept after rotating
>
> `-ri=` after which "time" rotating takes place
>
> `-ru=` unit of `rotating-interval`### mqtt (home assistant)
* Install [mosquitto](https://www.home-assistant.io/docs/mqtt/broker/) Add-On in `home-assistant`
* Configure it
> Logins
> ```
> - username:
> password:
> ```
* Register your sensors in `configuration.yaml` of home assistant as documented in `homeassistant/configuration.yaml` (`homeassistant/configuration.mock.yaml` resp.)
* Use it by providing at least `-mqtt=`use `-user= -pw=` (recommended)
> Note:
> Sensors' mqtt topics are the lower case name with ' ' replaced by '_', e.g. 'My Sensor 123' -> 'my_sensor_123'
### device mappingCreate a simple json file and map serial numbers of **your** sensors to
names of your desire
```
< dev_map.json
{
"28-aaaaaaaaaaaa": "Sensor-1",
"28-bbbbbbbbbbbb": "Sensor-2",
"28-cccccccccccc": "Sensor-3"
}
EOF
```
Use `-d=./dev_map.json` to map your devices
> MQTT topic will also be altered accordingly.
>
> i.e. instead of
>
> `/home-assistant/ds18b20/28-aaaaaaaaaaaa`
>
> we publish on
>
> `/home-assistant/ds18b20/Sensor-1`