M5Unit-THERMO 0.4.0 git rev:7cce598
Loading...
Searching...
No Matches
m5::unit::UnitMLX90614 Class Reference

Base class of the UnitMLX90614 series. More...

#include <unit_MLX90614.hpp>

Inheritance diagram for m5::unit::UnitMLX90614:
m5::unit::UnitMLX90614BAA

Classes

struct  config_t
 Settings for begin. More...
 

Public Member Functions

 UnitMLX90614 (const uint8_t addr=DEFAULT_ADDRESS)
 
virtual bool begin () override
 
virtual void update (const bool force=false) override
 
const mlx90614::EEPROM & eeprom () const
 Gets the EEPROM structure.
 
bool sleep ()
 Sleep.
 
bool wakeup ()
 Wakeup.
 
bool applySettings ()
 Apply EEPROM settings.
 
Settings for begin
config_t config ()
 Gets the configuration.
 
void config (const config_t &cfg)
 Sets the configuration.
 
Measurement data by periodic
float ambientKelvin () const
 Oldest ambient kelvin.
 
float ambientTemperature () const
 Oldest ambient temperature (Celsius)
 
float ambientCelsius () const
 Oldest ambient temperature (Celsius)
 
float ambientFahrenheit () const
 Oldest ambient temperature (Fahrenheit)
 
float objectKelvin1 () const
 Oldest object 1 kelvin.
 
float objectTemperature1 () const
 Oldest object 1 temperature (Celsius)
 
float objectCelsius1 () const
 Oldest object 1 temperature (Celsius)
 
float objectFahrenheit1 () const
 Oldest object 1 temperature (Fahrenheit)
 
float objectKelvin2 () const
 Oldest object 2 kelvin.
 
float objectTemperature2 () const
 Oldest object 2 temperature (Celsius)
 
float objectCelsius2 () const
 Oldest object 2 temperature (Celsius)
 
float objectFahrenheit2 () const
 Oldest object 2 temperature (Fahrenheit)
 
Periodic measurement
bool startPeriodicMeasurement (const mlx90614::IIR iir, const mlx90614::FIR fir, const mlx90614::Gain gain, const mlx90614::IRSensor irs)
 Start periodic measurement.
 
bool startPeriodicMeasurement ()
 Start periodic measurement in the current settings.
 
bool stopPeriodicMeasurement ()
 Stop periodic measurement.
 
Settings(Config)
Note
If apply is false, a POR or call applySettings() is required to enable the setting
Warning
Some settings are writable in SMBus mode, but not reflected in operation
When apply is true, the I2C bus is temporarily released and reinitializes (see applySettings())
bool readConfig (uint16_t &v)
 Read the configuration.
 
bool writeConfig (const uint16_t v, const bool apply=true)
 Write the configuration.
 
bool readOutput (mlx90614::Output &o)
 Read the Output.
 
bool writeOutput (const mlx90614::Output o, const bool apply=true)
 Write the Output.
 
bool readIIR (mlx90614::IIR &iir)
 Read the IIR.
 
bool writeIIR (const mlx90614::IIR iir, const bool apply=true)
 Write the IIR.
 
bool readFIR (mlx90614::FIR &fir)
 Read the FIR.
 
bool writeFIR (const mlx90614::FIR fir, const bool apply=true)
 Write the FIR.
 
bool readGain (mlx90614::Gain &gain)
 Read the Gain.
 
bool writeGain (const mlx90614::Gain gain, const bool apply=true)
 Write the Gain.
 
bool readIRSensor (mlx90614::IRSensor &irs)
 Read the IRSensor mode.
 
bool writeIRSensor (const mlx90614::IRSensor irs, const bool apply=true)
 Write the IRSensor mode.
 
bool readPositiveKs (bool &pos)
 Read the sign of Ks (Config Register1 bit7)
 
bool writePositiveKs (const bool pos, const bool apply=true)
 Write the sign of Ks (Config Register1 bit7)
 
bool readPositiveKt2 (bool &pos)
 Read the sign of Kt2 (Config Register1 bit14)
 
bool writePositiveKt2 (const bool pos, const bool apply=true)
 Write the sign of Kt2 (Config Register1 bit14)
 
bool readPositiveKf2 (bool &pos)
 
bool writePositiveKf2 (const bool pos, const bool apply=true)
 
Settings(Temperature range)
Note
If apply is false, a POR or call applySettings() is required to enable the setting
Warning
Some settings are writable in SMBus mode, but not reflected in operation
When apply is true, the I2C bus is temporarily released and reinitializes (see applySettings())
bool readObjectMinMax (uint16_t &toMin, uint16_t &toMax)
 Read the minimum and maximum temperatures of the measurement for the object.
 
bool readObjectMinMax (float &toMin, float &toMax)
 Read the minimum and maximum temperatures of the measurement for the object.
 
template<typename T , typename std::enable_if< std::is_integral< T >::value, std::nullptr_t >::type = nullptr>
bool writeObjectMinMax (const T toMin, const T toMax, const bool apply=true)
 Write the minimum and maximum temperatures of the measurement for the object.
 
bool writeObjectMinMax (const float toMin, const float toMax, const bool apply=true)
 Write the minimum and maximum temperatures of the measurement for the object.
 
bool readAmbientMinMax (uint8_t &taMin, uint8_t &taMax)
 Read the minimum and maximum temperatures of the measurement for the ambient.
 
bool readAmbientMinMax (float &taMin, float &taMax)
 Read the minimum and maximum temperatures of the measurement for the ambient.
 
template<typename T , typename std::enable_if< std::is_integral< T >::value, std::nullptr_t >::type = nullptr>
bool writeAmbientMinMax (const T taMin, const T taMax, const bool apply=true)
 Write the minimum and maximum temperatures of the measurement for the ambient.
 
bool writeAmbientMinMax (const float taMin, const float taMax, const bool apply=true)
 Write the minimum and maximum temperatures of the measurement for the ambient.
 
Settings (Emissivity)
Note
If apply is false, a POR or call applySettings() is required to enable the setting
Warning
When apply is true, the I2C bus is temporarily released and reinitializes (see applySettings())
bool readEmissivity (uint16_t &emiss)
 Read the emissivity.
 
bool readEmissivity (float &emiss)
 Read the emissivity.
 
template<typename T , typename std::enable_if< std::is_integral< T >::value, std::nullptr_t >::type = nullptr>
bool writeEmissivity (const T emiss, const bool apply=true)
 Write the emissivity.
 
bool writeEmissivity (const float emiss, const bool apply=true)
 Write the emissivity.
 
I2C Address
bool changeI2CAddress (const uint8_t i2c_address)
 Change device I2C address.
 
bool readI2CAddress (uint8_t &i2c_address)
 Read device I2C address.
 

Protected Member Functions

bool read_eeprom (mlx90614::EEPROM &e)
 
bool read_register16 (const uint8_t reg, uint16_t &v, const bool stopbit=false)
 
bool write_register16 (const uint8_t reg, const uint16_t val)
 
bool write_eeprom (const uint8_t reg, const uint16_t val, const bool apply=true)
 
bool write_object_minmax (const uint16_t toMin, const uint16_t toMax, const bool apply=true)
 
bool write_ambient_minmax (const uint8_t taMin, const uint8_t taMax, const bool apply=true)
 
bool write_emissivity (const uint16_t emiss, const bool apply=true)
 
bool read_measurement (mlx90614::Data &d)
 
bool start_periodic_measurement (const mlx90614::IIR iir, const mlx90614::FIR fir, const mlx90614::Gain gain, const mlx90614::IRSensor irs)
 
bool start_periodic_measurement ()
 
bool stop_periodic_measurement ()
 
 M5_UNIT_COMPONENT_PERIODIC_MEASUREMENT_ADAPTER_HPP_BUILDER (UnitMLX90614, mlx90614::Data)
 
virtual uint32_t get_interval (const mlx90614::IIR iir, const mlx90614::FIR fir)
 
virtual bool has_dual_sensors () const
 

Detailed Description

Base class of the UnitMLX90614 series.

It can be used to measure the surface temperature of a human body or other object. Only SMBus mode is supported, so the settings that only affect the PWM output (writeOutput(), writeObjectMinMax(), writeAmbientMinMax() and the PWMCTRL register) do not change the SMBus readings

Todo
In the future, PWM mode will be supported to allow various configurations

Member Function Documentation

◆ applySettings()

bool m5::unit::UnitMLX90614::applySettings ( )
inline

Apply EEPROM settings.

Returns
True if successful
Note
After writing to EEPROM, a POR or sleep/wakeup is required for the settings to take effect
Warning
Internally calls sleep() + wakeup(), which temporarily releases and reinitializes the I2C bus. All devices sharing the same bus are affected during this period

◆ changeI2CAddress()

bool m5::unit::UnitMLX90614::changeI2CAddress ( const uint8_t i2c_address)

Change device I2C address.

Parameters
i2c_addressI2C address
Returns
True if successful
Warning
Internally calls applySettings() (sleep + wakeup), which temporarily releases and reinitializes the I2C bus. All devices sharing the same bus are affected during this period

◆ readAmbientMinMax() [1/2]

bool m5::unit::UnitMLX90614::readAmbientMinMax ( float & taMin,
float & taMax )

Read the minimum and maximum temperatures of the measurement for the ambient.

Parameters
[out]taMinMinimum celsius
[out]taMaxMaximum celsius
Returns
True if successful

◆ readAmbientMinMax() [2/2]

bool m5::unit::UnitMLX90614::readAmbientMinMax ( uint8_t & taMin,
uint8_t & taMax )

Read the minimum and maximum temperatures of the measurement for the ambient.

Parameters
[out]taMinMinimum raw value
[out]taMaxMaximum raw value
Returns
True if successful

◆ readConfig()

bool m5::unit::UnitMLX90614::readConfig ( uint16_t & v)

Read the configuration.

Parameters
[out]vConfiguration value
Returns
True if successful

◆ readEmissivity() [1/2]

bool m5::unit::UnitMLX90614::readEmissivity ( float & emiss)

Read the emissivity.

Parameters
[out]emissemissivity (0.1f - 1.0f)
Returns
True if successful

◆ readEmissivity() [2/2]

bool m5::unit::UnitMLX90614::readEmissivity ( uint16_t & emiss)

Read the emissivity.

Parameters
[out]emissRaw emissivity value
Returns
True if successful

◆ readFIR()

bool m5::unit::UnitMLX90614::readFIR ( mlx90614::FIR & fir)

Read the FIR.

Parameters
[out]firFIR
Returns
True if successful

◆ readGain()

bool m5::unit::UnitMLX90614::readGain ( mlx90614::Gain & gain)

Read the Gain.

Parameters
[out]gainGain
Returns
True if successful

◆ readI2CAddress()

bool m5::unit::UnitMLX90614::readI2CAddress ( uint8_t & i2c_address)

Read device I2C address.

Parameters
[out]i2c_addressI2C address
Returns
True if successful

◆ readIIR()

bool m5::unit::UnitMLX90614::readIIR ( mlx90614::IIR & iir)

Read the IIR.

Parameters
[out]iirIIR
Returns
True if successful

◆ readIRSensor()

bool m5::unit::UnitMLX90614::readIRSensor ( mlx90614::IRSensor & irs)

Read the IRSensor mode.

Parameters
[out]irsIRSensor
Returns
True if successful

◆ readObjectMinMax() [1/2]

bool m5::unit::UnitMLX90614::readObjectMinMax ( float & toMin,
float & toMax )

Read the minimum and maximum temperatures of the measurement for the object.

Parameters
[out]toMinMinimum celsius
[out]toMaxMaximum celsius
Returns
True if successful

◆ readObjectMinMax() [2/2]

bool m5::unit::UnitMLX90614::readObjectMinMax ( uint16_t & toMin,
uint16_t & toMax )

Read the minimum and maximum temperatures of the measurement for the object.

Parameters
[out]toMinMinimum raw value
[out]toMaxMaximum raw value
Returns
True if successful

◆ readOutput()

bool m5::unit::UnitMLX90614::readOutput ( mlx90614::Output & o)

Read the Output.

Parameters
[out]oOutput
Returns
True if successful

◆ readPositiveKf2()

bool m5::unit::UnitMLX90614::readPositiveKf2 ( bool & pos)
inline
Deprecated
Use readPositiveKt2 instead

◆ readPositiveKs()

bool m5::unit::UnitMLX90614::readPositiveKs ( bool & pos)

Read the sign of Ks (Config Register1 bit7)

Parameters
[out]posPositive if true
Returns
True if successful
Warning
This is a factory calibration value. Altering it invalidates calibration.

◆ readPositiveKt2()

bool m5::unit::UnitMLX90614::readPositiveKt2 ( bool & pos)

Read the sign of Kt2 (Config Register1 bit14)

Parameters
[out]posPositive if true
Returns
True if successful
Warning
This is a factory calibration value. Altering it invalidates calibration.

◆ sleep()

bool m5::unit::UnitMLX90614::sleep ( )

Sleep.

Returns
True if successful
Warning
Releases the I2C bus (releasePins() when the unit is added through the ESP-IDF I2C bus adapter, end() otherwise) and holds SCL low until wakeup(). Via a hub, SCL of the root bus is held low
Until wakeup(), the functions of this unit that access the device fail (periodic measurement yields no data), and no other unit on the same root bus, including other hub channels, may be accessed (also through UnitUnified::update()). With Arduino Wire, any access to the released bus blocks forever

◆ startPeriodicMeasurement() [1/2]

bool m5::unit::UnitMLX90614::startPeriodicMeasurement ( )
inline

Start periodic measurement in the current settings.

Returns
True if successful

◆ startPeriodicMeasurement() [2/2]

bool m5::unit::UnitMLX90614::startPeriodicMeasurement ( const mlx90614::IIR iir,
const mlx90614::FIR fir,
const mlx90614::Gain gain,
const mlx90614::IRSensor irs )
inline

Start periodic measurement.

Parameters
iirInfinite Impulse Response
firFinite Impulse Response
gainAmplifier gain
irsInfra-Red Sensor mode
Returns
True if successful

◆ stopPeriodicMeasurement()

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

Stop periodic measurement.

Returns
True if successful

◆ wakeup()

bool m5::unit::UnitMLX90614::wakeup ( )

Wakeup.

Returns
True if successful
Warning
Releases the I2C bus unless sleep() has already released it, drives SDA low >33ms with GPIO, then reinitializes the bus (begin(), or restorePins() for the ESP-IDF I2C bus adapter). All devices sharing the same bus are affected during this period (~600ms)

◆ writeAmbientMinMax() [1/2]

bool m5::unit::UnitMLX90614::writeAmbientMinMax ( const float taMin,
const float taMax,
const bool apply = true )

Write the minimum and maximum temperatures of the measurement for the ambient.

Parameters
taMinMinimum celsius
taMaxMaximum celsius
applySettings take effect immediately if true
Returns
True if successful
Note
Valid range between -38.2f and 125.0f
Warning
During periodic detection runs, an error is returned

◆ writeAmbientMinMax() [2/2]

template<typename T , typename std::enable_if< std::is_integral< T >::value, std::nullptr_t >::type = nullptr>
bool m5::unit::UnitMLX90614::writeAmbientMinMax ( const T taMin,
const T taMax,
const bool apply = true )
inline

Write the minimum and maximum temperatures of the measurement for the ambient.

Parameters
taMinMinimum raw value
taMaxMaximum raw value
applySettings take effect immediately if true
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ writeConfig()

bool m5::unit::UnitMLX90614::writeConfig ( const uint16_t v,
const bool apply = true )

Write the configuration.

Parameters
vConfiguration value
applySettings take effect immediately if true
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ writeEmissivity() [1/2]

bool m5::unit::UnitMLX90614::writeEmissivity ( const float emiss,
const bool apply = true )

Write the emissivity.

Parameters
emissemissivity (0.1f - 1.0f)
applySettings take effect immediately if true
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ writeEmissivity() [2/2]

template<typename T , typename std::enable_if< std::is_integral< T >::value, std::nullptr_t >::type = nullptr>
bool m5::unit::UnitMLX90614::writeEmissivity ( const T emiss,
const bool apply = true )
inline

Write the emissivity.

Parameters
emissRaw emissivity value
applySettings take effect immediately if true
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ writeFIR()

bool m5::unit::UnitMLX90614::writeFIR ( const mlx90614::FIR fir,
const bool apply = true )

Write the FIR.

Parameters
firFIR
applySettings take effect immediately if true
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ writeGain()

bool m5::unit::UnitMLX90614::writeGain ( const mlx90614::Gain gain,
const bool apply = true )

Write the Gain.

Parameters
gainGain
applySettings take effect immediately if true
Returns
True if successful
Warning
This is a factory calibration value. Altering it invalidates calibration.
During periodic detection runs, an error is returned

◆ writeIIR()

bool m5::unit::UnitMLX90614::writeIIR ( const mlx90614::IIR iir,
const bool apply = true )

Write the IIR.

Parameters
iirIIR
applySettings take effect immediately if true
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ writeIRSensor()

bool m5::unit::UnitMLX90614::writeIRSensor ( const mlx90614::IRSensor irs,
const bool apply = true )

Write the IRSensor mode.

Parameters
irsIRSensor
applySettings take effect immediately if true
Returns
True if successful
Warning
If only one sensor is installed, the IRSensor setting to Dual is ignored
During periodic detection runs, an error is returned

◆ writeObjectMinMax() [1/2]

bool m5::unit::UnitMLX90614::writeObjectMinMax ( const float toMin,
const float toMax,
const bool apply = true )

Write the minimum and maximum temperatures of the measurement for the object.

Parameters
toMinMinimum celsius
toMaxMaximum celsius
applySettings take effect immediately if true
Returns
True if successful
Note
Valid range between -273.15f and 382.2f
Warning
During periodic detection runs, an error is returned

◆ writeObjectMinMax() [2/2]

template<typename T , typename std::enable_if< std::is_integral< T >::value, std::nullptr_t >::type = nullptr>
bool m5::unit::UnitMLX90614::writeObjectMinMax ( const T toMin,
const T toMax,
const bool apply = true )
inline

Write the minimum and maximum temperatures of the measurement for the object.

Parameters
toMinMinimum raw value
toMaxMaximum raw value
applySettings take effect immediately if true
Returns
True if successful
Warning
During periodic detection runs, an error is returned

◆ writeOutput()

bool m5::unit::UnitMLX90614::writeOutput ( const mlx90614::Output o,
const bool apply = true )

Write the Output.

Parameters
oOutput
applySettings take effect immediately if true
Returns
True if successful
Warning
IRSensor must be set to Dual mode to obtain TO2 output
If only one sensor is installed, the output setting to TO2 is ignored
During periodic detection runs, an error is returned

◆ writePositiveKf2()

bool m5::unit::UnitMLX90614::writePositiveKf2 ( const bool pos,
const bool apply = true )
inline
Deprecated
Use writePositiveKt2 instead

◆ writePositiveKs()

bool m5::unit::UnitMLX90614::writePositiveKs ( const bool pos,
const bool apply = true )

Write the sign of Ks (Config Register1 bit7)

Parameters
posPositive if true
applySettings take effect immediately if true
Returns
True if successful
Warning
This is a factory calibration value. Altering it invalidates calibration.
During periodic detection runs, an error is returned

◆ writePositiveKt2()

bool m5::unit::UnitMLX90614::writePositiveKt2 ( const bool pos,
const bool apply = true )

Write the sign of Kt2 (Config Register1 bit14)

Parameters
posPositive if true
applySettings take effect immediately if true
Returns
True if successful
Warning
This is a factory calibration value. Altering it invalidates calibration.
During periodic detection runs, an error is returned