9 static const char *
const TAG =
"tem3200";
19 ESP_LOGCONFIG(TAG,
"Setting up TEM3200...");
22 uint16_t raw_temperature(0);
23 uint16_t raw_pressure(0);
27 ESP_LOGCONFIG(TAG,
" I2C Communication Failed...");
34 ESP_LOGE(TAG,
"Invalid RESERVED Device Status");
38 ESP_LOGE(TAG,
"FAULT condition in the SSC or sensing element");
42 ESP_LOGE(TAG,
"STALE data. Data has not been updated since last fetch");
46 ESP_LOGCONFIG(TAG,
" Success...");
50 ESP_LOGCONFIG(TAG,
"TEM3200:");
52 LOG_UPDATE_INTERVAL(
this);
60 uint8_t response[4] = {0x00, 0x00, 0x00, 0x00};
69 status = (
ErrorCode) (response[0] & 0xc0) >> 6;
75 if (status ==
STALE) {
79 err = this->
read(response, 4);
86 status = (
ErrorCode) (response[0] & 0xc0) >> 6;
92 raw_pressure = (((response[0] & 0x3f)) << 8 | response[1]);
95 raw_temperature = ((response[2] << 3) | (response[3] & 0xe0) >> 5);
101 const float temperature_bits_span = 2048;
102 const float temperature_max = 150;
103 const float temperature_min = -50;
104 const float temperature_span = temperature_max - temperature_min;
106 float temperature = (raw_temperature * temperature_span / temperature_bits_span) + temperature_min;
113 uint16_t raw_temperature(0);
114 uint16_t raw_pressure(0);
118 ESP_LOGW(TAG,
"I2C Communication Failed");
125 ESP_LOGE(TAG,
"Failed: Device return RESERVED status");
129 ESP_LOGE(TAG,
"Failed: FAULT condition in the SSC or sensing element");
133 ESP_LOGE(TAG,
"Warning: STALE data. Data has not been updated since last fetch");
140 ESP_LOGD(TAG,
"Got raw pressure=%d, temperature=%.1f°C", raw_pressure, temperature);
const float DATA
For components that import data from directly connected sensors like DHT.
void dump_config() override
void status_set_warning(const char *message="unspecified")
ErrorCode read(uint8_t *data, size_t len)
reads an array of bytes from the device using an I2CBus
i2c::ErrorCode read_(uint8_t &status, uint16_t &raw_temperature, uint16_t &raw_pressure)
float convert_temperature(uint16_t raw_temperature)
float get_setup_priority() const override
No error found during execution of method.
void status_clear_warning()
void publish_state(float state)
Publish a new state to the front-end.
sensor::Sensor * temperature_sensor_
virtual void mark_failed()
Mark this component as failed.
Implementation of SPI Controller mode.
ErrorCode
Error codes returned by I2CBus and I2CDevice methods.
sensor::Sensor * raw_pressure_sensor_
void IRAM_ATTR HOT delay(uint32_t ms)