Contributed Driver: MH-Z16 I2C NDIR CO2 Sensor

  • The MH-Z16 CO2 sensor from Sandbox Electronics is visible at It offers rapid response and good accuracy. The part is similar to and based on the one sold by Winsen Electronics, but has been modified by Sandbox to be more easily calibrated, among other enhancements. I am using it to control ventilation in a greenhouse to make sure that there is enough fresh air supplied. It can also be used to enable CO2 supplementation. In the process of testing it, I found that my indoor CO2 was reaching unhealthy levels in my house!

    Sandbox offers an Arduino C++ driver which I converted to C-like REXLANG and tested extensively. The unit is very usable inside Rexygen on a Raspberry Pi, and includes a triggerable self-calibration function that coupled with Rexygen's live start from flash allows you to carry the unit outside for unattended calibration. myproject_exec.mdl - REXYGEN Studio - [io_task _] .png Block properties 2020-05-05 00.29.43.png

    Source files for download:

  • Hello,
    thanks for another contribution!

    Why not use the MP block for starting the calibration procedure?

    Minor note: We always recommend keeping the block name for clarity and "readability" of the algorithm. I'd go for "REXLANG_MHZ16" in this case.

    Thanks again,