M5Unit-ENV 1.2.0 git rev:d576302
Loading...
Searching...
No Matches
m5::unit::UnitSGP30 Class Reference

SGP30 unit. More...

#include <unit_SGP30.hpp>

Inheritance diagram for m5::unit::UnitSGP30:

Classes

struct  config_t
 Settings for begin. More...
 

Public Member Functions

 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 &ethanol)
 Read sensor raw signals.
 
bool readRaw (float &h2, float &ethanol)
 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.
 
Settings for begin
config_t config () const
 Gets the configration.
 
void config (const config_t &cfg)
 Set the configration.
 
Properties
uint8_t productVersion () const
 Gets the product version.
 
bool canMeasurePeriodic () const
 Can it be measured?
 
Measurement data by periodic
uint16_t co2eq () const
 Oldest CO2eq (ppm)
 
uint16_t tvoc () const
 Oldest TVOC (ppb)
 
Periodic measurement
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.
 
Correction
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.
 

Protected Member Functions

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)
 

Protected Attributes

uint8_t _version {}
 
bool _waiting {}
 
types::elapsed_time_t _can_measure_time {}
 
std::unique_ptr< m5::container::CircularBuffer< sgp30::Data > > _data {}
 
config_t _cfg {}
 

Detailed Description

SGP30 unit.

Member Function Documentation

◆ 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]resultself-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()

bool m5::unit::UnitSGP30::readFeatureSet ( sgp30::Feature & feature)

Read the feature set.

Parameters
feature
Returns
True if successful

◆ readIaqBaseline()

bool m5::unit::UnitSGP30::readIaqBaseline ( uint16_t & co2eq,
uint16_t & tvoc )

Read the IAQ baseline.

Parameters
[out]co2eqiaq baseline for CO2
[out]tvociaq 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]h2H2 concentration(ppm)
[out]ethanolEthanol 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]h2H2 concentration(raw)
[out]ethanolEthanol concentration(raw)
Returns
True if successful

◆ readSerialNumber() [1/2]

bool m5::unit::UnitSGP30::readSerialNumber ( char * number)

Read the serial number string.

Parameters
[out]numberOutput buffer
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
co2eqiaq baseline for CO2eq
tvociaq baseline for TVOC
humidityabsolute humidity (disable if zero)
intervalMeasurement Interval(ms)
durationMax 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
intervalMeasurement Interval(ms)
durationMax 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
gm3absolute humidity (g/m^3)
durationMax 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
rawabsolute humidity (disable if zero)
durationMax command duration(ms)
Returns
True if successful
Note
Value is a fixed-point 8.8bit number