SEN0214 Junk Data
Russell.Manning 2025-01-28 10:50:20 649 Views3 Replies I haven't put a lot of time into it with other projects I've been working on but efforts in getting any useful data out of this SEN0214 has failed. It ether doesn't really change with power draw or none, or it floats around super low values. The GPIO's used are correct along with the wiring for measuring.
Snippet from Home Assistant for this sensor:
sensor:
- platform: adc
pin: GPIO33 # Use an ADC pin available on the ESP32
id: current_sensor_adc
name: "Current Sensor Raw Voltage"
unit_of_measurement: "V"
accuracy_decimals: 3
attenuation: 11db # Allow 3.3V input
update_interval: 1s
- platform: template
name: "Measured Current (DC)"
unit_of_measurement: "A"
accuracy_decimals: 2
update_interval: 1s
lambda: |-
// Read ADC voltage
float v_adc = id(current_sensor_adc).state;
// Reference Voltage (5V supply for SEN0214)
const float Vref = 5.0; // Sensor power supply
// Midpoint Voltage (0A)
const float midpoint = Vref / 2.0; // 2.5V
// Sensitivity
const float sensitivity = 0.1; // 100mV per amp
// Calculate current
float current = (v_adc - midpoint) / sensitivity;
return abs(current) > 0.05 ? current : 0.0; // Filter small noise values
Any pointers?
Here is a breakdown of why getting "junk data" :
1. The Voltage Mismatch (The Biggest Culprit)
The SEN0214 is a 5V sensor. Its output voltage is proportional to the current:
At 0 Amps: The output is VCC/2 (approx. 2.5V).
Positive/Negative Current: The voltage swings up toward 5V or down toward 0V.
The Problem: The ESP32 ADC is non-linear and generally only handles up to 3.3V (even with attenuation).
If you power the sensor with 5V but connects it directly to the ESP32, they risk damaging the GPIO or getting highly inaccurate readings because the ESP32's ADC accuracy drops significantly near its upper limit. The ESP32 ADC is also notorious for "noise" and a "dead zone" near 0V and 3.3V.
2. AC vs. DC Measurement Logic
The Hardware Reality: The ACS712 outputs an instantaneous voltage. If you are measuring 60Hz AC, the output signal is a sine wave oscillating 60 times per second around the 2.5V midpoint.
The Code Error: The code provided in the forum is for DC. It takes a single snapshot of the voltage once per second (update_interval: 1s).
Result: You are catching a random point on the sine wave every second. To measure AC, you must sample very rapidly (thousands of times per second) and calculate the RMS (Root Mean Square) current.
3. ESP32 ADC Attenuation & Calibration
Home Assistant YAML shows attenuation: 11db. While 11dB allows the ESP32 to "see" 3.3V, the sensor's midpoint is 2.5V. On an ESP32, 2.5V is already in a region where the ADC starts to lose linearity.Without a voltage divider, the sensor could easily output 4V+ at high current, which is "blind" to the ESP32 and potentially harmful.
R2D2C3PO I have been struggling with these senors for a while and am having a similar problem.
I am trying to measure AC mains power (US 115V @ 60Hz) and have one wired in series to the load side* of a power cable, along with an inline voltage+amp meter, connected to a plug strip with different AC loads.
*the module has IN and OUT marked, but being an AC voltage there should be no polarity. And obviously I have tried it hooked up both ways.
When both the example code and my own did not seem to be working I started taking readings with my Fluke directly from the sensor, while supplying it with 5 volts from the MCU**.
I am getting a consistent reading of 2.5V and if I vary the current draw (using a heat gun as someone else here did) between 0.5A and ~9A the readings change by perhaps 0.1V (2.6 V reading). According to the Allegro datasheet the voltage should be linear between 2.5 to 4.5V.
Switching the meter to AC voltage I get 0V and reading frequency 0 Hz. So it's not an AC voltage coming out.
**just in case anyone finds this detail helpful: I was originally trying to read the DFRobot ADS1115 16-bit ADC module to read the voltage. However my MCU is a 3V3 device which is what is supplied to the I2C. But the datasheet says the Vcc minimum is 4.5V so I am using the regulated 5V form USB to the ADC.
Robb Drinkwater 

