Open PeteBa opened 1 year ago
Did you ever resolve this? I'm having trouble getting mine to read anything but zero. The ADC gives a nice floating value when the expansion board isnt connected, but I get the same fixed voltage reading across all 4 channels when the board is connected
Below is with a SCT013-000 (100A) CT with about 30A AC running through it, on a ESP32-WROOM-32. The 1.01400v is the same across all 4 channels
[19:29:21][D][ct_clamp:041]: 'Car charger CT' - Raw AC Value: 0.000A after 1 different samples (5 SPS)
[19:29:21][D][sensor:094]: 'Car charger CT': Sending state 0.00000 A with 2 decimals of accuracy
[19:29:25][D][sensor:094]: 'ct_input_1': Sending state 1.01400 V with 2 decimals of accuracy
Looking at your log extract, it shows 5 samples per second for the ADC. This should be reading many 100s of samples if setup correctly. You could either have the ESPHome sampling period way to short or the CT is not properly connected. Could the CT be wired incorrectly to the phono jack ? Also, double check, you are shorting the two right-most pins of the 1V/50mA jumper.
My original post above relates to a hardware design choice on the ESP32-S2 board that sets the bias voltage a bit high. This causes readings to be low when measuring currents higher than 50-60% of the CT's nominal value. This can be addressed using the calibrate_linear
filter.
I use the ESPHome config below for the ESP32-S2 board:
esphome:
name: current-sensor-s2
esp32:
board: lolin_s2_mini
variant: ESP32S2
framework:
type: arduino
wifi:
domain: !secret wifi_domain
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
password: !secret wifi_ap_password
api:
logger:
ota:
sensor:
################ Channel 4 - 100A CT 50mA ################
- platform: adc
pin: GPIO4
name: "Current Sensor S2 Channel 4 ADC"
id: channel_4_adc
attenuation: 11db
internal: true
- platform: ct_clamp
sensor: channel_4_adc
name: "Current Sensor S2 Channel 4 Current"
update_interval: 2s
sample_duration: 200ms
filters:
- calibrate_linear:
method: exact
datapoints:
- 0 -> 0
- 0.514 -> 51.4
- 0.788 -> 106.08
- sliding_window_moving_average:
window_size: 5
send_every: 5
send_first_at: 5
You're right, my problem is unrelated to this ticket, but you have solved my problem. It was the attenuation - I should have read the docs, but I had convinced myself that it did work at one point, so I assumed I didn't need attentuation. Thanks!
I have a 5 amp CT (SCT013-005) with a 1V output. Unfortunately, current readings appear to max out at around 4.7 amps. I am using the ESP32-S2 board, have the jumper set to 1V and using 11db attenuation. I think this is due to the bias voltage being a bit too high on this board.
The CT generates an AC output voltage from 0-1Vrms over the CT's range. This is equivalent to a DC voltage that varies between -1.414V to +1.414V. Looking at the board schematic, I can see the bias voltage is set to 1.65V (i.e. 3.3/2). so the voltage seen at the ESP32 gpio pin will vary between 0.236-3.064V.
However, the esspresif specs here states the widest measurable range of the ESP32-S2 to be 0-2.5V when configured with 11db attenuation. Unfortunately, this doesn't cover the full working range of the CT and I suspect the readings are getting damped and clipped at the high end.
Have I understood this correctly ? I'm a bit new to this stuff so could be misunderstanding things here but, if correct, would it make sense to alter the bias voltage to, say, 1.25V, allowing the full range of measurements.