|
upm
0.4.0
Sensor/Actuator repository for libmraa (v0.8.0)
|
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 *gas, int *temp) |
| void | calibrateZeroPoint () |
Protected Member Functions | |
| int | ttyFd () |
| int | setTtyFd (int fd) |
| 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 | ( | int * | gas, |
| int * | temp | ||
| ) |
Queries the sensor and returns gas (CO2) concentration and temperature data.
| gas | Returned gas concentration |
| temp | Returned temperature in Celsius |
| void calibrateZeroPoint | ( | ) |
Sets the zero point of the sensor
1.8.9.1