Why is my power sensor reading spiking randomly?

Oct 21, 2026 Last reply: 1 day ago 4 Replies

First reply

tundra_scout_1983

The jumpiness you're seeing is usally related to two things: either the sampling rate is too low for how fast your loads are cycling, or there's electrical noise on the ADC line that the ESP32 is picking up. If you're just running the default loop timing, the sampling rate…

Read the full reply

I am trying to get some basic power monitoring running using an ESP32 and a couple of CT clamps for my workbench circuits. I managed to get the sensor data into ESPHome, which is progress, but the readings are extremely jumpy. When I'm running a steady load, the power usage jumps up and down by a lot, even though the actual draw feels stable.



I configured the analog input pin and set up the basic sensor platform like the examples show. It seems like the data is coming through, but it never stays consistent. I’m wondering if I need to adjust the sampling rate or perhaps there is a specific calibration step for this kind of analog current sensing I am missing. Is this huge fluctuation normal, or am I overlooking something in the setup?


The jumpiness you're seeing is usally related to two things: either the sampling rate is too low for how fast your loads are cycling, or there's electrical noise on the ADC line that the ESP32 is picking up. If you're just running the default loop timing, the sampling rate might not be fast enough to capture the quick spikes and dips, making the average look unstable. What I found when I was setting up monitoring for a small network closet circuit was that simply increasing the frequency at which the ESP32 reads the analog pin helped stabilize the output significantly. If you're using a custom loop or function to read the sensor, try increasing the frequency to something like every 50 milliseconds, or even faster if the processor can handle it. More importantly, you should be using a moving average filter on the readings within your code before feeding them to ESPHome. Instead of reporting the raw instantaneous value, average the last ten or twenty readings. This is the most effective way to smooth out the high-frequency electrical noise inherent in AC sensing.

Regarding calibration, yes, you absolutely need a proper calibration factor. The raw ADC values from the CT clamps are proportional to the current, but that proportionality constant is unique to your sensor unit and the specific wiring setup. You can't just assume the raw data maps perfectly to amperes. You need a known good test. Run the circuit with a measurable, steady load, say 10 amps, and record the average raw ADC value. Then calculate the calibration factor needed to translate that specific raw reading into 10 amps. This factor should be applied every time you read the current.

Finally, check your hardware connections. If you're running the ESP32 close to high-current paths or if your power supply ground isn't well shielded, you are introducing noise. Try to keep the analog input wiring as short and shielded as possable. Sometimes, moving the ESP32 unit away from the mains power wires completly resolves erratic behavior without needing massive code changes.

I'm skeptical about the idea of just slapping a moving average filter onto the readings. If the jumps are acutally because the load is cycling on and off—like a pump or a compressor—then smoothing that data out is hiding the point of having the sensor in the first place. You lose the diagnostic ability if you just report a watered down average. I think if the fluctuations are real, you should focus more on how the circuit is wired to minimize the initial noise before processing the numbers. My expirience with CT clamps suggests that if you are trying to detect rapid changes, relying on the platform's built-in fast reporting cycle might be better than trying to bake averaging into the code itself. Also, how often is the ESP32 clock drifting, because inconsistent timing can introduce errors that look exactly like jitter.

I had the same wobbly numbers on mine and it turned out the usb plug I was powering the board with was the problem. Switched to a diffrent phone charger and the readings calmed down alot, no code changes at all. Might be worth trying a different plug before messing with anything else. Does it matter which of the analog pins you use, or are they all equally noisy?

Update: tried the different power supply trick first since that was the easy one. Swapped the wall plug the board runs off and the readings got noticeably calmer, still a bit twitchy though. Also wondering about the point one reply raised, that smoothing might hide real load cycling. How do you tell the difference between noise and something actually turning on and off?

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required