Adafruit Library
WipperSnapper_I2C_Driver_PM25.h
Go to the documentation of this file.
1 
16 #ifndef WipperSnapper_I2C_Driver_PM25_H
17 #define WipperSnapper_I2C_Driver_PM25_h
18 
20 #include <Adafruit_PM25AQI.h>
21 #include <Wire.h>
22 
23 /**************************************************************************/
27 /**************************************************************************/
29 
30 public:
31  /*******************************************************************************/
39  /*******************************************************************************/
40  WipperSnapper_I2C_Driver_PM25(TwoWire *i2c, uint16_t sensorAddress)
41  : WipperSnapper_I2C_Driver(i2c, sensorAddress) {
42  _i2c = i2c;
43  _sensorAddress = sensorAddress;
44  }
45 
46  /*******************************************************************************/
51  /*******************************************************************************/
52  bool begin() {
53  _pm25 = new Adafruit_PM25AQI();
54 
55  // Wait one second for sensor to boot up!
56  delay(1000);
57 
58  if (!_pm25->begin_I2C(_i2c))
59  return false;
60 
61  return true;
62  }
63 
64  /*******************************************************************************/
72  /*******************************************************************************/
73  bool getEventPM10_STD(sensors_event_t *pm10StdEvent) {
74  PM25_AQI_Data data;
75  if (!_pm25->read(&data))
76  return false; // couldn't read data
77 
78  pm10StdEvent->pm10_std = (float)data.pm10_standard;
79  return true;
80  }
81 
82  /*******************************************************************************/
90  /*******************************************************************************/
91  bool getEventPM25_STD(sensors_event_t *pm25StdEvent) {
92  PM25_AQI_Data data;
93  if (!_pm25->read(&data))
94  return false; // couldn't read data
95 
96  pm25StdEvent->pm25_std = (float)data.pm25_standard;
97  return true;
98  }
99 
100  /*******************************************************************************/
108  /*******************************************************************************/
109  bool getEventPM100_STD(sensors_event_t *pm100StdEvent) {
110  PM25_AQI_Data data;
111  if (!_pm25->read(&data))
112  return false; // couldn't read data
113 
114  pm100StdEvent->pm100_std = (float)data.pm100_standard;
115  return true;
116  }
117 
118 protected:
119  Adafruit_PM25AQI *_pm25;
120 };
121 
122 #endif // WipperSnapper_I2C_Driver_PM25
bool getEventPM100_STD(sensors_event_t *pm100StdEvent)
Gets the PM25 sensor&#39;s PM10.0 STD reading.
Definition: WipperSnapper_I2C_Driver_PM25.h:109
bool begin()
Initializes the PM25 sensor and begins I2C.
Definition: WipperSnapper_I2C_Driver_PM25.h:52
Class that provides a driver interface for the PM25 sensor.
Definition: WipperSnapper_I2C_Driver_PM25.h:28
WipperSnapper_I2C_Driver_PM25(TwoWire *i2c, uint16_t sensorAddress)
Constructor for a PM25 sensor.
Definition: WipperSnapper_I2C_Driver_PM25.h:40
bool getEventPM25_STD(sensors_event_t *pm25StdEvent)
Gets the PM25 sensor&#39;s PM2.5 STD reading.
Definition: WipperSnapper_I2C_Driver_PM25.h:91
Base class for I2C Drivers.
Definition: WipperSnapper_I2C_Driver.h:30
Adafruit_PM25AQI * _pm25
PM25 driver object.
Definition: WipperSnapper_I2C_Driver_PM25.h:119
uint16_t _sensorAddress
The I2C driver&#39;s unique I2C address.
Definition: WipperSnapper_I2C_Driver.h:1322
bool getEventPM10_STD(sensors_event_t *pm10StdEvent)
Gets the PM25 sensor&#39;s PM1.0 STD reading.
Definition: WipperSnapper_I2C_Driver_PM25.h:73
TwoWire * _i2c
Pointer to the I2C driver&#39;s Wire object.
Definition: WipperSnapper_I2C_Driver.h:1321