ESPHome 2026.12.0-dev
Loading...
Searching...
No Matches
smt100.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace esphome::smt100 {
9
19
22bool parse_measurements(const char *line, float *values);
23
25 // The longest answer, "65535,100.00,100.00,-20.000,15.00", is 33 characters
26 static constexpr uint16_t LINE_BUFFER_SIZE = 48;
27
28 public:
29 void setup() override;
30 void dump_config() override;
31 void loop() override;
32 void update() override;
33
34 SUB_SENSOR(counts)
35 SUB_SENSOR(permittivity)
36 SUB_SENSOR(temperature)
37 SUB_SENSOR(moisture)
38 SUB_SENSOR(voltage)
39
40 protected:
41 enum class State : uint8_t {
42 STATE_IDLE,
43 STATE_REQUEST_DUE,
44 STATE_AWAITING_ANSWER,
45 };
46
47 void send_request_(uint32_t now);
49 void finish_request_(const char *answer);
50
53 State state_{State::STATE_IDLE};
54};
55
56} // namespace esphome::smt100
Collects bytes into NUL terminated lines of up to N - 1 characters; IGNORE_CHAR bytes are skipped and...
Definition line_reader.h:15
This class simplifies creating components that periodically check a state.
Definition component.h:542
LineReader< LINE_BUFFER_SIZE > line_reader_
Definition smt100.h:52
SUB_SENSOR(counts) SUB_SENSOR(permittivity) SUB_SENSOR(temperature) SUB_SENSOR(moisture) SUB_SENSOR(voltage) protected void send_request_(uint32_t now)
Definition smt100.cpp:83
void finish_request_(const char *answer)
End the request; answer is the line the sensor sent, or nullptr when it sent none in time.
Definition smt100.cpp:93
Field
Order of the values in the answer to GetAllMeasurements.
Definition smt100.h:11
@ FIELD_TEMPERATURE
Definition smt100.h:15
@ FIELD_PERMITTIVITY
Definition smt100.h:13
bool parse_measurements(const char *line, float *values)
Read "counts,permittivity,moisture,temperature,voltage" into values[FIELD_COUNT].
Definition smt100.cpp:20
void const char int line
Definition log.h:110
static void uint32_t
uint16_t temperature
Definition sun_gtil2.cpp:12