4#include "../Data/RollingAverage.h"
5#include "../Data/SensorLevels.h"
54 PMS5003(
const std::string& devicePath);
79 virtual void TurnOn()
override;
91 virtual void TurnOff()
override;
136 virtual bool IsDataValid(
const float* dataToValidate,
const size_t bufferSize)
const;
167 virtual std::string
DetermineAirQuality(
const float pmTwoPointFiveReading,
const float pmTenReading)
const;
248 virtual std::string
ToString()
const override;
Abstract base class for every component (sensor, actuator, etc.) the library manages.
Definition: BaseComponent.h:60
PMS5003 particulate-matter (dust) sensor read over serial, reporting PM1.0/PM2.5/PM10 concentrations,...
Definition: PMS5003.h:22
RollingAverage myAverageNumberOfParticlesLargerThanZeroPointFiveMicronDiameter
Rolling average of particles > 0.5um.
Definition: PMS5003.h:34
float GetPMOneAtmospheric() const
Gets the atmospheric PM1.0 concentration.
Definition: PMS5003.cpp:628
RollingAverage myAverageNumberOfParticlesLargerThanTenMicronDiameter
Rolling average of particles > 10um.
Definition: PMS5003.h:38
float GetPMTwoPointFiveAverageFactory() const
Gets the rolling average of the factory-calibrated PM2.5 concentration.
Definition: PMS5003.cpp:577
float GetPMTenFactory() const
Gets the factory-calibrated PM10 concentration.
Definition: PMS5003.cpp:594
float GetNumberOfParticlesLargerThanOneMicronDiameter() const
Gets the number of particles larger than 1um in diameter.
Definition: PMS5003.cpp:804
virtual E_AirQualityLevel CalculateAirQualitySeverity() const
Maps the current average PM2.5 and PM10 readings onto a 0 (good) to 5 (hazardous) severity,...
Definition: PMS5003.cpp:289
PMS5003(const std::string &devicePath)
Builds a PMS5003 for the given serial device path, seeding its data map so each reading updates in pl...
Definition: PMS5003.cpp:19
float GetAverageNumberOfParticlesLargerThanTwoPointFiveMicronDiameter() const
Gets the rolling average of the number of particles larger than 2.5um in diameter.
Definition: PMS5003.cpp:855
RollingAverage myAverageNumberOfParticlesLargerThanZeroPointThreeMicronDiameter
Rolling average of particles > 0.3um.
Definition: PMS5003.h:33
std::map< std::string, float > myDustData
Most recent raw readings, keyed by measurement name.
Definition: PMS5003.h:39
float GetNumberOfParticlesLargerThanFiveMicronDiameter() const
Gets the number of particles larger than 5um in diameter.
Definition: PMS5003.cpp:872
virtual int ReadRawValue()
Reads a single raw byte from the serial device.
Definition: PMS5003.cpp:121
float GetAverageNumberOfParticlesLargerThanTenMicronDiameter() const
Gets the rolling average of the number of particles larger than 10um in diameter.
Definition: PMS5003.cpp:923
virtual void TurnOff() override
Closes the serial device (if open) and marks the sensor stopped.
Definition: PMS5003.cpp:98
float GetNumberOfParticlesLargerThanZeroPointThreeMicronDiameter() const
Gets the number of particles larger than 0.3um in diameter.
Definition: PMS5003.cpp:736
virtual std::string ToString() const override
Serializes every current reading and rolling average (PM concentrations, particle counts) plus the ai...
Definition: PMS5003.cpp:941
float GetPMOneAverageFactory() const
Gets the rolling average of the factory-calibrated PM1.0 concentration.
Definition: PMS5003.cpp:543
float GetPMOneFactory() const
Gets the factory-calibrated PM1.0 concentration.
Definition: PMS5003.cpp:526
RollingAverage myAverageNumberOfParticlesLargerThanFiveMicronDiameter
Rolling average of particles > 5um.
Definition: PMS5003.h:37
float GetPMTwoPointFiveAtmospheric() const
Gets the atmospheric PM2.5 concentration.
Definition: PMS5003.cpp:662
int mySerialDeviceFileDescriptor
The open serial device file descriptor.
Definition: PMS5003.h:25
RollingAverage myPMTenAverageAtmospheric
Rolling average of the atmospheric PM10 reading.
Definition: PMS5003.h:32
virtual void TurnOn() override
Opens the serial device at 9600 baud and marks the sensor running, reporting the result through the A...
Definition: PMS5003.cpp:73
float GetPMTenAverageAtmospheric() const
Gets the rolling average of the atmospheric PM10 concentration.
Definition: PMS5003.cpp:719
float GetPMTenAverageFactory() const
Gets the rolling average of the factory-calibrated PM10 concentration.
Definition: PMS5003.cpp:611
float GetPMTenAtmospheric() const
Gets the atmospheric PM10 concentration.
Definition: PMS5003.cpp:702
RollingAverage myPMTwoPointFiveAverageFactory
Rolling average of the factory-calibrated PM2.5 reading.
Definition: PMS5003.h:28
RollingAverage myPMTwoPointFiveAverageAtmospheric
Rolling average of the atmospheric PM2.5 reading.
Definition: PMS5003.h:31
float GetNumberOfParticlesLargerThanZeroPointFiveMicronDiameter() const
Gets the number of particles larger than 0.5um in diameter.
Definition: PMS5003.cpp:770
RollingAverage myPMOneAverageAtmospheric
Rolling average of the atmospheric PM1.0 reading.
Definition: PMS5003.h:30
virtual std::string DetermineAirQualityCategory() const
Gets the short air-quality category name for the current average readings.
Definition: PMS5003.cpp:385
float GetPMTwoPointFiveFactory() const
Gets the factory-calibrated PM2.5 concentration.
Definition: PMS5003.cpp:560
RollingAverage myAverageNumberOfParticlesLargerThanTwoPointFiveMicronDiameter
Rolling average of particles > 2.5um.
Definition: PMS5003.h:36
bool myIsRunning
True while the serial device is open and readable.
Definition: PMS5003.h:24
virtual std::string DetermineAirQuality() const
Gets the full air-quality advisory text (quality, at-risk groups, and guidance) for the current avera...
Definition: PMS5003.cpp:456
float GetAverageNumberOfParticlesLargerThanZeroPointThreeMicronDiameter() const
Gets the rolling average of the number of particles larger than 0.3um in diameter.
Definition: PMS5003.cpp:753
virtual void ProcessRawValues() override
Reads and validates a serial frame (retrying up to RUMPI_MAX_READ_ATTEMPTS), decodes the PM1....
Definition: PMS5003.cpp:180
RollingAverage myPMOneAverageFactory
Rolling average of the factory-calibrated PM1.0 reading.
Definition: PMS5003.h:27
float GetNumberOfParticlesLargerThanTenMicronDiameter() const
Gets the number of particles larger than 10um in diameter.
Definition: PMS5003.cpp:906
float GetAverageNumberOfParticlesLargerThanOneMicronDiameter() const
Gets the rolling average of the number of particles larger than 1um in diameter.
Definition: PMS5003.cpp:821
virtual ~PMS5003()
Destroys the sensor, turning it off first.
Definition: PMS5003.cpp:58
std::string myDevicePath
The serial device path.
Definition: PMS5003.h:26
float GetAverageNumberOfParticlesLargerThanFiveMicronDiameter() const
Gets the rolling average of the number of particles larger than 5um in diameter.
Definition: PMS5003.cpp:889
RollingAverage myPMTenAverageFactory
Rolling average of the factory-calibrated PM10 reading.
Definition: PMS5003.h:29
RollingAverage myAverageNumberOfParticlesLargerThanOneMicronDiameter
Rolling average of particles > 1um.
Definition: PMS5003.h:35
virtual bool IsDataValid(const float *dataToValidate, const size_t bufferSize) const
Validates a serial frame by summing all bytes except the trailing two and comparing against the big-e...
Definition: PMS5003.cpp:142
float GetNumberOfParticlesLargerThanTwoPointFiveMicronDiameter() const
Gets the number of particles larger than 2.5um in diameter.
Definition: PMS5003.cpp:838
float GetAverageNumberOfParticlesLargerThanZeroPointFiveMicronDiameter() const
Gets the rolling average of the number of particles larger than 0.5um in diameter.
Definition: PMS5003.cpp:787
float GetPMTwoPointFiveAverageAtmospheric() const
Gets the rolling average of the atmospheric PM2.5 concentration.
Definition: PMS5003.cpp:679
float GetPMOneAverageAtmospheric() const
Gets the rolling average of the atmospheric PM1.0 concentration.
Definition: PMS5003.cpp:645
Maintains a rolling (moving) average over a fixed-length window of recent readings using a circular b...
Definition: RollingAverage.h:14
RumPi is the library's top-level facade.
Definition: AlertManager.h:6
E_AirQualityLevel
How bad the air is, best to worst, taking whichever of PM2.5 / PM10 is worse.
Definition: SensorLevels.h:34