Giter Site home page Giter Site logo

popstas / nodemcu-co2-temp-hum-grafana Goto Github PK

View Code? Open in Web Editor NEW
8.0 4.0 2.0 137 KB

Temperature, humidity and CO2 in Grafana (NodeMCU, MH-Z19, DHT11) with MQTT and OTA updates

Lua 84.40% Makefile 4.35% C 11.25%
nodemcu dht11 mh-z19 grafana co2 temperature humidity mqtt ota

nodemcu-co2-temp-hum-grafana's Introduction

nodemcu-co2-temp-hum-grafana

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

sensors

Wiring

  • 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

Setup nodemcu

Flash firmware

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.

Set Wifi and MQTT credentials

Copy config-secrets.default.lua to config-secrets.lua and fill your credentials.

Upload

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

Setup other

All docs below is obsolete after @418f481.

I am using it with Grafana, Telegraf and InfluxDB.

Generate json

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"}

Setup nginx

server {
   listen 80;
   server_name sensors.myhome;
   root /path/to/sensors/output_dir;
}

Setup Telegraf

Add to /etc/telegraf/telegraf.conf:

[[inputs.httpjson]]
    servers = [ "http://sensors.myhome/co2-temp-hum-sensor.json" ]
    name = "home"
    tag_keys = [ "location" ]

Setup Grafana

Import grafana-sensors-dashboard.json to Grafana.

nodemcu-co2-temp-hum-grafana's People

Contributors

popstas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.