|
upm
0.2.0
Sensor/Actuator repository for libmraa (v0.6.1)
|
C++ API support for the Grove CO2 sensor. More...
This class implements support for the Grove CO2 sensor.
It's CO2 detection ranges from 0PPM to 2000PPM. 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, size_t len) |
| int | writeData (char *buffer, size_t len) |
| bool | setupTty (speed_t baud=B9600) |
| bool | verifyPacket (unsigned char *pkt) |
| bool | getData (int *gas, int *temp) |
| void | calibrateZeroPoint () |
Protected Member Functions | |
| int | ttyFd () |
| int | setTtyFd (int fd) |
| bool dataAvailable | ( | unsigned int | millis | ) |
Check to see if there is data available for reading
| millis | number of milliseconds to wait, 0 means no wait. |
| int readData | ( | char * | buffer, |
| size_t | len | ||
| ) |
read any available data into a user-supplied buffer. Note, the call will block until data is available to be read. Use dataAvailable() to determine whether there is data available beforehand, to avoid blocking.
| buffer | the buffer to hold the data read |
| len | the length of the buffer |
| int writeData | ( | char * | buffer, |
| size_t | len | ||
| ) |
write the data in buffer to the device
| buffer | the buffer to hold the data read |
| len | the length of the buffer |
| bool setupTty | ( | speed_t | baud = B9600 | ) |
setup the proper tty i/o modes and the baudrate. The default baud rate is 9600 (B9600).
| baud | the desired baud rate. |
| bool verifyPacket | ( | unsigned char * | pkt | ) |
verify the packet header and indicate it's validity
| pkt | the packet to check |
| bool getData | ( | int * | gas, |
| int * | temp | ||
| ) |
Query the sensor and return gas (CO2) concentration and temperature data.
| gas | the returned gas concentration |
| temp | the returned temperature in celsius |
| void calibrateZeroPoint | ( | ) |
Set the zero point of the sensor
1.8.9.1