10static const uint8_t READ_COMMAND = 0xAC;
13 uint16_t raw_temperature(0);
14 uint16_t raw_pressure(0);
17 ESP_LOGCONFIG(TAG, ESP_LOG_MSG_COMM_FAIL);
23void NPI19Component::dump_config() {
24 ESP_LOGCONFIG(TAG,
"NPI19:");
26 LOG_UPDATE_INTERVAL(
this);
27 LOG_SENSOR(
" ",
"Raw Pressure", this->raw_pressure_sensor_);
28 LOG_SENSOR(
" ",
"Temperature", this->temperature_sensor_);
39 uint8_t response[4] = {0x00, 0x00, 0x00, 0x00};
47 raw_pressure =
encode_uint16(response[0] & 0x3F, response[1]);
50 raw_temperature =
encode_uint16(response[2], response[3]) >> 5;
69 const float temperature_bits_span = 2048;
70 const float temperature_max = 150;
71 const float temperature_min = -50;
72 const float temperature_span = temperature_max - temperature_min;
74 float temperature = (raw_temperature * temperature_span / temperature_bits_span) + temperature_min;
79void NPI19Component::update() {
80 uint16_t raw_temperature(0);
81 uint16_t raw_pressure(0);
86 ESP_LOGW(TAG, ESP_LOG_MSG_COMM_FAIL);
93 ESP_LOGD(TAG,
"Got raw pressure=%d, temperature=%.1f°C", raw_pressure,
temperature);
95 PUBLISH_STATE(this->temperature_sensor_,
temperature);
96 PUBLISH_STATE(this->raw_pressure_sensor_, raw_pressure);