9 ESP_LOGV(TAG,
"Sending measurement request");
19 if (line !=
nullptr && line[0] !=
'\0') {
20 char *token = strtok(line,
",");
23 int counts = (int) strtol(token,
nullptr, 10);
24 token = strtok(
nullptr,
",");
27 float permittivity = (float) strtod(token,
nullptr);
28 token = strtok(
nullptr,
",");
31 float moisture = (float) strtod(token,
nullptr);
32 token = strtok(
nullptr,
",");
36 token = strtok(
nullptr,
",");
39 float voltage = (float) strtod(token,
nullptr);
65 ESP_LOGCONFIG(TAG,
"SMT100:");
71 LOG_UPDATE_INTERVAL(
this);
char * feed(uint8_t c)
Feed one byte; returns the completed line (empty lines included), valid until the next call,...
void log_if_overflowed(const char *tag) const
Log the shared "line dropped" warning when the last feed() overflowed.
void publish_state(float state)
Publish a new state to the front-end.
LineReader< LINE_BUFFER_SIZE, '\r', '\n'> line_reader_
sensor::Sensor * temperature_sensor_
sensor::Sensor * counts_sensor_
sensor::Sensor * voltage_sensor_
void dump_config() override
sensor::Sensor * moisture_sensor_
sensor::Sensor * permittivity_sensor_
void write_str(const char *str)
bool read_available(F &&on_byte)
Same as read_available_chunks(), calling on_byte(uint8_t) once per byte.
ESPHOME_LOG_TAG(TAG, "smt100")