David Hunt fd4e1995bc extend Honeywell HPMA driver for compact devices
The HPMA115C0-xxx is a new series of devices than has a
slightly different (longer) response than the HPMA115S0-xxx

THis patch keeps the same API as the original library and
picks out the PM2.5 and PM10 reading from the new response
format.

The patch also changes a const change to be more in line with
the upstream library for future rebases.

This change has also been merge-requested into the upstream
library.

Signed-off-by: David Hunt <dave@davidhunt.ie>
2019-11-16 11:00:32 +00:00

34 lines
804 B
C++

/**
* @file example.ino
* @author Felix Galindo
* @date June 2017
* @brief Example using HPMA115S0 sensor library on a Feather 32u4
* @license MIT
*/
#include <hpma115S0.h>
#include <SoftwareSerial.h>
//Create an instance of software serial
SoftwareSerial hpmaSerial(10, 11); // Feather TX, Feather RX
//Create an instance of the hpma115S0 library
HPMA115S0 hpma115S0(hpmaSerial);
void setup() {
Serial.begin(57600);
hpmaSerial.begin(9600);
delay(5000);
Serial.println("Starting...");
hpma115S0.Init();
hpma115S0.StartParticleMeasurement();
}
void loop() {
unsigned int pm2_5, pm10;
if (hpma115S0.ReadParticleMeasurement(&pm2_5, &pm10)) {
Serial.println("PM 2.5: " + String(pm2_5) + " ug/m3" );
Serial.println("PM 10: " + String(pm10) + " ug/m3" );
}
delay(1000);
}