Sensor that outputs:
- co2 from MH-Z19 sensor
- temperature and humidity from DHT11 sensor
- light from GL5528 resistor
This is modification of project http://www.crystalairfresh.ucoz.net
- Connect MH-Z19 to pin 1 and 5v
- Connect DHT11 to pin 2 and 5v
- Connect light resistor to A0 (not so easy, don't want to explain)
- Connect PMS7003: SET to D6, RX to TX, TX to RX
Get firmware from https://nodemcu-build.com/ with modules:
- adc
- dht
- file
- gpio
- mqtt
- net
- node
- pwm
- tmr
- uart
- wifi
esptool.py --port COM3 write_flash 0x00000 /path/to/nodemcu_float.bin
Or compile it, using user_modules.h
.
Copy config-secrets.default.lua
to config-secrets.lua
and fill your credentials.
I am just open all lua files in ESPlorer and upload it, init.lua
should be uploaded last.
Or you can install nodemcu-tool
, change port address in Makefile
and call make
from project root:
make upload_all
All docs below is obsolete after @418f481.
I am using it with Grafana, Telegraf and InfluxDB.
Put file in cron:
#!/bin/bash
output_path="/path/to/co2-temp-hum-sensor.json"
location="room"
get_s() {
echo "$1" | grep -oE "S$2=[0-9]+" | cut -d'=' -f2
}
line="$(nc -u -l 6650 -w 5 | grep -oE "S1=.+")"
echo '{"temp":'$(get_s "$line" 1)',"hum":'$(get_s "$line" 2)',"co2":'$(get_s "$line" 3)',"location":"$location"}' > "$output_path"
It should generate file such:
{"temp":25,"hum":32,"co2":452,"location":"room"}
server {
listen 80;
server_name sensors.myhome;
root /path/to/sensors/output_dir;
}
Add to /etc/telegraf/telegraf.conf
:
[[inputs.httpjson]]
servers = [ "http://sensors.myhome/co2-temp-hum-sensor.json" ]
name = "home"
tag_keys = [ "location" ]
Import grafana-sensors-dashboard.json to Grafana.