pyupm_mhz16 module¶
-
class
pyupm_mhz16.
MHZ16
(uart)[source]¶ Bases:
object
API support for the Grove CO2 sensor.
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.
C++ includes: mhz16.hpp
-
dataAvailable
(millis)[source]¶ bool dataAvailable(unsigned int millis)
Checks to see if there is data available for reading
millis: Number of milliseconds to wait; 0 means no waiting.
True if there is data available for reading
-
getData
()[source]¶ bool getData()
Queries the sensor and gets the gas (CO2) concentration and temperature data. Should be called before other “get” functions.
True if successful
-
readData
(buffer, len)[source]¶ int readData(char *buffer, int 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.
buffer: Buffer to hold the data read
len: Length of the buffer
Number of bytes read
-
setupTty
(*args)[source]¶ bool setupTty(speed_t baud=B9600)
Sets up proper tty I/O modes and the baud rate. The default baud rate is 9,600 (B9600).
baud: Desired baud rate.
True if successful
-