ESPHome
2026.11.0b6
Loading...
Searching...
No Matches
esphome
components
hlw8032
hlw8032.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/core/component.h
"
4
#include "
esphome/components/sensor/sensor.h
"
5
#include "
esphome/components/uart/uart.h
"
6
7
namespace
esphome::hlw8032
{
8
9
class
HLW8032Component
final :
public
Component
,
public
uart::UARTDevice
{
10
SUB_SENSOR(voltage)
11
SUB_SENSOR(current)
12
SUB_SENSOR(power)
13
SUB_SENSOR(apparent_power)
14
SUB_SENSOR(power_factor)
15
16
public
:
17
void
loop
()
override
;
18
void
dump_config()
override
;
19
20
void
set_current_resistor(
float
current_resistor) { this->
current_resistor_
= current_resistor; }
21
void
set_voltage_divider(
float
voltage_divider) { this->
voltage_divider_
= voltage_divider; }
22
23
protected
:
24
void
parse_data_
();
25
uint32_t
read_uint24_
(uint8_t offset);
26
27
float
current_resistor_
{0.001f};
28
float
voltage_divider_
{1.720f};
29
uint8_t
raw_data_
[24]{};
30
uint8_t
check_
{0};
31
uint8_t
raw_data_index_
{0};
32
bool
header_found_
{
false
};
33
};
34
35
}
// namespace esphome::hlw8032
esphome::Component
Definition
component.h:147
esphome::Component::loop
virtual void loop()
This method will be called repeatedly.
Definition
component.cpp:86
esphome::hlw8032::HLW8032Component
Definition
hlw8032.h:9
esphome::hlw8032::HLW8032Component::raw_data_
uint8_t raw_data_[24]
Definition
hlw8032.h:29
esphome::hlw8032::HLW8032Component::current_resistor_
float current_resistor_
Definition
hlw8032.h:27
esphome::hlw8032::HLW8032Component::raw_data_index_
uint8_t raw_data_index_
Definition
hlw8032.h:31
esphome::hlw8032::HLW8032Component::parse_data_
void parse_data_()
Definition
hlw8032.cpp:66
esphome::hlw8032::HLW8032Component::header_found_
bool header_found_
Definition
hlw8032.h:32
esphome::hlw8032::HLW8032Component::read_uint24_
uint32_t read_uint24_(uint8_t offset)
Definition
hlw8032.cpp:62
esphome::hlw8032::HLW8032Component::voltage_divider_
float voltage_divider_
Definition
hlw8032.h:28
esphome::hlw8032::HLW8032Component::check_
uint8_t check_
Definition
hlw8032.h:30
esphome::uart::UARTDevice
Definition
uart.h:15
component.h
esphome::hlw8032
Definition
hlw8032.cpp:5
uint32_t
static void uint32_t
Definition
crash_handler.cpp:153
sensor.h
uart.h
Generated by
1.12.0