Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kpetremann/dht2mqtt
Simple tool to send DHT11 or DHT22 sensor metrics to MQTT.
https://github.com/kpetremann/dht2mqtt
dht11 dht12 mqtt
Last synced: 4 days ago
JSON representation
Simple tool to send DHT11 or DHT22 sensor metrics to MQTT.
- Host: GitHub
- URL: https://github.com/kpetremann/dht2mqtt
- Owner: kpetremann
- License: mit
- Created: 2023-06-23T16:48:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-19T12:47:39.000Z (7 months ago)
- Last Synced: 2024-10-11T14:14:29.621Z (28 days ago)
- Topics: dht11, dht12, mqtt
- Language: Go
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
[![status](https://img.shields.io/badge/status-alpha-red)](https://github.com/kpetremann/dht2mqtt)
[![Go](https://img.shields.io/github/go-mod/go-version/kpetremann/dht2mqtt)](https://github.com/kpetremann/dht2mqtt)
[![CI](https://github.com/kpetremann/dht2mqtt/actions/workflows/go.yml/badge.svg)](https://github.com/kpetremann/dht2mqtt/actions/workflows/go.yml)
[![GitHub](https://img.shields.io/github/license/kpetremann/dht2mqtt)](https://github.com/kpetremann/dht2mqtt/blob/main/LICENSE)# DHT2MQTT
DHT2MQTT is yet another tool to send DHT11/DHT22 metrics to MQTT.
It is designed to be compatible with [mqtt-exporter](https://github.com/kpetremann/mqtt-exporter).
Only tested on Raspberry Pi 3B.
It leverages [MichaelS11/go-dht](https://github.com/MichaelS11/go-dht).
## Quickstart
### Build from source
```CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build ./cmd/dht2mqtt```
### Usage
```
Usage of ./dht2mqtt:
-dht-model string
DHT sensor model: DHT11 or DHT22 (default "DHT22")
-fahrenheit
Temperature unit. Fahrenheit if set, default is Celcius
-gpio-pin string
GPIO PIN Name on which the sensor is connected (default "GPIO4")
-log-level string
log level (debug, info, warn, error, fatal, panic, disabled) (default "info")
-mqtt-topic-root string
MQTT url, example: dht2mqtt/ (default "dht2mqtt/")
-mqtt-url string
MQTT url, example: tcp://127.0.0.1:1883
-mqtt-username string
username to connect to MQTT. The password must be set as in 'DHT2MQTT_PASSWORD' varenv
-sensor-name string
sensor name (default "sensor")
```Example:
```
~ $ DHT2MQTT_PASSWORD="awesomepassword" ./dht2mqtt -mqtt-url tcp://10.0.0.1:1883 -sensor-name garden -mqtt-username dht
```### Systemd service example
* Put the binary somewhere like in `/usr/local/bin/`.
* Create the file `/etc/systemd/system/dht2mqtt` with the following content:```
[Unit]
Description = dht2mqtt
Wants = network-online.target
After = network-online.target[Install]
WantedBy = multi-user.target[Service]
Type = simple
Environment = "DHT2MQTT_PASSWORD="
ExecStart = /usr/local/bin/dht2mqtt -mqtt-url tcp://10.0.0.:1883 -sensor-name -mqtt-username
```**Do not forget to adapt the variables.**
* Then simply run it and enable on boot:
```
sudo systemctl daemon-reloadsystemctl enable --now dht2mqtt
# or:
sudo systemctl enable dht2mqtt
sudo systemctl start dht2mqtt
```## Support
[![](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86)](https://github.com/sponsors/kpetremann)