upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions | Protected Attributes

API for theDFRobot Laser PM2.5 Sensor. More...

Detailed Description

This driver was tested with a DFRobot Laser PM2.5 Sensor. It connects to a UART at 9600 baud. This is the only baud rate supported. It optionally supports Reset and Set/Sleep gpios as well.

// Instantiate a HKA5 sensor on uart 0. We don't use the set or
// reset pins, so we pass -1 for them.
upm::HKA5 sensor(0, -1, -1);
// update once every 2 seconds and output data
while (shouldRun) {
sensor.update();
cout << "PM 1 : " << sensor.getPM1() << " ug/m3" << endl;
cout << "PM 2.5: " << sensor.getPM2_5() << " ug/m3" << endl;
cout << "PM 10 : " << sensor.getPM10() << " ug/m3" << endl;
cout << endl;
upm_delay(2);
}
if (shouldRun)
cerr << "Timed out" << endl;

Public Member Functions

 HKA5 (unsigned int uart, int set_pin, int reset_pin)
 
 ~HKA5 ()
 
void enable (bool enable)
 
void reset ()
 
void update ()
 
unsigned int getPM1 ()
 
unsigned int getPM2_5 ()
 
unsigned int getPM10 ()
 

Protected Attributes

hka5_context m_hka5
 

Constructor & Destructor Documentation

HKA5 ( unsigned int  uart,
int  set_pin,
int  reset_pin 
)

HKA5 object constructor

Parameters
uartSpecify which uart to use.
set_pinSpecify the GPIO pin to use for Set. -1 to not use a set pin.
reset_pinSpecify the GPIO pin to use for Reset. -1 to not use a reset pin.
Returns
an initialized device context on success, NULL on error.
~HKA5 ( )

HKA5 object destructor

Here is the call graph for this function:

Member Function Documentation

void enable ( bool  enable)

Enable or disable the device. When disabled, the device enters a low power mode and does not emit data. You must have initialized and connected the Set pin for this function to work.

Parameters
enabletrue to enable the device, false otherwise.

Here is the call graph for this function:

void reset ( )

Reset the device. You must have initialized and connected the Reset pin for this function to work.

Here is the call graph for this function:

void update ( void  )

Query the device and store the latest values. You must call this function before calling any of the get*() functions.

Here is the call graph for this function:

unsigned int getPM1 ( )

Return the last read PM 1.0 value. The value is in micrograms per cubic meter (ug/m3). You must have called the update() function before calling this function.

Returns
The value in ug/m3

Here is the call graph for this function:

unsigned int getPM2_5 ( )

Return the last read PM 2.5 value. The value is in micrograms per cubic meter (ug/m3). You must have called the update() function before calling this function.

Returns
The value in ug/m3

Here is the call graph for this function:

unsigned int getPM10 ( )

Return the last read PM 10.0 value. The value is in micrograms per cubic meter (ug/m3). You must have called the update() function before calling this function.

Returns
The value in ug/m3

Here is the call graph for this function:

Collaboration diagram for HKA5:
Collaboration graph
[legend]

The documentation for this class was generated from the following files: