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);
36 int16_t raw_temperature;
37 if (this->
read(reinterpret_cast<uint8_t *>(&raw_temperature), 2) !=
i2c::ERROR_OK) {
42 raw_temperature = raw_temperature >> 4;
43 float temperature = raw_temperature * TMP102_CONVERSION_FACTOR;
44 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)
void status_set_warning(const char *message="unspecified")
float get_setup_priority() const override
ErrorCode read(uint8_t *data, size_t len)
reads an array of bytes from the device using an I2CBus
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
ErrorCode write(const uint8_t *data, size_t len, bool stop=true)
writes an array of bytes to a device using an I2CBus
No error found during execution of method.
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.
Implementation of SPI Controller mode.