8 static const char *
const TAG =
"mpl3115a2";
11 ESP_LOGCONFIG(TAG,
"Setting up MPL3115A2...");
13 uint8_t whoami = 0xFF;
35 ESP_LOGCONFIG(TAG,
"MPL3115A2:");
38 switch (this->error_code_) {
40 ESP_LOGE(TAG,
"Communication with MPL3115A2 failed!");
43 ESP_LOGE(TAG,
"MPL3115A2 has invalid id");
46 ESP_LOGE(TAG,
"Setting up MPL3115A2 registers failed!");
50 LOG_UPDATE_INTERVAL(
this);
52 LOG_SENSOR(
" ",
"Pressure", this->
pressure_);
53 LOG_SENSOR(
" ",
"Altitude", this->
altitude_);
74 uint8_t buffer[5] = {0, 0, 0, 0, 0};
79 int32_t alt =
encode_uint32(buffer[0], buffer[1], buffer[2], 0);
80 altitude = float(alt) / 65536.0;
83 uint32_t p =
encode_uint32(0, buffer[0], buffer[1], buffer[2]);
93 ESP_LOGD(TAG,
"Got Temperature=%.1f°C Altitude=%.1f Pressure=%.1f", temperature, altitude,
pressure);
bool read_byte(uint8_t a_register, uint8_t *data, bool stop=true)
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
constexpr uint32_t encode_uint32(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint8_t byte4)
Encode a 32-bit value given four bytes in most to least significant byte order.
sensor::Sensor * temperature_
void status_clear_warning()
BedjetMode mode
BedJet operating mode.
sensor::Sensor * altitude_
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.
void dump_config() override
sensor::Sensor * pressure_
bool write_byte(uint8_t a_register, uint8_t data, bool stop=true)
virtual void mark_failed()
Mark this component as failed.
Implementation of SPI Controller mode.
void IRAM_ATTR HOT delay(uint32_t ms)