6 namespace sen0321_sensor {
8 static const char *
const TAG =
"sen0321_sensor.sensor";
11 ESP_LOGCONFIG(TAG,
"Setting up sen0321...");
12 if (!this->
write_byte(SENSOR_MODE_REGISTER, SENSOR_MODE_AUTO)) {
13 ESP_LOGW(TAG,
"Error setting measurement mode.");
21 ESP_LOGCONFIG(TAG,
"DF Robot Ozone Sensor sen0321:");
24 ESP_LOGE(TAG,
"Communication with sen0321 failed!");
26 LOG_UPDATE_INTERVAL(
this);
31 this->
read_bytes(SENSOR_AUTO_READ_REG, result, (uint8_t) 2);
32 this->
publish_state(((uint16_t) (result[0] << 8) + result[1]));
bool read_bytes(uint8_t a_register, uint8_t *data, uint8_t len)
Compat APIs All methods below have been added for compatibility reasons.
void publish_state(float state)
Publish a new state to the front-end.
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 dump_config() override