8 static const char *
const TAG =
"tmp102";
10 static const uint8_t TMP102_ADDRESS = 0x48;
11 static const uint8_t TMP102_REGISTER_TEMPERATURE = 0x00;
12 static const uint8_t TMP102_REGISTER_CONFIGURATION = 0x01;
13 static const uint8_t TMP102_REGISTER_LOW_LIMIT = 0x02;
14 static const uint8_t TMP102_REGISTER_HIGH_LIMIT = 0x03;
16 static const float TMP102_CONVERSION_FACTOR = 0.0625;
21 ESP_LOGCONFIG(TAG,
"TMP102:");
24 ESP_LOGE(TAG,
"Communication with TMP102 failed!");
26 LOG_UPDATE_INTERVAL(
this);
27 LOG_SENSOR(
" ",
"Temperature",
this);
31 uint16_t raw_temperature;
37 if (this->
read(reinterpret_cast<uint8_t *>(&raw_temperature), 2) !=
i2c::ERROR_OK) {
43 raw_temperature = raw_temperature >> 4;
44 float temperature = raw_temperature * TMP102_CONVERSION_FACTOR;
45 ESP_LOGD(TAG,
"Got Temperature=%.1f°C", temperature);
void dump_config() override
const float DATA
For components that import data from directly connected sensors like DHT.
uint16_t i2ctohs(uint16_t i2cshort)
void update() override
Update the sensor values (temperature)
float get_setup_priority() const override
ErrorCode read(uint8_t *data, size_t len)
void status_clear_warning()
void setup() override
Setup (reset) the sensor and check connection.
void publish_state(float state)
Publish a new state to the front-end.
ErrorCode write(const uint8_t *data, uint8_t len, bool stop=true)
void status_set_warning()
Implementation of SPI Controller mode.
void IRAM_ATTR HOT delay(uint32_t ms)