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

Temperature and humidity, sensor unit. More...

#include <unit_SHT40.hpp>

Inheritance diagram for m5::unit::UnitSHT40:

Classes

struct  config_t
 Settings for begin. More...
 

Public Member Functions

 UnitSHT40 (const uint8_t addr=DEFAULT_ADDRESS)
 
virtual bool begin () override
 
virtual void update (const bool force=false) override
 
Settings for begin
config_t config ()
 Gets the configration.
 
void config (const config_t &cfg)
 Set the configration.
 
Measurement data by periodic
float temperature () const
 Oldest measured temperature (Celsius)
 
float celsius () const
 Oldest measured temperature (Celsius)
 
float fahrenheit () const
 Oldest measured temperature (Fahrenheit)
 
float humidity () const
 Oldest measured humidity (RH)
 
Periodic measurement
bool startPeriodicMeasurement (const sht40::Precision precision, const sht40::Heater heater, const float duty=0.05f)
 Start periodic measurement.
 
bool stopPeriodicMeasurement ()
 Stop periodic measurement.
 
Single shot measurement
bool measureSingleshot (sht40::Data &d, const sht40::Precision precision=sht40::Precision::High, const sht40::Heater heater=sht40::Heater::None)
 Measurement single shot.
 
Reset
bool softReset ()
 Soft reset.
 
bool generalReset ()
 General reset.
 
Serial number
bool readSerialNumber (uint32_t &serialNumber)
 Read the serial number value.
 
bool readSerialNumber (char *serialNumber)
 Read the serial number string.
 

Protected Member Functions

bool start_periodic_measurement (const sht40::Precision precision, const sht40::Heater heater, const float duty)
 
bool stop_periodic_measurement ()
 
bool read_measurement (sht40::Data &d)
 
void reset_status ()
 
bool soft_reset ()
 
 M5_UNIT_COMPONENT_PERIODIC_MEASUREMENT_ADAPTER_HPP_BUILDER (UnitSHT40, sht40::Data)
 

Protected Attributes

std::unique_ptr< m5::container::CircularBuffer< sht40::Data > > _data {}
 
config_t _cfg {}
 
uint8_t _cmd {}
 
uint8_t _measureCmd {}
 
types::elapsed_time_t _latest_heater {}
 
types::elapsed_time_t _interval_heater {}
 
uint32_t _duration_measure {}
 
uint32_t _duration_heater {}
 

Detailed Description

Temperature and humidity, sensor unit.

Member Function Documentation

◆ generalReset()

bool m5::unit::UnitSHT40::generalReset ( )

General reset.

Reset using I2C general call

Returns
True if successful
Warning
This is a reset by General command, the command is also sent to all devices with I2C connections

◆ measureSingleshot()

bool m5::unit::UnitSHT40::measureSingleshot ( sht40::Data & d,
const sht40::Precision precision = sht40::Precision::High,
const sht40::Heater heater = sht40::Heater::None )

Measurement single shot.

Parameters
[out]dataMeasuerd data
precisionSensor precision
heaterHeater behavior
Returns
True if successful
Note
Blocking until the process is complete
Warning
During periodic detection runs, an error is returned
If heater is activated, the accuracy of the returned value is not guaranteed
See also
UnitSHT40::startPeriodicMeasurement

◆ readSerialNumber() [1/2]

bool m5::unit::UnitSHT40::readSerialNumber ( char * serialNumber)

Read the serial number string.

Parameters
[out]serialNumberOutput buffer
Returns
True if successful
Warning
serialNumber must be at least 9 bytes
During periodic detection runs, an error is returned

◆ readSerialNumber() [2/2]

bool m5::unit::UnitSHT40::readSerialNumber ( uint32_t & serialNumber)

Read the serial number value.

Parameters
[out]serialNumberserial number value
Returns
True if successful
Note
The serial number is 32 bit
Warning
During periodic detection runs, an error is returned

◆ softReset()

bool m5::unit::UnitSHT40::softReset ( )

Soft reset.

Returns
True if successful

◆ startPeriodicMeasurement()

bool m5::unit::UnitSHT40::startPeriodicMeasurement ( const sht40::Precision precision,
const sht40::Heater heater,
const float duty = 0.05f )
inline

Start periodic measurement.

Parameters
precisionSensor precision
heaterHeater behavior
dutyDuty for activate heater
Returns
True if successful
Note
If the heater is Long or SHort, the heater will be active periodically within the specified duty
Warning
Datasheet says "keepingin mind that the heater is designed for a maximal duty cycle of less than 5%"

◆ stopPeriodicMeasurement()

bool m5::unit::UnitSHT40::stopPeriodicMeasurement ( )
inline

Stop periodic measurement.

Returns
True if successful