UPM

The UPM API is a high level sensor library for IoT devices using MRAA. See examples here. Back to index page.
SparkFun sensor images provided under CC BY-NC-SA-3.0.

MHZ16 Class

Module: mhz16

This class implements support for the Grove CO2 sensor.
Its CO2 detection range is 0-2,000 ppm. It requires a 2-3 minute warm-up time before reporting valid data.
mhz16.jpg

Methods

MHZ16

(
  • uart
)
Number

MHZ16 constructor

Parameters:

  • uart Number

    Default mraa UART index to use

Returns:

Number:

MHZ16

(
  • uart_raw
)
Number

MHZ16 constructor

Parameters:

  • uart_raw Const std::string *

    Full path to UART device.

Returns:

Number:

dataAvailable

(
  • millis
)
Boolean

Checks to see if there is data available for reading

Parameters:

  • millis Number

    Number of milliseconds to wait; 0 means no waiting.

Returns:

Boolean:

True if there is data available for reading

readData

(
  • buffer
  • len
)
Number

Reads any available data in a user-supplied buffer. Note: the call blocks until data is available to be read. Use dataAvailable() to determine whether there is data available beforehand, to avoid blocking.

Parameters:

  • buffer String

    Buffer to hold the data read

  • len Number

    Length of the buffer

Returns:

Number:

Number of bytes read

writeData

(
  • buffer
  • len
)
Number

Writes the data in the buffer to the device

Parameters:

  • buffer String

    Buffer to hold the data read

  • len Number

    Length of the buffer

Returns:

Number:

Number of bytes written

setupTty

(
  • baud
)
Boolean

Sets up proper tty I/O modes and the baud rate. The default baud rate is 9,600 (B9600).

Parameters:

  • baud Speed_t

    Desired baud rate.

Returns:

Boolean:

True if successful

verifyPacket

(
  • pkt
  • len
)
Boolean

Verifies the packet header and indicates its validity

Parameters:

  • pkt Uint8_t *

    Packet to check

  • len Number

    undefined

Returns:

Boolean:

True if the checksum is valid, false otherwise

getData

() Boolean

Queries the sensor and gets the gas (CO2) concentration and temperature data. Should be called before other "get" functions.

Returns:

Boolean:

True if successful

getGas

() Number

Returns the gas (CO2) concentration data.

Returns:

Number:

Gas concentration

getTemperature

() Number

Returns the temperature data.

Returns:

Number:

Temperature in Celsius

calibrateZeroPoint

()

Sets the zero point of the sensor