Coder Social home page Coder Social logo

co2-monitor-mhz19-ssd1306's Introduction

CO₂ Monitor

This repository contains NodeMCU Lua source code for an MH-Z19 based CO₂ monitor. It shows the current CO₂ concentration and MH-Z19 temperature on a 128×32 SSD1306 OLED and makes them available to Home Assistant via MQTT. It can also publish readings to InfluxDB.

Features

  • Display for CO₂ and temperature
  • Home Assistant integration via MQTT
  • Optional logging to InfluxDB
  • Powered via USB

Components

  • Processor: ESP8266
  • CO₂ sensor: MH-Z19
  • Display: 128×32 OLED via SSD1306 (128×64 also supported with some changes)

Flashing

This repository contains a NodeMCU build that provides the required modules. You can flash it using e.g. esptool:

esptool write_flash 0x00000 firmware/nodemcu-release-13-modules-2022-04-17-19-03-07-integer.bin

After flashing, the firmware will need a few seconds to initialize the filesystem. You can use that time to create config.lua (see below) and then flash the Python code, e.g. using nodemcu-uploader:

ext/nodemcu-uploader/nodemcu-uploader.py upload *.lua

Afterwards, you can check whether everything works using the serial connection, e.g.

pyserial-miniterm --dtr 0 --rts 0 /dev/ttyUSB0 115200

You may need to adjust the /dev/tty device name.

Configuration

WiFi, Home Assistant, and InfluxDB configuration is read from src/config.lua. You will need the following entries.

WiFi

Assuming ESSID "foo" and PSK "bar". WPA2 Enterprise is not supported. Leave out the psk for open WiFi.

station_cfg = {ssid = "foo", pwd = "bar"}

MQTT

The only configurable entity is the hostname of the MQTT broker. The ESP8266 will register itself as homeassistant/sensor/esp8266_XXXXXX with the last six digits representing its WiFi MAC address.

mqtt_host = "mqtt.example.org"

InfluxDB

These settings are optional. Specify a URL and attributes in order to enable InfluxDB publishing. For instance, if measurements should be stored as mh_z19,location=lounge in the sensors database on https://influxdb.example.org, the configuration is as follows.

influx_url = 'https://influxdb.example.org/write?db=sensors'
influx_attr = ',location=lounge'

You can also use the esp8266_XXXXXX device id here, like so:

influx_url = 'https://influxdb.example.org/write?db=sensors'
influx_attr = ',location=' .. device_id

Optionally, you can set influx_header to an HTTP header that is passed as part of the POST request to InfluxDB.

Images

Resources

Mirrors of this repository are maintained at the following locations:

co2-monitor-mhz19-ssd1306's People

Contributors

derf avatar

Watchers

 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.