ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
cse7766.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace esphome::cse7766 {
9
10static constexpr size_t CSE7766_RAW_DATA_SIZE = 24;
11
12class CSE7766Component final : public Component, public uart::UARTDevice {
13 SUB_SENSOR(voltage)
14 SUB_SENSOR(current)
15 SUB_SENSOR(power)
16 SUB_SENSOR(energy)
17 SUB_SENSOR(apparent_power)
18 SUB_SENSOR(reactive_power)
19 SUB_SENSOR(power_factor)
20
21 public:
22 void loop() override;
23 void dump_config() override;
24
25 protected:
26 bool check_byte_();
27 void parse_data_();
28 uint32_t get_24_bit_uint_(uint8_t start_index) const {
29 return encode_uint24(this->raw_data_[start_index], this->raw_data_[start_index + 1],
30 this->raw_data_[start_index + 2]);
31 }
32
33 uint8_t raw_data_[CSE7766_RAW_DATA_SIZE];
34 uint8_t raw_data_index_{0};
35 uint16_t cf_pulses_last_{0};
38 // Power cycle of the last frame that carried a new power measurement, 0 if none
40};
41
42} // namespace esphome::cse7766
virtual void loop()
This method will be called repeatedly.
Definition component.cpp:86
uint32_t get_24_bit_uint_(uint8_t start_index) const
Definition cse7766.h:28
uint8_t raw_data_[CSE7766_RAW_DATA_SIZE]
Definition cse7766.h:33
constexpr uint32_t encode_uint24(uint8_t byte1, uint8_t byte2, uint8_t byte3)
Encode a 24-bit value given three bytes in most to least significant byte order.
Definition helpers.h:1047
static void uint32_t