Data is published to serial bus once per second as a comma delimited string.
Example:
26.70,35,736,1013,-5.91,26421
- Temperature - Celsius
- Humidity - Percent
- Light - Analog value between 0 and 100
- Pressure - Pa
- Altitude - m (Not accurate)
- CRC-16 - checksum of data fields
- DHT11 - temperature + humidity
- BMP085 - temperature + pressure
- LDR - light
pip3 install -r requirements.txt
- Serial -
9600
- LDR -
A0
- DHT11 -
4
serToMQTT.py
takes the data published by the Arduino and forwards it to an MQTT broker.
It takes the name of the serial port and name of the room it is in as parameters.
python3 serToMQTT.py "192.168.1.111" "/dev/ttyACM0" "livingroom"
An alternative to python is the q version serToMQTT.q
q serToMQTT.q -q "192.168.1.111" "/dev/ttyACM0" "livingroom"
You can subscribe from the command line to confirm your data is publishing to your broker:
mosquitto_sub -h 192.168.1.111 -t "homeassistant/#"
mosquitto_sub -h 192.168.1.111 -t "EnvironmentalMonitor/#"
MQTT discovery will automatically add these sensors to Home Assistant for you.
Discovery is not enabled, you will need to add to configuration.yaml
:
sensor:
platform: mqtt
name: "livingroomtemperature"
state_topic: "EnvironmentalMonitor/livingroom/state"
value_template: "{{ value_json.temperature }}"
qos: 0
unit_of_measurement: "ºC"
sensor 2:
platform: mqtt
name: "livingroomhumidity"
state_topic: "EnvironmentalMonitor/livingroom/state"
value_template: "{{ value_json.humidity }}"
qos: 0
unit_of_measurement: "%"
sensor 3:
platform: mqtt
name: "livingroompressure"
state_topic: "EnvironmentalMonitor/livingroom/state"
value_template: "{{ value_json.pressure }}"
qos: 0
unit_of_measurement: "hPa"
sensor 4:
platform: mqtt
name: "livingroomlight"
icon: "mdi:white-balance-sunny"
state_topic: "EnvironmentalMonitor/livingroom/state"
value_template: "{{ value_json.light }}"
qos: 0
unit_of_measurement: "/100"
To add to a Lovelace dashboard:
entities:
- entity: sensor.livingroomtemperature
- entity: sensor.livingroomhumidity
- entity: sensor.livingroompressure
- entity: sensor.livingroomlight
show_icon: true
show_name: false
show_state: true
title: Living Room
type: glance