All Projects → robmarkcole → rpi-enviro-mqtt

robmarkcole / rpi-enviro-mqtt

Licence: Apache-2.0 license
Send air quality data from a Pimoroni RPi Enviro+ over MQTT

Programming Languages

Jupyter Notebook
11667 projects

Projects that are alternatives of or similar to rpi-enviro-mqtt

M5Stack-Air-Quality-ESPHome
ESPHome configuration for M5Stack's PM2.5 Air Quality Kit with the PMSA003 particulate matter sensor and the SHT20 temperature and humidity sensor
Stars: ✭ 19 (-36.67%)
Mutual labels:  mqtt, air-quality, home-assistant
System sensors
Logging of system sensor specific for the RPI and sending them to a MQTT broker
Stars: ✭ 134 (+346.67%)
Mutual labels:  mqtt, home-assistant
Android Mqtt Alarm Panel
Android Alarm Panel for Home Assistant and Home Automation Platforms (http://thanksmister.com/android-mqtt-alarm-panel/)
Stars: ✭ 124 (+313.33%)
Mutual labels:  mqtt, home-assistant
Home Assistant Config Fr
🏠Configuration de Home Assistant en français. 👨🏻‍💻 N'hésitez pas à ⭐ mon repo et à copier les bonnes idées ! 🇨🇵
Stars: ✭ 175 (+483.33%)
Mutual labels:  mqtt, home-assistant
Loadcelloccupany
Home automation occupancy sensor using load cells
Stars: ✭ 103 (+243.33%)
Mutual labels:  mqtt, home-assistant
Ha Shellies Discovery
Script that adds MQTT discovery support for Shellies devices
Stars: ✭ 113 (+276.67%)
Mutual labels:  mqtt, home-assistant
Zm1
斐讯M1空气检测仪个人固件公开项目. 此项目为公开release+讨论
Stars: ✭ 165 (+450%)
Mutual labels:  mqtt, home-assistant
Addon Zwave2mqtt
Z-Wave to MQTT - Home Assistant Community Add-ons
Stars: ✭ 58 (+93.33%)
Mutual labels:  mqtt, home-assistant
Home Assistant
Home-Assistant-Config
Stars: ✭ 182 (+506.67%)
Mutual labels:  mqtt, home-assistant
Arilux al Lc0x
Alternative firmware for Arilux AL-LC0X LED controllers, based on the MQTT protocol and a TLS connection
Stars: ✭ 194 (+546.67%)
Mutual labels:  mqtt, home-assistant
Hass Workstation Service
Provide useful sensors and services from your workstation to Home Assistant.
Stars: ✭ 198 (+560%)
Mutual labels:  mqtt, home-assistant
Home Assistant Configuration
My Home Assistant Config. For more Information visit ->
Stars: ✭ 102 (+240%)
Mutual labels:  mqtt, home-assistant
Frigate
NVR with realtime local object detection for IP cameras
Stars: ✭ 1,329 (+4330%)
Mutual labels:  mqtt, home-assistant
Itead sonoff
Alternative firmware for Itead Sonoff switches, based on the MQTT protocol and a TLS connection
Stars: ✭ 115 (+283.33%)
Mutual labels:  mqtt, home-assistant
Pysmartnode
Micropython Smarthome framework
Stars: ✭ 58 (+93.33%)
Mutual labels:  mqtt, home-assistant
Temper Esp8266
Temper is a compact temperature sensor based on ESP8266 and SHT30 with large 13x7 pixel led display.
Stars: ✭ 155 (+416.67%)
Mutual labels:  mqtt, home-assistant
ha-iaquk
Indoor Air Quality Sensor Component for Home Assistant
Stars: ✭ 57 (+90%)
Mutual labels:  air-quality, home-assistant
Wavin Ahc 9000 Mqtt
Esp8266 mqtt interface for Wavin AHC-9000/Jablotron AC-116
Stars: ✭ 47 (+56.67%)
Mutual labels:  mqtt, home-assistant
Homeautomation.codesys3
Home Automation system build in CoDeSys 3 with MQTT communication to any third party Home Automation software
Stars: ✭ 55 (+83.33%)
Mutual labels:  mqtt, home-assistant
Openmqttgateway
MQTT gateway for ESP8266, ESP32, Sonoff RF Bridge or Arduino with bidirectional 433mhz/315mhz/868mhz, Infrared communications, BLE, Bluetooth, beacons detection, mi flora, mi jia, LYWSD02, LYWSD03MMC, Mi Scale, TPMS, BBQ thermometer compatibility, SMS & LORA.
Stars: ✭ 2,413 (+7943.33%)
Mutual labels:  mqtt, home-assistant

rpi-enviro-mqtt

Send air quality data from a Pimoroni RPi Enviro+ over MQTT. This script works with the Enviroplus with or without the PMS5003 sensor attached. Note that the mqtt-all.py script is now included in the pimoroni repo here

The mqtt-all.py script is a fork of the official luftdaten.py script. The main difference being that this script uses MQTT to publish data over the local network (vs internet to Luftdaten) so there no dependency on internet connection. Also since you don't need to poll the Luftdaten website for data, latency is almost eliminated and you can visualise data in real time, using a tool like mqtt-explorer (screenshot below).

Installation & setup

You should first install the Pimoroni enviroplus-python library. There is one additional dependency required for this script, which is paho-mqtt. This can be installed with pip3 install paho-mqtt. You need an MQTT broker to receive the data, if you haven't already set one up, a broker can be installed on the rpi with sudo apt-get install mosquitto mosquitto-clients. Note this broker will run at startup automatically, which is very convenient. Note also that this broker is unsecured by default, and that this code is only for personal (not professional) use on a secure local network. You should publish some MQTT data from the command line to check the broker is functioning, and verify receipt of this data using the tool of your choice (e.g. mqtt-explorer). Your device is assigned an MQTT client_id of format raspi-device_serial_number. Clone this repo to your rpi, making note of the path to mqtt-all.py

Run the mqtt-all.py script

From the terminal you can run the script with readings every 5 seconds:

python3 /home/pi/yourdir/rpi-enviro-mqtt/mqtt-all.py --broker localhost --port 1883 --topic enviroplus --interval 5

Note that the arguments passed here are the defaults, and just shown as an example.

Run as a service

You can run the mqtt-all.py script as a service, which means it can be configured to automatically start on RPi boot, and can be easily started & stopped. Create the service file in the appropriate location on the RPi using: sudo nano /etc/systemd/system/enviro.service

Entering the following (adapted for your mqtt-all.py file location and args):

[Unit]
Description=Enviroplus MQTT Logger
After=network.target

[Service]
ExecStart=/usr/bin/python3 /home/pi/github/rpi-enviro-mqtt/mqtt-all.py --broker 192.168.1.164 --topic enviroplus --interval 5
WorkingDirectory=/home/pi/github/rpi-enviro-mqtt
StandardOutput=inherit
StandardError=inherit
Restart=always
User=pi

[Install]
WantedBy=multi-user.target

Once this file has been created you can start the service using: sudo systemctl start enviro.service

View the status and logs with: sudo systemctl status enviro.service

Stop the service with: sudo systemctl stop enviro.service

Restart the service with: sudo systemctl restart enviro.service

You can have the service auto-start on rpi boot by using: sudo systemctl enable enviro.service

You can disable auto-start using: sudo systemctl disable enviro.service

Home Assistant integration

I am using home-assistant to receive and log the enviro mqtt data. The benefits are: logging to .db sqlite file & graphing. Simply configure an mqtt-sensor on the enviro topic (or whatever you selected) and break out the individual readings using a template. Example below, and assuming you have a PMS5003 attached, in sensor.yaml:

- platform: mqtt
  state_topic: "enviroplus"
  value_template: "{{ value_json.pm1 }}"
  name: "enviro_pm1"
  unit_of_measurement: 'pm'
  icon: "mdi:thought-bubble-outline"
- platform: mqtt
  state_topic: "enviroplus"
  value_template: "{{ value_json.pm10 }}"
  name: "enviro_pm10"
  unit_of_measurement: 'pm'
  icon: "mdi:thought-bubble-outline"
- platform: mqtt
  state_topic: "enviroplus"
  value_template: "{{ value_json.pm25 }}"
  name: "enviro_pm2"
  unit_of_measurement: 'pm'
  icon: "mdi:thought-bubble"
- platform: mqtt
  state_topic: "enviroplus"
  value_template: "{{ value_json.humidity }}"
  name: "enviro_humidity"
  unit_of_measurement: '%'
  icon: "mdi:water-percent"
- platform: mqtt
  state_topic: "enviroplus"
  value_template: "{{ value_json.pressure }}"
  name: "enviro_pressure"
  unit_of_measurement: 'Pa'
  icon: "mdi:arrow-down-bold"
- platform: mqtt
  state_topic: "enviroplus"
  value_template: "{{ value_json.temperature }}"
  name: "enviro_temperature"
  unit_of_measurement: 'C'
  icon: "mdi:thermometer"
- platform: mqtt
  state_topic: "enviroplus"
  value_template: "{{ value_json.lux }}"
  name: "enviro_lux"
  unit_of_measurement: 'lx'
  icon: "mdi:weather-sunny"
- platform: mqtt
  state_topic: "enviroplus"
  value_template: "{{ value_json.nh3 }}"
  name: "enviro_nh3"
  unit_of_measurement: 'nh3'
  icon: "mdi:thought-bubble"
- platform: mqtt
  state_topic: "enviroplus"
  value_template: "{{ value_json.reduced }}"
  name: "enviro_reduced"
  unit_of_measurement: 'CO'
  icon: "mdi:thought-bubble"
- platform: mqtt
  state_topic: "enviroplus"
  value_template: "{{ value_json.oxidised }}"
  name: "enviro_oxidised "
  unit_of_measurement: 'no2'
  icon: "mdi:thought-bubble"

Using the created entities you can add an entity card like the following:

Hardware

I bought the following:

Total cost £86, which is considerably cheaper than commercial devices containing similar sensors, e.g. uHoo (£325) or Kaiterra (£260)

My study

I live on a road that can get congested during rush hour, and I want to know if the pollution in the house is rasied during these times. I have the Enviro+ on a windowsill streetside. I've only just started capturing data, and also owing to covid lock-down there is hardly any traffic. Analytics of my data is in the analytics folder of this repo.

Publication

This setup was used in the following publication: Indoor Air Pollution from Residential Stoves: Examining the Flooding of Particulate Matter into Homes during Real-World Use

Presentation

My former colleage Oliver Crask (@olivercrask) presented on IAQ monitoring with the PMS sensor at an event in London in 2018, and the pdf presentation is included in this repo. A video of the presentation is below:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].