MHZ16 Class
- ID: mhz16
- Name: CO2 Sensor
- Other Names: MHZ16 Serial CO2 Sensor
- Category: gaseous
- Manufacturer: seeed
- Connection: uart
- Link: http://wiki.seeed.cc/Grove-CO2_Sensor/
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.
Item Index
Methods
MHZ16
-
uart
MHZ16 constructor
Parameters:
-
uart
NumberDefault mraa UART index to use
Returns:
MHZ16
-
uart_raw
MHZ16 constructor
Parameters:
-
uart_raw
Const std::string *Full path to UART device.
Returns:
dataAvailable
-
millis
Checks to see if there is data available for reading
Parameters:
-
millis
NumberNumber of milliseconds to wait; 0 means no waiting.
Returns:
True if there is data available for reading
readData
-
buffer
-
len
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
StringBuffer to hold the data read
-
len
NumberLength of the buffer
Returns:
Number of bytes read
writeData
-
buffer
-
len
Writes the data in the buffer to the device
Parameters:
-
buffer
StringBuffer to hold the data read
-
len
NumberLength of the buffer
Returns:
Number of bytes written
setupTty
-
baud
Sets up proper tty I/O modes and the baud rate. The default baud rate is 9,600 (B9600).
Parameters:
-
baud
Speed_tDesired baud rate.
Returns:
True if successful
verifyPacket
-
pkt
-
len
Verifies the packet header and indicates its validity
Parameters:
-
pkt
Uint8_t *Packet to check
-
len
Numberundefined
Returns:
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:
True if successful
getGas
()
Number
Returns the gas (CO2) concentration data.
Returns:
Gas concentration
getTemperature
()
Number
Returns the temperature data.
Returns:
Temperature in Celsius
calibrateZeroPoint
()
Sets the zero point of the sensor