upm
0.5.1
Sensor/Actuator repository for libmraa (v0.9.1)
|
API support for the Grove CO2 sensor. More...
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.
Public Member Functions | |
MHZ16 (int uart) | |
~MHZ16 () | |
bool | dataAvailable (unsigned int millis) |
int | readData (char *buffer, int len) |
int | writeData (char *buffer, int len) |
bool | setupTty (speed_t baud=B9600) |
bool | verifyPacket (uint8_t *pkt, int len) |
bool | getData () |
int | getGas () |
int | getTemperature () |
void | calibrateZeroPoint () |
Protected Member Functions | |
int | ttyFd () |
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. |
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 |
int writeData | ( | char * | buffer, |
int | len | ||
) |
Writes the data in the buffer to the device
buffer | Buffer to hold the data read |
len | Length of the buffer |
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. |
bool verifyPacket | ( | uint8_t * | pkt, |
int | len | ||
) |
Verifies the packet header and indicates its validity
pkt | Packet to check |
bool getData | ( | ) |
Queries the sensor and gets the gas (CO2) concentration and temperature data. Should be called before other "get" functions.
int getGas | ( | ) |
Returns the gas (CO2) concentration data.
int getTemperature | ( | void | ) |
Returns the temperature data.
void calibrateZeroPoint | ( | ) |
Sets the zero point of the sensor