SGP30 unit.
More...
#include <unit_SGP30.hpp>
|
| UnitSGP30 (const uint8_t addr=DEFAULT_ADDRESS) |
|
virtual bool | begin () override |
|
virtual void | update (const bool force=false) override |
|
bool | readRaw (uint16_t &h2, uint16_t ðanol) |
| Read sensor raw signals.
|
|
bool | readRaw (float &h2, float ðanol) |
| Read H2/Ethanol concentration.
|
|
bool | measureTest (uint16_t &result) |
| Run the on-chip self-test.
|
|
bool | generalReset () |
| General reset.
|
|
bool | readFeatureSet (sgp30::Feature &feature) |
| Read the feature set.
|
|
bool | readSerialNumber (uint64_t &number) |
| Read the serial number.
|
|
bool | readSerialNumber (char *number) |
| Read the serial number string.
|
|
|
config_t | config () const |
| Gets the configration.
|
|
void | config (const config_t &cfg) |
| Set the configration.
|
|
|
uint8_t | productVersion () const |
| Gets the product version.
|
|
bool | canMeasurePeriodic () const |
| Can it be measured?
|
|
|
uint16_t | co2eq () const |
| Oldest CO2eq (ppm)
|
|
uint16_t | tvoc () const |
| Oldest TVOC (ppb)
|
|
|
bool | startPeriodicMeasurement (const uint16_t co2eq, const uint16_t tvoc, const uint16_t humidity, const uint32_t interval=1000U, const uint32_t duration=sgp30::IAQ_INIT_DURATION) |
| Start periodic measurement.
|
|
bool | startPeriodicMeasurement (const uint32_t interval=1000U, const uint32_t duration=sgp30::IAQ_INIT_DURATION) |
| Start periodic measurement.
|
|
bool | stopPeriodicMeasurement () |
| Stop periodic measurement.
|
|
|
bool | readIaqBaseline (uint16_t &co2eq, uint16_t &tvoc) |
| Read the IAQ baseline.
|
|
bool | writeAbsoluteHumidity (const uint16_t raw, const uint32_t duration=sgp30::SET_ABSOLUTE_HUMIDITY_DURATION) |
| Write the absolute humidity.
|
|
bool | writeAbsoluteHumidity (const float gm3, const uint32_t duration=sgp30::SET_ABSOLUTE_HUMIDITY_DURATION) |
| Write the absolute humidity.
|
|
|
bool | start_periodic_measurement (const uint16_t co2eq, const uint16_t tvoc, const uint16_t humidity, const uint32_t interval, const uint32_t duration=sgp30::IAQ_INIT_DURATION) |
|
bool | start_periodic_measurement (const uint32_t interval, const uint32_t duration=sgp30::IAQ_INIT_DURATION) |
|
bool | stop_periodic_measurement () |
|
bool | write_iaq_baseline (const uint16_t co2eq, const uint16_t tvoc) |
|
bool | read_measurement (sgp30::Data &d) |
|
| M5_UNIT_COMPONENT_PERIODIC_MEASUREMENT_ADAPTER_HPP_BUILDER (UnitSGP30, sgp30::Data) |
|
|
uint8_t | _version {} |
|
bool | _waiting {} |
|
types::elapsed_time_t | _can_measure_time {} |
|
std::unique_ptr< m5::container::CircularBuffer< sgp30::Data > > | _data {} |
|
config_t | _cfg {} |
|
◆ canMeasurePeriodic()
bool m5::unit::UnitSGP30::canMeasurePeriodic |
( |
| ) |
const |
|
inline |
Can it be measured?
- Returns
- True if it can
- Warning
- After the start of a periodic measurement, it is necessary to wait 15 seconds to obtain a valid measurement value
◆ generalReset()
bool m5::unit::UnitSGP30::generalReset |
( |
| ) |
|
General reset.
Reset using I2C general call
- Warning
- This is a reset by General command, the command is also sent to all devices with I2C connections
- Returns
- True if successful
◆ measureTest()
bool m5::unit::UnitSGP30::measureTest |
( |
uint16_t & | result | ) |
|
Run the on-chip self-test.
- Parameters
-
[out] | result | self-test return code |
- Returns
- True if successful
- Note
- If the test is OK, the result will be 0xd400
- Warning
- Must not be executed after startPeriodicMeasurement
◆ productVersion()
uint8_t m5::unit::UnitSGP30::productVersion |
( |
| ) |
const |
|
inline |
Gets the product version.
- Warning
- Calling after the call of begin()
◆ readFeatureSet()
Read the feature set.
- Parameters
-
- Returns
- True if successful
◆ readIaqBaseline()
bool m5::unit::UnitSGP30::readIaqBaseline |
( |
uint16_t & | co2eq, |
|
|
uint16_t & | tvoc ) |
Read the IAQ baseline.
- Parameters
-
[out] | co2eq | iaq baseline for CO2 |
[out] | tvoc | iaq baseline for TVOC |
- Returns
- True if successful
◆ readRaw() [1/2]
bool m5::unit::UnitSGP30::readRaw |
( |
float & | h2, |
|
|
float & | ethanol ) |
Read H2/Ethanol concentration.
- Parameters
-
[out] | h2 | H2 concentration(ppm) |
[out] | ethanol | Ethanol concentration(rppm |
- Returns
- True if successful
- Note
- Outputs the value calculated from the output of readRaw
◆ readRaw() [2/2]
bool m5::unit::UnitSGP30::readRaw |
( |
uint16_t & | h2, |
|
|
uint16_t & | ethanol ) |
Read sensor raw signals.
- Parameters
-
[out] | h2 | H2 concentration(raw) |
[out] | ethanol | Ethanol concentration(raw) |
- Returns
- True if successful
◆ readSerialNumber() [1/2]
bool m5::unit::UnitSGP30::readSerialNumber |
( |
char * | number | ) |
|
Read the serial number string.
- Parameters
-
- Returns
- True if successful
- Warning
- number must be at least 13 bytes
◆ readSerialNumber() [2/2]
bool m5::unit::UnitSGP30::readSerialNumber |
( |
uint64_t & | number | ) |
|
Read the serial number.
- Returns
- True if successful
- Note
- Serial number is 48bits
◆ startPeriodicMeasurement() [1/2]
bool m5::unit::UnitSGP30::startPeriodicMeasurement |
( |
const uint16_t | co2eq, |
|
|
const uint16_t | tvoc, |
|
|
const uint16_t | humidity, |
|
|
const uint32_t | interval = 1000U, |
|
|
const uint32_t | duration = sgp30::IAQ_INIT_DURATION ) |
|
inline |
Start periodic measurement.
Specify settings and measure
- Parameters
-
co2eq | iaq baseline for CO2eq |
tvoc | iaq baseline for TVOC |
humidity | absolute humidity (disable if zero) |
interval | Measurement Interval(ms) |
duration | Max command duration(ms) |
- Returns
- True if successful
- Note
- 15 seconds wait is required before a valid measurement can be initiated (warmup)
-
In update(), waiting are taken into account
◆ startPeriodicMeasurement() [2/2]
bool m5::unit::UnitSGP30::startPeriodicMeasurement |
( |
const uint32_t | interval = 1000U, |
|
|
const uint32_t | duration = sgp30::IAQ_INIT_DURATION ) |
|
inline |
Start periodic measurement.
Measuring in the current settings
- Parameters
-
interval | Measurement Interval(ms) |
duration | Max command duration(ms) |
- Returns
- True if successful
- Note
- 15 seconds wait is required before a valid measurement can be initiated.
-
In update(), waiting are taken into account
◆ stopPeriodicMeasurement()
bool m5::unit::UnitSGP30::stopPeriodicMeasurement |
( |
| ) |
|
|
inline |
Stop periodic measurement.
- Returns
- True if successful
◆ writeAbsoluteHumidity() [1/2]
bool m5::unit::UnitSGP30::writeAbsoluteHumidity |
( |
const float | gm3, |
|
|
const uint32_t | duration = sgp30::SET_ABSOLUTE_HUMIDITY_DURATION ) |
Write the absolute humidity.
- Parameters
-
gm3 | absolute humidity (g/m^3) |
duration | Max command duration(ms) |
- Returns
- True if successful
◆ writeAbsoluteHumidity() [2/2]
bool m5::unit::UnitSGP30::writeAbsoluteHumidity |
( |
const uint16_t | raw, |
|
|
const uint32_t | duration = sgp30::SET_ABSOLUTE_HUMIDITY_DURATION ) |
Write the absolute humidity.
- Parameters
-
raw | absolute humidity (disable if zero) |
duration | Max command duration(ms) |
- Returns
- True if successful
- Note
- Value is a fixed-point 8.8bit number