RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
RumPi::PMS5003 Class Reference

PMS5003 particulate-matter (dust) sensor read over serial, reporting PM1.0/PM2.5/PM10 concentrations, particle counts by diameter, rolling averages, and an air-quality evaluation. More...

#include <PMS5003.h>

Inheritance diagram for RumPi::PMS5003:
[legend]
Collaboration diagram for RumPi::PMS5003:
[legend]

Public Member Functions

 PMS5003 (const std::string &devicePath)
 Builds a PMS5003 for the given serial device path, seeding its data map so each reading updates in place. More...
 
virtual ~PMS5003 ()
 Destroys the sensor, turning it off first. More...
 
virtual void TurnOn () override
 Opens the serial device at 9600 baud and marks the sensor running, reporting the result through the AlertManager. More...
 
virtual void TurnOff () override
 Closes the serial device (if open) and marks the sensor stopped. More...
 
virtual int ReadRawValue ()
 Reads a single raw byte from the serial device. More...
 
virtual void ProcessRawValues () override
 Reads and validates a serial frame (retrying up to RUMPI_MAX_READ_ATTEMPTS), decodes the PM1.0/PM2.5/PM10 concentrations and particle counts from their big-endian byte pairs, and feeds each into its rolling average. More...
 
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-endian checksum those two bytes carry. More...
 
virtual std::string DetermineAirQuality () const
 Gets the full air-quality advisory text (quality, at-risk groups, and guidance) for the current average readings. More...
 
virtual std::string DetermineAirQuality (const float pmTwoPointFiveReading, const float pmTenReading) const
 Gets the full air-quality advisory text (quality, at-risk groups, and guidance) for given PM2.5 and PM10 readings. More...
 
virtual std::string DetermineAirQualityCategory () const
 Gets the short air-quality category name for the current average readings. More...
 
virtual std::string DetermineAirQualityCategory (const float pmTwoPointFiveReading, const float pmTenReading) const
 Gets the short form of the air-quality evaluation - just the category name, for compact UI labels such as the Home scene pill. More...
 
virtual E_AirQualityLevel CalculateAirQualitySeverity () const
 Maps the current average PM2.5 and PM10 readings onto a 0 (good) to 5 (hazardous) severity, taking whichever of the two is worse. More...
 
virtual E_AirQualityLevel CalculateAirQualitySeverity (const float pmTwoPointFiveReading, const float pmTenReading) const
 Maps given PM2.5 and PM10 readings onto a 0 (good) to 5 (hazardous) severity, bucketing each against its own thresholds and returning the worse of the two. More...
 
virtual std::string ToString () const override
 Serializes every current reading and rolling average (PM concentrations, particle counts) plus the air-quality evaluation to a string. More...
 
float GetPMOneFactory () const
 Gets the factory-calibrated PM1.0 concentration. More...
 
float GetPMOneAverageFactory () const
 Gets the rolling average of the factory-calibrated PM1.0 concentration. More...
 
float GetPMTwoPointFiveFactory () const
 Gets the factory-calibrated PM2.5 concentration. More...
 
float GetPMTwoPointFiveAverageFactory () const
 Gets the rolling average of the factory-calibrated PM2.5 concentration. More...
 
float GetPMTenFactory () const
 Gets the factory-calibrated PM10 concentration. More...
 
float GetPMTenAverageFactory () const
 Gets the rolling average of the factory-calibrated PM10 concentration. More...
 
float GetPMOneAtmospheric () const
 Gets the atmospheric PM1.0 concentration. More...
 
float GetPMOneAverageAtmospheric () const
 Gets the rolling average of the atmospheric PM1.0 concentration. More...
 
float GetPMTwoPointFiveAtmospheric () const
 Gets the atmospheric PM2.5 concentration. More...
 
float GetPMTwoPointFiveAverageAtmospheric () const
 Gets the rolling average of the atmospheric PM2.5 concentration. More...
 
float GetPMTenAtmospheric () const
 Gets the atmospheric PM10 concentration. More...
 
float GetPMTenAverageAtmospheric () const
 Gets the rolling average of the atmospheric PM10 concentration. More...
 
float GetNumberOfParticlesLargerThanZeroPointThreeMicronDiameter () const
 Gets the number of particles larger than 0.3um in diameter. More...
 
float GetAverageNumberOfParticlesLargerThanZeroPointThreeMicronDiameter () const
 Gets the rolling average of the number of particles larger than 0.3um in diameter. More...
 
float GetNumberOfParticlesLargerThanZeroPointFiveMicronDiameter () const
 Gets the number of particles larger than 0.5um in diameter. More...
 
float GetAverageNumberOfParticlesLargerThanZeroPointFiveMicronDiameter () const
 Gets the rolling average of the number of particles larger than 0.5um in diameter. More...
 
float GetNumberOfParticlesLargerThanOneMicronDiameter () const
 Gets the number of particles larger than 1um in diameter. More...
 
float GetAverageNumberOfParticlesLargerThanOneMicronDiameter () const
 Gets the rolling average of the number of particles larger than 1um in diameter. More...
 
float GetNumberOfParticlesLargerThanTwoPointFiveMicronDiameter () const
 Gets the number of particles larger than 2.5um in diameter. More...
 
float GetAverageNumberOfParticlesLargerThanTwoPointFiveMicronDiameter () const
 Gets the rolling average of the number of particles larger than 2.5um in diameter. More...
 
float GetNumberOfParticlesLargerThanFiveMicronDiameter () const
 Gets the number of particles larger than 5um in diameter. More...
 
float GetAverageNumberOfParticlesLargerThanFiveMicronDiameter () const
 Gets the rolling average of the number of particles larger than 5um in diameter. More...
 
float GetNumberOfParticlesLargerThanTenMicronDiameter () const
 Gets the number of particles larger than 10um in diameter. More...
 
float GetAverageNumberOfParticlesLargerThanTenMicronDiameter () const
 Gets the rolling average of the number of particles larger than 10um in diameter. More...
 
- Public Member Functions inherited from RumPi::BaseComponent
 BaseComponent ()
 Builds a base component with an unknown type and an empty name. More...
 
virtual ~BaseComponent ()
 Virtual destructor so deleting a component through a BaseComponent* also cleans up the concrete subclass. More...
 
virtual void TurnOn ()=0
 Turns the component on (e.g. More...
 
virtual void TurnOff ()=0
 Turns the component off. More...
 
virtual std::string ToString () const =0
 Serializes the component's current readings to a string (usually JSON). More...
 
virtual void ProcessRawValues ()=0
 Reads and processes the component's latest raw values (called once per poll). More...
 
virtual EComponentType GetComponentType () const
 Gets the component's type. More...
 
const std::string & GetName () const
 Gets the component's unique per-instance name. More...
 
void SetName (const std::string &name)
 Sets the component's unique per-instance name. More...
 

Protected Attributes

bool myIsRunning
 True while the serial device is open and readable. More...
 
int mySerialDeviceFileDescriptor
 The open serial device file descriptor. More...
 
std::string myDevicePath
 The serial device path. More...
 
RollingAverage myPMOneAverageFactory
 Rolling average of the factory-calibrated PM1.0 reading. More...
 
RollingAverage myPMTwoPointFiveAverageFactory
 Rolling average of the factory-calibrated PM2.5 reading. More...
 
RollingAverage myPMTenAverageFactory
 Rolling average of the factory-calibrated PM10 reading. More...
 
RollingAverage myPMOneAverageAtmospheric
 Rolling average of the atmospheric PM1.0 reading. More...
 
RollingAverage myPMTwoPointFiveAverageAtmospheric
 Rolling average of the atmospheric PM2.5 reading. More...
 
RollingAverage myPMTenAverageAtmospheric
 Rolling average of the atmospheric PM10 reading. More...
 
RollingAverage myAverageNumberOfParticlesLargerThanZeroPointThreeMicronDiameter
 Rolling average of particles > 0.3um. More...
 
RollingAverage myAverageNumberOfParticlesLargerThanZeroPointFiveMicronDiameter
 Rolling average of particles > 0.5um. More...
 
RollingAverage myAverageNumberOfParticlesLargerThanOneMicronDiameter
 Rolling average of particles > 1um. More...
 
RollingAverage myAverageNumberOfParticlesLargerThanTwoPointFiveMicronDiameter
 Rolling average of particles > 2.5um. More...
 
RollingAverage myAverageNumberOfParticlesLargerThanFiveMicronDiameter
 Rolling average of particles > 5um. More...
 
RollingAverage myAverageNumberOfParticlesLargerThanTenMicronDiameter
 Rolling average of particles > 10um. More...
 
std::map< std::string, float > myDustData
 Most recent raw readings, keyed by measurement name. More...
 
- Protected Attributes inherited from RumPi::BaseComponent
EComponentType myComponentType
 The kind of component this is (set by each concrete subclass). More...
 
std::string myName
 A unique per-instance name, assigned when the component is added to the manager. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from RumPi::BaseComponent
static std::string ComponentTypeToString (const EComponentType theComponentTypeToConvert)
 Maps an EComponentType to its string name. More...
 
static EComponentType StringToComponentType (const std::string &theComponentTypeName)
 Maps a type name back to its EComponentType (the inverse of ComponentTypeToString), so the client can turn the type carried on the wire back into a value it can look an icon up with. More...
 

Detailed Description

PMS5003 particulate-matter (dust) sensor read over serial, reporting PM1.0/PM2.5/PM10 concentrations, particle counts by diameter, rolling averages, and an air-quality evaluation.

References: https://www.health.ny.gov/environmental/indoors/air/pmq_a.htm https://www.airveda.com/blog/Understanding-Particulate-Matter-and-Its-Associated-Health-Impact https://ioct.tech/edu/sites/default/files/2019-04/PMS5003-Informational.pdf

Author
Eddie O'Hagan
Date
8/13/2026

Constructor & Destructor Documentation

◆ PMS5003()

RumPi::PMS5003::PMS5003 ( const std::string &  devicePath)

Builds a PMS5003 for the given serial device path, seeding its data map so each reading updates in place.

Author
Eddie O'Hagan
Date
8/13/2026
PMS5003 dustSensor("/dev/serial0");
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
Parameters
[in]devicePathThe serial device path the sensor is connected to.

◆ ~PMS5003()

RumPi::PMS5003::~PMS5003 ( )
virtual

Destroys the sensor, turning it off first.

Author
Eddie O'Hagan
Date
8/13/2026
PMS5003* dustSensor = new PMS5003("/dev/serial0");
delete dustSensor;

Member Function Documentation

◆ CalculateAirQualitySeverity() [1/2]

E_AirQualityLevel RumPi::PMS5003::CalculateAirQualitySeverity ( ) const
virtual

Maps the current average PM2.5 and PM10 readings onto a 0 (good) to 5 (hazardous) severity, taking whichever of the two is worse.

Both the short category and the full advisory text derive from this, so the thresholds live in exactly one place.

Author
Eddie O'Hagan
Date
8/13/2026
E_AirQualityLevel severity = dustSensor.CalculateAirQualitySeverity();
E_AirQualityLevel
How bad the air is, best to worst, taking whichever of PM2.5 / PM10 is worse.
Definition: SensorLevels.h:34
Returns
The worse of the PM2.5 and PM10 severity levels.

◆ CalculateAirQualitySeverity() [2/2]

E_AirQualityLevel RumPi::PMS5003::CalculateAirQualitySeverity ( const float  pmTwoPointFiveReading,
const float  pmTenReading 
) const
virtual

Maps given PM2.5 and PM10 readings onto a 0 (good) to 5 (hazardous) severity, bucketing each against its own thresholds and returning the worse of the two.

Author
Eddie O'Hagan
Date
8/13/2026
E_AirQualityLevel severity = dustSensor.CalculateAirQualitySeverity(35.0f, 60.0f);
Parameters
[in]pmTwoPointFiveReadingThe PM2.5 reading to evaluate.
[in]pmTenReadingThe PM10 reading to evaluate.
Returns
The worse of the PM2.5 and PM10 severity levels.

◆ DetermineAirQuality() [1/2]

std::string RumPi::PMS5003::DetermineAirQuality ( ) const
virtual

Gets the full air-quality advisory text (quality, at-risk groups, and guidance) for the current average readings.

Author
Eddie O'Hagan
Date
8/13/2026
std::string advisory = dustSensor.DetermineAirQuality();
Returns
The full air-quality advisory text.

◆ DetermineAirQuality() [2/2]

std::string RumPi::PMS5003::DetermineAirQuality ( const float  pmTwoPointFiveReading,
const float  pmTenReading 
) const
virtual

Gets the full air-quality advisory text (quality, at-risk groups, and guidance) for given PM2.5 and PM10 readings.

Author
Eddie O'Hagan
Date
8/13/2026
std::string advisory = dustSensor.DetermineAirQuality(35.0f, 60.0f);
Parameters
[in]pmTwoPointFiveReadingThe PM2.5 reading to evaluate.
[in]pmTenReadingThe PM10 reading to evaluate.
Returns
The full air-quality advisory text.

◆ DetermineAirQualityCategory() [1/2]

std::string RumPi::PMS5003::DetermineAirQualityCategory ( ) const
virtual

Gets the short air-quality category name for the current average readings.

Author
Eddie O'Hagan
Date
8/13/2026
std::string category = dustSensor.DetermineAirQualityCategory();
Returns
The air-quality category (e.g. "Good", "Poor", "Severe and Hazardous").

◆ DetermineAirQualityCategory() [2/2]

std::string RumPi::PMS5003::DetermineAirQualityCategory ( const float  pmTwoPointFiveReading,
const float  pmTenReading 
) const
virtual

Gets the short form of the air-quality evaluation - just the category name, for compact UI labels such as the Home scene pill.

DetermineAirQuality() returns the full advisory text for a details view.

Author
Eddie O'Hagan
Date
8/13/2026
std::string category = dustSensor.DetermineAirQualityCategory(35.0f, 60.0f);
Parameters
[in]pmTwoPointFiveReadingThe PM2.5 reading to evaluate.
[in]pmTenReadingThe PM10 reading to evaluate.
Returns
The air-quality category name.

◆ GetAverageNumberOfParticlesLargerThanFiveMicronDiameter()

float RumPi::PMS5003::GetAverageNumberOfParticlesLargerThanFiveMicronDiameter ( ) const

Gets the rolling average of the number of particles larger than 5um in diameter.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetAverageNumberOfParticlesLargerThanFiveMicronDiameter();
Returns
The rolling average of the number of particles larger than 5um in diameter, or NaN if no reading has been taken yet.

◆ GetAverageNumberOfParticlesLargerThanOneMicronDiameter()

float RumPi::PMS5003::GetAverageNumberOfParticlesLargerThanOneMicronDiameter ( ) const

Gets the rolling average of the number of particles larger than 1um in diameter.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetAverageNumberOfParticlesLargerThanOneMicronDiameter();
Returns
The rolling average of the number of particles larger than 1um in diameter, or NaN if no reading has been taken yet.

◆ GetAverageNumberOfParticlesLargerThanTenMicronDiameter()

float RumPi::PMS5003::GetAverageNumberOfParticlesLargerThanTenMicronDiameter ( ) const

Gets the rolling average of the number of particles larger than 10um in diameter.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetAverageNumberOfParticlesLargerThanTenMicronDiameter();
Returns
The rolling average of the number of particles larger than 10um in diameter, or NaN if no reading has been taken yet.

◆ GetAverageNumberOfParticlesLargerThanTwoPointFiveMicronDiameter()

float RumPi::PMS5003::GetAverageNumberOfParticlesLargerThanTwoPointFiveMicronDiameter ( ) const

Gets the rolling average of the number of particles larger than 2.5um in diameter.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetAverageNumberOfParticlesLargerThanTwoPointFiveMicronDiameter();
Returns
The rolling average of the number of particles larger than 2.5um in diameter, or NaN if no reading has been taken yet.

◆ GetAverageNumberOfParticlesLargerThanZeroPointFiveMicronDiameter()

float RumPi::PMS5003::GetAverageNumberOfParticlesLargerThanZeroPointFiveMicronDiameter ( ) const

Gets the rolling average of the number of particles larger than 0.5um in diameter.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetAverageNumberOfParticlesLargerThanZeroPointFiveMicronDiameter();
Returns
The rolling average of the number of particles larger than 0.5um in diameter, or NaN if no reading has been taken yet.

◆ GetAverageNumberOfParticlesLargerThanZeroPointThreeMicronDiameter()

float RumPi::PMS5003::GetAverageNumberOfParticlesLargerThanZeroPointThreeMicronDiameter ( ) const

Gets the rolling average of the number of particles larger than 0.3um in diameter.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetAverageNumberOfParticlesLargerThanZeroPointThreeMicronDiameter();
Returns
The rolling average of the number of particles larger than 0.3um in diameter, or NaN if no reading has been taken yet.

◆ GetNumberOfParticlesLargerThanFiveMicronDiameter()

float RumPi::PMS5003::GetNumberOfParticlesLargerThanFiveMicronDiameter ( ) const

Gets the number of particles larger than 5um in diameter.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetNumberOfParticlesLargerThanFiveMicronDiameter();
Returns
The number of particles larger than 5um in diameter.

◆ GetNumberOfParticlesLargerThanOneMicronDiameter()

float RumPi::PMS5003::GetNumberOfParticlesLargerThanOneMicronDiameter ( ) const

Gets the number of particles larger than 1um in diameter.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetNumberOfParticlesLargerThanOneMicronDiameter();
Returns
The number of particles larger than 1um in diameter.

◆ GetNumberOfParticlesLargerThanTenMicronDiameter()

float RumPi::PMS5003::GetNumberOfParticlesLargerThanTenMicronDiameter ( ) const

Gets the number of particles larger than 10um in diameter.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetNumberOfParticlesLargerThanTenMicronDiameter();
Returns
The number of particles larger than 10um in diameter.

◆ GetNumberOfParticlesLargerThanTwoPointFiveMicronDiameter()

float RumPi::PMS5003::GetNumberOfParticlesLargerThanTwoPointFiveMicronDiameter ( ) const

Gets the number of particles larger than 2.5um in diameter.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetNumberOfParticlesLargerThanTwoPointFiveMicronDiameter();
Returns
The number of particles larger than 2.5um in diameter.

◆ GetNumberOfParticlesLargerThanZeroPointFiveMicronDiameter()

float RumPi::PMS5003::GetNumberOfParticlesLargerThanZeroPointFiveMicronDiameter ( ) const

Gets the number of particles larger than 0.5um in diameter.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetNumberOfParticlesLargerThanZeroPointFiveMicronDiameter();
Returns
The number of particles larger than 0.5um in diameter.

◆ GetNumberOfParticlesLargerThanZeroPointThreeMicronDiameter()

float RumPi::PMS5003::GetNumberOfParticlesLargerThanZeroPointThreeMicronDiameter ( ) const

Gets the number of particles larger than 0.3um in diameter.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetNumberOfParticlesLargerThanZeroPointThreeMicronDiameter();
Returns
The number of particles larger than 0.3um in diameter.

◆ GetPMOneAtmospheric()

float RumPi::PMS5003::GetPMOneAtmospheric ( ) const

Gets the atmospheric PM1.0 concentration.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetPMOneAtmospheric();
Returns
The atmospheric PM1.0 concentration.

◆ GetPMOneAverageAtmospheric()

float RumPi::PMS5003::GetPMOneAverageAtmospheric ( ) const

Gets the rolling average of the atmospheric PM1.0 concentration.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetPMOneAverageAtmospheric();
Returns
The rolling average of the atmospheric PM1.0 concentration, or NaN if no reading has been taken yet.

◆ GetPMOneAverageFactory()

float RumPi::PMS5003::GetPMOneAverageFactory ( ) const

Gets the rolling average of the factory-calibrated PM1.0 concentration.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetPMOneAverageFactory();
Returns
The rolling average of the factory-calibrated PM1.0 concentration, or NaN if no reading has been taken yet.

◆ GetPMOneFactory()

float RumPi::PMS5003::GetPMOneFactory ( ) const

Gets the factory-calibrated PM1.0 concentration.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetPMOneFactory();
Returns
The factory-calibrated PM1.0 concentration.

◆ GetPMTenAtmospheric()

float RumPi::PMS5003::GetPMTenAtmospheric ( ) const

Gets the atmospheric PM10 concentration.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetPMTenAtmospheric();
Returns
The atmospheric PM10 concentration.

◆ GetPMTenAverageAtmospheric()

float RumPi::PMS5003::GetPMTenAverageAtmospheric ( ) const

Gets the rolling average of the atmospheric PM10 concentration.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetPMTenAverageAtmospheric();
Returns
The rolling average of the atmospheric PM10 concentration, or NaN if no reading has been taken yet.

◆ GetPMTenAverageFactory()

float RumPi::PMS5003::GetPMTenAverageFactory ( ) const

Gets the rolling average of the factory-calibrated PM10 concentration.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetPMTenAverageFactory();
Returns
The rolling average of the factory-calibrated PM10 concentration, or NaN if no reading has been taken yet.

◆ GetPMTenFactory()

float RumPi::PMS5003::GetPMTenFactory ( ) const

Gets the factory-calibrated PM10 concentration.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetPMTenFactory();
Returns
The factory-calibrated PM10 concentration.

◆ GetPMTwoPointFiveAtmospheric()

float RumPi::PMS5003::GetPMTwoPointFiveAtmospheric ( ) const

Gets the atmospheric PM2.5 concentration.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetPMTwoPointFiveAtmospheric();
Returns
The atmospheric PM2.5 concentration.

◆ GetPMTwoPointFiveAverageAtmospheric()

float RumPi::PMS5003::GetPMTwoPointFiveAverageAtmospheric ( ) const

Gets the rolling average of the atmospheric PM2.5 concentration.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetPMTwoPointFiveAverageAtmospheric();
Returns
The rolling average of the atmospheric PM2.5 concentration, or NaN if no reading has been taken yet.

◆ GetPMTwoPointFiveAverageFactory()

float RumPi::PMS5003::GetPMTwoPointFiveAverageFactory ( ) const

Gets the rolling average of the factory-calibrated PM2.5 concentration.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetPMTwoPointFiveAverageFactory();
Returns
The rolling average of the factory-calibrated PM2.5 concentration, or NaN if no reading has been taken yet.

◆ GetPMTwoPointFiveFactory()

float RumPi::PMS5003::GetPMTwoPointFiveFactory ( ) const

Gets the factory-calibrated PM2.5 concentration.

Author
Eddie O'Hagan
Date
8/13/2026
float value = dustSensor.GetPMTwoPointFiveFactory();
Returns
The factory-calibrated PM2.5 concentration.

◆ IsDataValid()

bool RumPi::PMS5003::IsDataValid ( const float *  dataToValidate,
const size_t  bufferSize 
) const
virtual

Validates a serial frame by summing all bytes except the trailing two and comparing against the big-endian checksum those two bytes carry.

Author
Eddie O'Hagan
Date
8/13/2026
bool valid = dustSensor.IsDataValid(readData, bufferSize);
Parameters
[in]dataToValidateThe frame's bytes (as floats), including the trailing checksum.
[in]bufferSizeThe number of bytes in the frame.
Returns
True if the computed checksum matches the received checksum.

◆ ProcessRawValues()

void RumPi::PMS5003::ProcessRawValues ( )
overridevirtual

Reads and validates a serial frame (retrying up to RUMPI_MAX_READ_ATTEMPTS), decodes the PM1.0/PM2.5/PM10 concentrations and particle counts from their big-endian byte pairs, and feeds each into its rolling average.

Author
Eddie O'Hagan
Date
8/13/2026
dustSensor.ProcessRawValues();

Implements RumPi::BaseComponent.

◆ ReadRawValue()

int RumPi::PMS5003::ReadRawValue ( )
virtual

Reads a single raw byte from the serial device.

Author
Eddie O'Hagan
Date
8/13/2026
int value = dustSensor.ReadRawValue();
Returns
The next byte from the serial device.

◆ ToString()

std::string RumPi::PMS5003::ToString ( ) const
overridevirtual

Serializes every current reading and rolling average (PM concentrations, particle counts) plus the air-quality evaluation to a string.

Author
Eddie O'Hagan
Date
8/13/2026
std::string data = dustSensor.ToString();
Returns
A multi-line string describing the sensor's readings.

Implements RumPi::BaseComponent.

◆ TurnOff()

void RumPi::PMS5003::TurnOff ( )
overridevirtual

Closes the serial device (if open) and marks the sensor stopped.

Author
Eddie O'Hagan
Date
8/13/2026
dustSensor.TurnOff();

Implements RumPi::BaseComponent.

◆ TurnOn()

void RumPi::PMS5003::TurnOn ( )
overridevirtual

Opens the serial device at 9600 baud and marks the sensor running, reporting the result through the AlertManager.

Author
Eddie O'Hagan
Date
8/13/2026
dustSensor.TurnOn();

Implements RumPi::BaseComponent.

Member Data Documentation

◆ myAverageNumberOfParticlesLargerThanFiveMicronDiameter

RollingAverage RumPi::PMS5003::myAverageNumberOfParticlesLargerThanFiveMicronDiameter
protected

Rolling average of particles > 5um.

◆ myAverageNumberOfParticlesLargerThanOneMicronDiameter

RollingAverage RumPi::PMS5003::myAverageNumberOfParticlesLargerThanOneMicronDiameter
protected

Rolling average of particles > 1um.

◆ myAverageNumberOfParticlesLargerThanTenMicronDiameter

RollingAverage RumPi::PMS5003::myAverageNumberOfParticlesLargerThanTenMicronDiameter
protected

Rolling average of particles > 10um.

◆ myAverageNumberOfParticlesLargerThanTwoPointFiveMicronDiameter

RollingAverage RumPi::PMS5003::myAverageNumberOfParticlesLargerThanTwoPointFiveMicronDiameter
protected

Rolling average of particles > 2.5um.

◆ myAverageNumberOfParticlesLargerThanZeroPointFiveMicronDiameter

RollingAverage RumPi::PMS5003::myAverageNumberOfParticlesLargerThanZeroPointFiveMicronDiameter
protected

Rolling average of particles > 0.5um.

◆ myAverageNumberOfParticlesLargerThanZeroPointThreeMicronDiameter

RollingAverage RumPi::PMS5003::myAverageNumberOfParticlesLargerThanZeroPointThreeMicronDiameter
protected

Rolling average of particles > 0.3um.

◆ myDevicePath

std::string RumPi::PMS5003::myDevicePath
protected

The serial device path.

◆ myDustData

std::map<std::string, float> RumPi::PMS5003::myDustData
protected

Most recent raw readings, keyed by measurement name.

◆ myIsRunning

bool RumPi::PMS5003::myIsRunning
protected

True while the serial device is open and readable.

◆ myPMOneAverageAtmospheric

RollingAverage RumPi::PMS5003::myPMOneAverageAtmospheric
protected

Rolling average of the atmospheric PM1.0 reading.

◆ myPMOneAverageFactory

RollingAverage RumPi::PMS5003::myPMOneAverageFactory
protected

Rolling average of the factory-calibrated PM1.0 reading.

◆ myPMTenAverageAtmospheric

RollingAverage RumPi::PMS5003::myPMTenAverageAtmospheric
protected

Rolling average of the atmospheric PM10 reading.

◆ myPMTenAverageFactory

RollingAverage RumPi::PMS5003::myPMTenAverageFactory
protected

Rolling average of the factory-calibrated PM10 reading.

◆ myPMTwoPointFiveAverageAtmospheric

RollingAverage RumPi::PMS5003::myPMTwoPointFiveAverageAtmospheric
protected

Rolling average of the atmospheric PM2.5 reading.

◆ myPMTwoPointFiveAverageFactory

RollingAverage RumPi::PMS5003::myPMTwoPointFiveAverageFactory
protected

Rolling average of the factory-calibrated PM2.5 reading.

◆ mySerialDeviceFileDescriptor

int RumPi::PMS5003::mySerialDeviceFileDescriptor
protected

The open serial device file descriptor.


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