nanoFramework.Iot.Device.Mhz19b 1.2.952

Prefix Reserved
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package nanoFramework.Iot.Device.Mhz19b --version 1.2.952
                    
NuGet\Install-Package nanoFramework.Iot.Device.Mhz19b -Version 1.2.952
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="nanoFramework.Iot.Device.Mhz19b" Version="1.2.952" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="nanoFramework.Iot.Device.Mhz19b" Version="1.2.952" />
                    
Directory.Packages.props
<PackageReference Include="nanoFramework.Iot.Device.Mhz19b" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add nanoFramework.Iot.Device.Mhz19b --version 1.2.952
                    
#r "nuget: nanoFramework.Iot.Device.Mhz19b, 1.2.952"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package nanoFramework.Iot.Device.Mhz19b@1.2.952
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=nanoFramework.Iot.Device.Mhz19b&version=1.2.952
                    
Install as a Cake Addin
#tool nuget:?package=nanoFramework.Iot.Device.Mhz19b&version=1.2.952
                    
Install as a Cake Tool

MH-Z19B CO2-Sensor

Binding for the MH-Z19B NDIR infrared gas module. The gas module measures the CO2 gas concentration in the ambient air.

Documentation

MH-Z19b Datasheet

Usage

Important: Make sure you install the nanoFramework.Hardware.ESP32 nuget and properly setup the UART pins especially for ESP32 before creating the Serialport.

The binding can be instantiated using an existing serial UART stream or with the name (e.g. COM2 ) of the serial interface to be used. If using an existing stream shouldDispose indicates whether the stream shall be disposed when the binding gets disposed. If providing the name of the serial interface the connection gets closed and disposed when the binding is disposed.

public Mhz19b(Stream stream, bool shouldDispose)
public Mhz19b(string uartDevice)

The CO2 concentration reading can be retrieved with

public VolumeConcentration GetCo2Reading()

The sample application demonstrates the use of the binding API for sensor calibration.

Note: Refer to the datasheet for more details on sensor calibration before using the calibration API of the binding. You may decalibrate the sensor otherwise!

Binding Notes

The MH-Z19B gas module provides a serial communication interface (UART) which can be directly wired to a ESP32 board. The module is supplied with 5V. The UART level is at 3.3V and no level shifter is required.

Mhz19B_bb

|Function| ESP32Pin| MH-Z19 pin| |--------|-----------|------------| |Vcc +5V |(+5V) |6 (Vin) | |GND |(GND) |7 (GND) | |UART |32 (TXD2) |2 (RXD) | |UART |33 (RXD2) |3 (TXD) | Table: MH-Z19B to ESP32 connection

The binding supports the connection through an UART interface (e.g. ``COM2```) or (serial port) stream. When using the UART interface the binding instantiates the port with the required UART settings and opens it. The use of an existing stream adds flexibility to the actual interface that used with the binding. In either case the binding supports all commands of the module.

Make sure that you read the datasheet carefully before altering the default calibration behaviour. Automatic baseline correction is enabled by default.

An example of the expected output from the sample : ExpectedOutput

Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0-preview.73 38 5/20/2026
2.0.0-preview.62 51 5/13/2026
2.0.0-preview.49 53 5/4/2026
2.0.0-preview.45 53 4/29/2026
2.0.0-preview.32 55 4/20/2026
2.0.0-preview.16 61 3/10/2026
1.2.952 128 3/4/2026
1.2.907 267 10/2/2025
1.2.889 252 7/28/2025
1.2.880 339 4/24/2025
1.2.869 334 4/2/2025
1.2.864 314 4/2/2025
1.2.852 315 3/11/2025
1.2.846 332 3/10/2025
1.2.838 278 3/3/2025
1.2.822 271 2/26/2025
1.2.790 272 2/5/2025
1.2.775 273 2/4/2025
1.2.772 278 2/4/2025
1.2.755 261 1/31/2025
Loading failed