4#include "../Data/RollingAverage.h"
50 PTQS1005(
const std::string& devicePath);
75 virtual void TurnOn()
override;
87 virtual void TurnOff()
override;
119 virtual bool IsDataValid(
const float* dataToValidate,
const size_t bufferSize)
const;
164 virtual std::string
ToString()
const override;
Abstract base class for every component (sensor, actuator, etc.) the library manages.
Definition: BaseComponent.h:60
PTQS1005 air-quality sensor read over serial, reporting PM2.5, TVOC, HCHO, CO2, internal temperature,...
Definition: PTQS1005.h:20
float GetTVOC() const
Gets the current TVOC reading.
Definition: PTQS1005.cpp:364
virtual ~PTQS1005()
Destroys the sensor, turning it off first.
Definition: PTQS1005.cpp:55
virtual float ReadRawValue()
Reads a single raw byte (as a float) from the serial device.
Definition: PTQS1005.cpp:119
float GetCO2Average() const
Gets the rolling average of the CO2 reading.
Definition: PTQS1005.cpp:461
std::map< std::string, float > myDustData
Most recent raw readings, keyed by measurement name.
Definition: PTQS1005.h:35
float myCalculatedTVOC
The most recent TVOC reading (raw / division factor).
Definition: PTQS1005.h:25
RollingAverage myCO2Average
Rolling average of the CO2 reading.
Definition: PTQS1005.h:32
float GetHCHOAverage() const
Gets the rolling average of the HCHO (formaldehyde) reading.
Definition: PTQS1005.cpp:421
float GetHCHO() const
Gets the current HCHO (formaldehyde) reading.
Definition: PTQS1005.cpp:404
float myCalculatedHumidity
The most recent humidity, as a percent.
Definition: PTQS1005.h:28
float GetCO2() const
Gets the current CO2 reading.
Definition: PTQS1005.cpp:444
RollingAverage myPMTwoPointFiveAverageAtmospheric
Rolling average of the PM2.5 reading.
Definition: PTQS1005.h:29
virtual void TurnOn() override
Opens the serial device at 9600 baud and marks the sensor running, reporting the result through the A...
Definition: PTQS1005.cpp:70
float GetPmTwoPointFiveAtmospheric() const
Gets the current PM2.5 reading.
Definition: PTQS1005.cpp:330
virtual float ConvertDivisionFactorToNumber(float divisionFactor) const
Maps the sensor's TVOC/HCHO division-factor code (0, 1, or 2) to its numeric divisor (10,...
Definition: PTQS1005.cpp:297
PTQS1005(const std::string &devicePath)
Builds a PTQS1005 for the given serial device path, seeding its data map so each reading updates in p...
Definition: PTQS1005.cpp:19
bool myIsRunning
True while the serial device is open and readable.
Definition: PTQS1005.h:22
RollingAverage myInternalTemperatureInCAverage
Rolling average of the internal temperature.
Definition: PTQS1005.h:33
virtual std::string ToString() const override
Serializes every current reading and rolling average (PM2.5, TVOC, HCHO, CO2, temperature,...
Definition: PTQS1005.cpp:558
float GetHumidityAverage() const
Gets the rolling average of the humidity reading.
Definition: PTQS1005.cpp:535
float myCalculatedHCHO
The most recent HCHO reading (raw / division factor).
Definition: PTQS1005.h:26
virtual void ProcessRawValues() override
Sends the data-request command, reads and validates a serial frame (retrying up to RUMPI_MAX_READ_ATT...
Definition: PTQS1005.cpp:178
virtual void TurnOff() override
Closes the serial device (if open) and marks the sensor stopped.
Definition: PTQS1005.cpp:96
float myCalculatedInternalTemperatureInC
The most recent internal temperature, in Celsius.
Definition: PTQS1005.h:27
std::string myDevicePath
The serial device path.
Definition: PTQS1005.h:24
int mySerialDeviceFileDescriptor
The open serial device file descriptor.
Definition: PTQS1005.h:23
float GetPmTwoPointFiveAverageAtmospheric() const
Gets the rolling average of the PM2.5 reading.
Definition: PTQS1005.cpp:347
RollingAverage myHumidityAverage
Rolling average of the humidity.
Definition: PTQS1005.h:34
RollingAverage myHCHOAverage
Rolling average of the HCHO reading.
Definition: PTQS1005.h:31
float GetInternalTemperatureInCAverage() const
Gets the rolling average of the sensor's internal temperature.
Definition: PTQS1005.cpp:501
RollingAverage myTVOCAverage
Rolling average of the TVOC reading.
Definition: PTQS1005.h:30
float GetTVOCAverage() const
Gets the rolling average of the TVOC reading.
Definition: PTQS1005.cpp:381
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: PTQS1005.cpp:140
float GetInternalTemperatureInC() const
Gets the sensor's current internal temperature.
Definition: PTQS1005.cpp:484
float GetHumidity() const
Gets the current humidity reading.
Definition: PTQS1005.cpp:518
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