9static const uint8_t MLX90614_RAW_IR_1 = 0x04;
10static const uint8_t MLX90614_RAW_IR_2 = 0x05;
11static const uint8_t MLX90614_TEMPERATURE_AMBIENT = 0x06;
12static const uint8_t MLX90614_TEMPERATURE_OBJECT_1 = 0x07;
13static const uint8_t MLX90614_TEMPERATURE_OBJECT_2 = 0x08;
15static const uint8_t MLX90614_TOMAX = 0x20;
16static const uint8_t MLX90614_TOMIN = 0x21;
17static const uint8_t MLX90614_PWMCTRL = 0x22;
18static const uint8_t MLX90614_TARANGE = 0x23;
19static const uint8_t MLX90614_EMISSIVITY = 0x24;
20static const uint8_t MLX90614_CONFIG = 0x25;
21static const uint8_t MLX90614_ADDR = 0x2E;
22static const uint8_t MLX90614_ID1 = 0x3C;
23static const uint8_t MLX90614_ID2 = 0x3D;
24static const uint8_t MLX90614_ID3 = 0x3E;
25static const uint8_t MLX90614_ID4 = 0x3F;
27static const char *
const TAG =
"mlx90614";
30 ESP_LOGCONFIG(TAG,
"Setting up MLX90614...");
32 ESP_LOGE(TAG,
"Communication with MLX90614 failed!");
41 uint16_t value = (uint16_t) (this->
emissivity_ * 65535);
55 for (uint8_t i = 0; i <
len; i++) {
57 for (uint8_t j = 0; j < 8; j++) {
58 bool carry = (crc ^ in) & 0x80;
79 ESP_LOGCONFIG(TAG,
"MLX90614:");
82 ESP_LOGE(TAG,
"Communication with MLX90614 failed!");
84 LOG_UPDATE_INTERVAL(
this);
92 uint8_t emissivity[3];
97 uint8_t raw_object[3];
103 uint8_t raw_ambient[3];
109 float ambient = raw_ambient[1] & 0x80 ? NAN :
encode_uint16(raw_ambient[1], raw_ambient[0]) * 0.02f - 273.15f;
110 float object = raw_object[1] & 0x80 ? NAN :
encode_uint16(raw_object[1], raw_object[0]) * 0.02f - 273.15f;
112 ESP_LOGD(TAG,
"Got Temperature=%.1f°C Ambient=%.1f°C",
object, ambient);
virtual void mark_failed()
Mark this component as failed.
void status_set_warning(const char *message="unspecified")
void status_clear_warning()
bool write_bytes(uint8_t a_register, const uint8_t *data, uint8_t len, bool stop=true)
uint8_t address_
store the address of the device on the bus
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
ErrorCode read_register(uint8_t a_register, uint8_t *data, size_t len, bool stop=true)
reads an array of bytes from a specific register in the I²C device
void dump_config() override
uint8_t crc8_pec_(const uint8_t *data, uint8_t len)
bool write_bytes_(uint8_t reg, uint16_t data)
float get_setup_priority() const override
sensor::Sensor * object_sensor_
sensor::Sensor * ambient_sensor_
void publish_state(float state)
Publish a new state to the front-end.
@ ERROR_OK
No error found during execution of method.
const float DATA
For components that import data from directly connected sensors like DHT.
Providing packet encoding functions for exchanging data with a remote host.
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.
void IRAM_ATTR HOT delay(uint32_t ms)