Well, I added a CT clamp to one of my Wemos D1 mini, using an ADC (ADS1115) in differential mode. I have an SCT13-000 which outputs 50mA current instead of 1V, so I added a 33ohm burden resistor. I live in Argentina so the mains voltage is 220v.
What I’m getting from the sensor right now:
[19:20:30][D][sensor:092]: 'Measured Current': Sending state 0.05401 A with 2 decimals of accuracy
[19:20:33][D][sensor:092]: 'Measured Current': Sending state 0.03408 A with 2 decimals of accuracy
[19:20:35][D][sensor:092]: 'Measured Current': Sending state 0.05031 A with 2 decimals of accuracy
[19:20:37][D][sensor:092]: 'Measured Current': Sending state 0.04377 A with 2 decimals of accuracy
[19:20:41][D][sensor:092]: 'Measured Current': Sending state 0.04759 A with 2 decimals of accuracy
[19:20:43][D][sensor:092]: 'Measured Current': Sending state 0.04059 A with 2 decimals of accuracy
[19:20:44][D][sensor:092]: 'Measured Current': Sending state 0.04366 A with 2 decimals of accuracy
[19:24:33][D][sensor:092]: 'Measured Current': Sending state 0.03712 A with 2 decimals of accuracy
[19:24:35][D][sensor:092]: 'Measured Current': Sending state 0.04597 A with 2 decimals of accuracy
[19:24:37][D][sensor:092]: 'Measured Current': Sending state 0.05084 A with 2 decimals of accuracy
[19:24:39][D][sensor:092]: 'Measured Current': Sending state 0.04519 A with 2 decimals of accuracy
[19:24:40][D][sensor:092]: 'Measured Current': Sending state 0.03390 A with 2 decimals of accuracy
[19:24:42][D][sensor:092]: 'Measured Current': Sending state 0.05371 A with 2 decimals of accuracy
[19:24:45][D][sensor:092]: 'Measured Current': Sending state 0.04518 A with 2 decimals of accuracy
[19:24:46][D][sensor:092]: 'Measured Current': Sending state 0.03873 A with 2 decimals of accuracy
[19:24:49][D][sensor:092]: 'Measured Current': Sending state 0.03463 A with 2 decimals of accuracy
[19:24:51][D][sensor:092]: 'Measured Current': Sending state 0.03772 A with 2 decimals of accuracy
[19:24:52][D][sensor:092]: 'Measured Current': Sending state 0.05454 A with 2 decimals of accuracy
[19:24:55][D][sensor:092]: 'Measured Current': Sending state 0.04433 A with 2 decimals of accuracy
[19:24:57][D][sensor:092]: 'Measured Current': Sending state 0.03305 A with 2 decimals of accuracy
[19:24:59][D][sensor:092]: 'Measured Current': Sending state 0.03654 A with 2 decimals of accuracy
As you can see, readings are not stable. Consumption measured with a multimeter is 2.28A
As per the doc, I should add this to the config
filters:
- calibrate_linear:
# Measured value of 0 maps to 0A
- 0 -> 0
# Known load: 2.28A
# Value shown in logs: xxxx
- xxxx -> 2.28
But since I’m not getting a stable reading, how could I map those values to 2.28A?
filters:
- calibrate_linear:
# Measured value of 0 maps to 0A
- 0 -> 0
# Known load: 2.28A
# Value shown in logs: xxxx
- 0.03 -> 2.28
- 0.04 -> 2.28
- 0.05 -> 2.28
- 0.06 -> 2.28
Now I’m getting this in the logs:
[20:43:08][D][ct_clamp:051]: 'Measured Current' - Raw Value: 0.00A
[20:43:08][D][sensor:092]: 'Measured Current': Sending state 0.24449 A with 2 decimals of accuracy
[20:43:10][D][ct_clamp:051]: 'Measured Current' - Raw Value: 0.00A
[20:43:10][D][sensor:092]: 'Measured Current': Sending state 0.24578 A with 2 decimals of accuracy
[20:43:12][D][ct_clamp:051]: 'Measured Current' - Raw Value: 0.02A
[20:43:12][D][sensor:092]: 'Measured Current': Sending state 1.43071 A with 2 decimals of accuracy
[20:43:14][D][ct_clamp:051]: 'Measured Current' - Raw Value: 0.04A
[20:43:14][D][sensor:092]: 'Measured Current': Sending state 2.23891 A with 2 decimals of accuracy
[20:43:16][D][ct_clamp:051]: 'Measured Current' - Raw Value: 0.04A
[20:43:16][D][sensor:092]: 'Measured Current': Sending state 2.08680 A with 2 decimals of accuracy
[20:43:18][D][ct_clamp:051]: 'Measured Current' - Raw Value: 0.05A
[20:43:18][D][sensor:092]: 'Measured Current': Sending state 2.57242 A with 2 decimals of accuracy
[20:43:20][D][ct_clamp:051]: 'Measured Current' - Raw Value: 0.06A
[20:43:20][D][sensor:092]: 'Measured Current': Sending state 2.97451 A with 2 decimals of accuracy
[20:43:22][D][ct_clamp:051]: 'Measured Current' - Raw Value: 0.04A
[20:43:22][D][sensor:092]: 'Measured Current': Sending state 2.04726 A with 2 decimals of accuracy
[20:43:24][D][ct_clamp:051]: 'Measured Current' - Raw Value: 0.05A
[20:43:24][D][sensor:092]: 'Measured Current': Sending state 2.49952 A with 2 decimals of accuracy
[20:43:26][D][ct_clamp:051]: 'Measured Current' - Raw Value: 0.05A
[20:43:26][D][sensor:092]: 'Measured Current': Sending state 2.60993 A with 2 decimals of accuracy
[20:43:28][D][ct_clamp:051]: 'Measured Current' - Raw Value: 0.04A
[20:43:28][D][sensor:092]: 'Measured Current': Sending state 2.41457 A with 2 decimals of accuracy
[20:43:30][D][ct_clamp:051]: 'Measured Current' - Raw Value: 0.05A
[20:43:30][D][sensor:092]: 'Measured Current': Sending state 2.50434 A with 2 decimals of accuracy
[20:43:32][D][ct_clamp:051]: 'Measured Current' - Raw Value: 0.04A
[20:43:32][D][sensor:092]: 'Measured Current': Sending state 2.16493 A with 2 decimals of accuracy
[20:43:34][D][ct_clamp:051]: 'Measured Current' - Raw Value: 0.04A
[20:43:34][D][sensor:092]: 'Measured Current': Sending state 2.23563 A with 2 decimals of accuracy
If I get a raw value of 0.04A, which is mapped to 2.27A in the sensor config file, why am I seeing 2.42A on the UI?
[20:43:28][D][ct_clamp:051]: 'Measured Current' - Raw Value: 0.04A
[20:43:28][D][sensor:092]: 'Measured Current': Sending state 2.41457 A with 2 decimals of accuracy
calibrate_linear doesn’t do what you think it does. From the documentation:
The arguments are a list of data points, each in the form MEASURED -> TRUTH . ESPHome will then fit a linear equation to the values (using least squares). So you need to supply at least two values.
I’m not quite following why you want everything in that range of data to report the same value. Usually you would measure the average real power over some time and also measure the average signal measurement. Then use that to calibrate. If you see sensor noise, you can use moving averages or similar to smooth the signal.
But, if there is a reason, you can use a lambda filter to do exactly what you want.
calibrate_linear fits a single line to all your mapped data, it doesn’t use linear interpolation between them. If recommend using a single mapped value for the upper range and smooth it.
If you want it to work the way you proposed, you could use a lambda filter and write it exactly how you want it to work.
Hola @vazquezjm, estoy con un tema similar al tuyo y al leer tu post vi que sos argentino así que quería aprovechar comentarte mi situación y para hacerte algunas consultas.
Acabo de arrancar con el uso de home assistant y una de las primeras cosas que estoy intentando hacer es registrar el consumo eléctrico de mi casa, para esto estoy usando una Wemos D1 y una “pinza” de 50A-1V. Para simplificar, estoy usando ESPhome, lo que al momento de intentar ver lo que está pasando es mas una complicación que una ayuda. El problema que tengo supongo es ruido en la señal, lo que hace que me esté resultando difícil la calibración… siempre tengo un offset y aveces valores negativos (muy chicos, pero negativos al fin). Ahora las consultas: en tu caso que circuito usaste, el básico que se ve en todos lados o tuviste que hacer alguna modificación? lograste tener una medición mas o menos precisa con el método de calibración lineal o fuiste por alguno mas complejo?