Giter VIP home page Giter VIP logo

mhz16_uart's Introduction

MHZ16_uart

Arduino IDE library for the MH-Z16 CO₂ sensor. Tested with ESP32 but might just work for Arduino too.

Version 0.1

Credits and License

By: Intar BV

Based on: https://github.com/nara256/mhz19_uart

License: MIT

Usage

  1. Add this library to your Arduino IDE's libraries folder.

  2. Include the library in your program

  3. Connect your MH-Z16 sensor to your ESP32

    MH-Z16 Vcc to 5V power supply
    MH-Z16 GND to common GND
    MH-Z16 Tx to ESP32 GPIO pin to use as Rx
    MH-Z16 Rx to ESP32 GPIO pin to use as Tx
    Other MH-Z16 pins are not supported

  4. Upload your program to the ESP32

Warnings

This library only supports serial UART communication with the MH-Z16.

This library has only been tested on ESP32S.

The isWarming() function does not indicate whether the MH-Z16 is warming up.

Reference

MHZ16_uart()

Default constructor. You must call begin(int rx, int tx) before you can use the MH-Z16

MHZ16_uart(int rx, int tx)

Constructor that sets Rx and Tx pin, and initialises the serial interface.

void begin(int rx, int tx)

Set the Rx and Tx pin, and initialise the serial interface.

void calibrateZero()

Calibrate the zero-point. According to the documentation the MH-Z16 sensor must have been working in a stable gas environment with a CO₂ concentration of 400ppm for 20 minutes before you call this function.

void calibrateSpan(int ppm)

Calibrate the span point. According to the documentation the MH-Z16 sensor must have been working in a stable gas environment with a CO₂ concentration of ppm for 20 minutes before you call this function.

int getPPM()

Read the CO₂ concentration in PPM from the sensor. On a read error the return value is -1.

bool isWarming()

The return value indicates whether the documenation mandated 3 minutes of warm-up time have passed since the call to either MHZ16_uart(int rx, int tx) or begin(int rx, int tx).
Caution: This is not a value read from the MH-Z16

MH-Z16 Datasheet

http://www.winsen-sensor.com/d/files/PDF/Infrared%20Gas%20Sensor/NDIR%20CO2%20SENSOR/MH-Z16%20CO2%20V2.1.pdf

Change log

Version 0.1

First release

mhz16_uart's People

Contributors

ghostbird avatar

Stargazers

eueduardo3 avatar Ondřej Diok avatar Stif avatar  avatar

Watchers

James Cloos avatar  avatar Roel Bruins avatar eueduardo3 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.