9 static const uint8_t MLX90614_RAW_IR_1 = 0x04;
10 static const uint8_t MLX90614_RAW_IR_2 = 0x05;
11 static const uint8_t MLX90614_TEMPERATURE_AMBIENT = 0x06;
12 static const uint8_t MLX90614_TEMPERATURE_OBJECT_1 = 0x07;
13 static const uint8_t MLX90614_TEMPERATURE_OBJECT_2 = 0x08;
15 static const uint8_t MLX90614_TOMAX = 0x20;
16 static const uint8_t MLX90614_TOMIN = 0x21;
17 static const uint8_t MLX90614_PWMCTRL = 0x22;
18 static const uint8_t MLX90614_TARANGE = 0x23;
19 static const uint8_t MLX90614_EMISSIVITY = 0x24;
20 static const uint8_t MLX90614_CONFIG = 0x25;
21 static const uint8_t MLX90614_ADDR = 0x2E;
22 static const uint8_t MLX90614_ID1 = 0x3C;
23 static const uint8_t MLX90614_ID2 = 0x3D;
24 static const uint8_t MLX90614_ID3 = 0x3E;
25 static const uint8_t MLX90614_ID4 = 0x3F;
27 static 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);
const float DATA
For components that import data from directly connected sensors like DHT.
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
sensor::Sensor * ambient_sensor_
void status_set_warning(const char *message="unspecified")
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
float get_setup_priority() const override
uint8_t crc8_pec_(const uint8_t *data, uint8_t len)
No error found during execution of method.
void status_clear_warning()
void publish_state(float state)
Publish a new state to the front-end.
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.
sensor::Sensor * object_sensor_
uint8_t address_
store the address of the device on the bus
bool write_bytes_(uint8_t reg, uint16_t data)
virtual void mark_failed()
Mark this component as failed.
Implementation of SPI Controller mode.
void dump_config() override
void IRAM_ATTR HOT delay(uint32_t ms)
bool write_bytes(uint8_t a_register, const uint8_t *data, uint8_t len, bool stop=true)