Tasmota/lib/HPMA115S0/example/example.ino
David Hunt 5130ac4f78 add support for Honeywell HPMA115S0 particle sensor
The Honeywell HPM Series Particulate Matter Sensor is a
    laser-based sensor which detects and counts particles using
    light scattering.

    This commit adds:
      * The HPMA115S0 library by Felix Galindo
      * selectable GPIOs for Tx and Rx (SoftwareSerial only)
      * xsns_55_hpma.ino for Tasmota sensor implementation

    Signed-off-by: David Hunt <dave@davidhunt.ie>
2019-11-05 22:03:07 +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);
}