I have a question, how do you get voltage reported to HA?
I can get the Amperage with the ct_clamp platform no problem, but I cannot wrap my head around implementing lamda to do the math and send both amps and voltage to HA.
I don’t believe you can get Voltage from the sensor (assuming you are talking about the mains voltage.
If you mean the Voltage reading from the clamp then change the internal: to false as I have done below:
I just thought I’d put my config in here if anyone likes the look of it, it deesn’t report any fluctuations below 0.1A, can be changed.
sensor:
- platform: ct_clamp
sensor: adc_sensor
name: "True Current" # This first sensor gets the Amps, note that is set to internal only.
id: the_clamp
internal: true
update_interval: 10s
filters:
- calibrate_linear: # Calibrate your own stuff here, mine is only used for the car charger, therefore I'm pulling approx 28A
- 0.00026 -> 0.0
- 0.02856 -> 8.37
- 0.09489 -> 27.9
- platform: template
name: "ESP8266 Current" # This sensor is the one that gets seen by HA, if the reading is below 0.1A then it reports 0, keeps your 0 at 0
id: templated_sensor
lambda: |-
if (id(the_clamp).state > 0.1){
return (id(the_clamp).state);
} else {
return 0.0;
}
device_class: current
update_interval: 10s
accuracy_decimals: 2
unit_of_measurement: A
- platform: template
name: "ESP8266 Watts" # This sensor converts the Amps to Watts (this is assuming that your voltage is 230, if not change the 230 accordingly)
id: esp_watts
lambda: |-
return id(templated_sensor).state * 230;
accuracy_decimals: 2
update_interval: 10s
device_class: power
unit_of_measurement: W
- platform: total_daily_energy # This sensor will give you a Daily kW reading
name: "ESP8266 Daily Energy"
unit_of_measurement: 'kW'
power_id: esp_watts
filters:
- multiply: 0.001
device_class: energy
- platform: adc
pin: A0
id: adc_sensor
- platform: ct_clamp
sensor: adc_sensor
name: "raw values"
internal: true
update_interval: 10s
unit_of_measurement: mA
accuracy_decimals: 5
The SCT-013-xxx CT Clamp does not need the burden resistor (shown in your diagram as “66”), The CT Clamp has this in it already. Other than that your diagram is correct. But one thing, there is an issue with these cheap clamps. The shielding may be connected to the ring, causing interference. Suggested to cut the plug off and hard wire.
I’m not sure what you mean, there is an example of how to change W the kW in the post you referenced, kWh is a measurement of power used over a period of time.
I think in order for this integration to be added to the Energy Dashboard, you have to add it to the Recorder. Again, I’m not sure, but I think I’m right.
I have connected a SCT-013-xxx (20A) CT Clamp exactly as described above, but I am not getting any readings via esphome. As soon as the sensor is connected: NaN. Without the sensor, the values fluctuate.
I have already cut off the connector and soldered it, no improvement. The contacts are correct, I have checked them several times. Even with a load of almost 9A: no measurement. I have already replaced the sensor and don’t know what to do. The capacitor points with negative to GND, doesn’t it?
It should not be due to the calibration, I have already tested the most different variants. The same with the ‘internal’ option.
Does anyone have any ideas? 🤷