7 static const char *
const TAG =
"hlw8012";
10 static const uint32_t HLW8012_CLOCK_FREQUENCY = 3579000;
13 float reference_voltage = 0;
14 ESP_LOGCONFIG(TAG,
"Setting up HLW8012...");
22 reference_voltage = 1.218f;
29 reference_voltage = 2.43f;
31 64.0f / 24.0f / HLW8012_CLOCK_FREQUENCY;
37 ESP_LOGCONFIG(TAG,
"HLW8012:");
38 LOG_PIN(
" SEL Pin: ", this->
sel_pin_)
39 LOG_PIN(
" CF Pin: ", this->
cf_pin_)
40 LOG_PIN(
" CF1 Pin: ", this->
cf1_pin_)
41 ESP_LOGCONFIG(TAG,
" Change measurement mode every %" PRIu32, this->
change_mode_every_);
42 ESP_LOGCONFIG(TAG,
" Current resistor: %.1f mΩ", this->
current_resistor_ * 1000.0f);
44 LOG_UPDATE_INTERVAL(
this)
76 ESP_LOGD(TAG,
"Got power=%.1fW, current=%.1fA", power, current);
82 ESP_LOGD(TAG,
"Got power=%.1fW, voltage=%.1fV", power, voltage);
101 ESP_LOGV(TAG,
"Changing mode to %s mode", this->
current_mode_ ?
"CURRENT" :
"VOLTAGE");
virtual void digital_write(bool value)=0
const float DATA
For components that import data from directly connected sensors like DHT.
uint32_t change_mode_every_
sensor::Sensor * energy_sensor_
sensor::Sensor * power_sensor_
float current_multiplier_
InternalGPIOPin * cf_pin_
virtual pulse_counter_t read_raw_value()=0
void publish_state(float state)
Publish a new state to the front-end.
pulse_counter::PulseCounterStorageBase & cf_store_
virtual uint32_t get_update_interval() const
Get the update interval in ms of this sensor.
HLW8012SensorModels sensor_model_
sensor::Sensor * voltage_sensor_
float get_setup_priority() const override
float voltage_multiplier_
Implementation of SPI Controller mode.
sensor::Sensor * current_sensor_
pulse_counter::PulseCounterStorageBase & cf1_store_
InternalGPIOPin * cf1_pin_
void dump_config() override
uint64_t cf_total_pulses_
virtual bool pulse_counter_setup(InternalGPIOPin *pin)=0