Skip to content

Simple example python/js solution to monitor CO2 concentration using MH-Z14 sensor connected with UART.

Notifications You must be signed in to change notification settings

TMillesich/MHZ14-CO2-Logger

 
 

Repository files navigation

Example MH-Z14 CO2 sensor reader and visualizer

  • Read data from UART(serial)-connected MH-Z14 sensor using python,
  • visualize received data using html and plotly.js library.

Screenshot of example data

example

(peak at 6:50 AM is when my cat walked over my desktop and probably sniffed the sensor)

Usage

Connection

Sensor can be queried using 3.3v UART at 9600 bps. Sensor main feed voltage is 5v.

Can be connected to computer using almost any USB-UART converter if voltage matches.

Querying

$ python CO2Reader.py /dev/ttyUSB0 10
Connected to /dev/ttyUSB0
2016-03-25 22:04:16     1134    69
...

4 fields separated by tab: timestamp, CO2 concentration (ppm), internal sensor temperature (celsius?), checksum validation result

python script and library is expecting python 3.7+ and has dependency on pyserial 3.4 (may be installed via pip)

Use stream redirection to save data series to file.

$ python CO2Reader.py /dev/ttyUSB0 >example.log

Visualizing

  • install npm dependencies npm install
  • start server python -m SimpleHTTPServer 8088
  • open browser at http://localhost:8088/plot.html
  • select your log file in input field

Licence

MIT licence

About

Simple example python/js solution to monitor CO2 concentration using MH-Z14 sensor connected with UART.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 61.3%
  • JavaScript 21.7%
  • HTML 17.0%