8static 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);
BedjetMode mode
BedJet operating mode.
virtual void mark_failed()
Mark this component as failed.
void status_clear_warning()
bool write_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
bool read_byte(uint8_t a_register, uint8_t *data, bool stop=true)
sensor::Sensor * temperature_
void dump_config() override
sensor::Sensor * altitude_
sensor::Sensor * pressure_
void publish_state(float state)
Publish a new state to the front-end.
@ MPL3115A2_PT_DATA_CFG_TDEFE
@ MPL3115A2_PT_DATA_CFG_PDEFE
@ MPL3115A2_PT_DATA_CFG_DREM
@ MPL3115A2_CTRL_REG1_OS128
@ MPL3115A2_CTRL_REG1_OST
@ MPL3115A2_CTRL_REG1_ALT
@ MPL3115A2_CTRL_REG1_RST
@ MPL3115A2_REGISTER_STATUS_PDR
@ MPL3115A2_REGISTER_PRESSURE_MSB
@ MPL3115A2_REGISTER_STATUS
Providing packet encoding functions for exchanging data with a remote host.
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.
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.
void IRAM_ATTR HOT delay(uint32_t ms)