Please look at this picture:Measured signals.

I'm using STM32F103, a popular Blue Pill module. What you can see in the picture are three signals, from bottom:

  • green - AC voltage of 14V RMS, measured with step down transformer (400/6 ratio), then amplified, filtered and then applied to ADC by resistor divider.

  • red - AC current of 60mA RMS, measured with ACS712 5A Hall effect current sensor. Then by resistor divider it is applied to ADC.

  • blue - the same AC current as above, but amplified three times with LM321 (with exact values from documentation's example).

Details about STM32 program:

  • sample rate was set to "ADC_SMPR_55_5" in circular mode - ADC was constantly measuring and buffer was updated every 55 cycles with an averaged value (but changing this setting did not improve anything as it works way faster than 50 Hz),

  • in the above picture you can see 500 samples taken with distance of 50us, not averaged,

  • ADC of this uC has resolution of 3.3V/4095

As you can see the noise appears at peaks of measured sine waves and I have no idea about its source. I ask you to help me identify it. I know I can simply average it but it will introduce phase delay which is not acceptable (especially in the current signal, as my control loop in the final project will be oriented on the current signal).

What I tried so far:

  1. Since both sensors are close to each other I thought that maybe the transformer interferes with the hall sensor, so I removed one sensor and checked the value from the other, but the noise was still apparent.
  2. Initially both sensors and microcontroller were supplied from SMPS but changed it to linear ones, noise still there.

Edit: I did an oscilloscope measurements and here is what I got: enter image description here

Edit2: About load - the load that was measured is 220 ohm 5W resistor. Also the voltage across the resistor is pure, non-deformed sine wave so there's no source of any distortion in the load circuit.

Edit3: setup photo enter image description here

schematic1:enter image description here

schematic2: enter image description here

edit, last one:

So, I changed resitor dividers at the output of the sensors from 33k/68k to 3k3/6k8. It helped a little bit. Unfortunately don't have space to add voltage follower. The noise was still apparent when I supplied the sensor from battery. I guess high impedance output and long wires picked up noise from the air.

One thing worth to mention is that ACS712 5A chip according to datasheet has its output noise up to 21mV, that means with accuracy of 185mV/A, any measurement below 100mA can't be reliable. I connected a small 12W lamp to the output and it doesn't look that bad at higher amperage (about 1A of current).

Anyway, thanks you guys for help! Lesson for me was that the next time I will be doing any signal measurements I will convert them to digital before passing them to the wires.

enter image description here

  • 4
    \$\begingroup\$ The first step it to look at the signals with an oscilloscope and see if they are clean before they hit the ADC. \$\endgroup\$
    – JRE
    Commented Mar 24, 2020 at 17:51
  • \$\begingroup\$ I did. Edited my post, please have a look. Sorry for the resolution, since schools and universities are closed I don't have access to better oscilloscope. It seems liike microcontroller and its ADC are fine. \$\endgroup\$ Commented Mar 25, 2020 at 1:25
  • 1
    \$\begingroup\$ That noise is really bad. What oscilloscope did you use? How much noise do you get when measuring a fixed DC voltage (eg. 1.5V battery)? Can you show us a photo of your setup? \$\endgroup\$ Commented Mar 25, 2020 at 2:47
  • 2
    \$\begingroup\$ These long wires are great antennas and catch whatever they fall for. Shorten the wires as much as possible! When measuring, the ground clip must be as close as possible to the measuring location. If possible, use a differential probe when measuring. \$\endgroup\$
    – Peter MP
    Commented Mar 25, 2020 at 19:15

1 Answer 1


The power line tends to be noisy at the peaks of the voltage waveform because any piece of equipment that contains a non-PFC power supply tends to draw all of its current in narrow pulses only when the rectified voltage exceeds the internal DC voltage on its filter capacitor(s).

The noise is emphasized in your second waveform probably because your load is not a pure resistance, but rather has a capacitive component in which the reactance is lower at high frequencies. This allows the high-frequency noise to drive a proportionally higher current through the load than the line frequency does.

And the noise is proportionally lower in the third waveform probably because your amplifier has a low-pass frequency response that attenuates those components.

If you want to do additional filtering, but you're worried about relative phase shifts, you can feed both the voltage signal and the current signal through identical filters. That way, the phase shifts cancel out for any subsequent calculations.

  • \$\begingroup\$ But I placed an linear regulator LM7805 between power supply and my board (with micro-controller and sensors). Also added quite a few capacitors here and there. From my understanding all the noise that comes from power supply should be filtered by now. Please have a look at the oscilloscope measurements I did. It seems like supply voltage has dropdowns during mains peaks. But the dropdowns supposed to be smaller if I placed a high value capacitor at the output of linear regulator, yet the capacitor didn't change anything. \$\endgroup\$ Commented Mar 25, 2020 at 1:14
  • 3
    \$\begingroup\$ Linear regulators pass high frequency noise pretty well. Also just putting a bunch of bypass caps into your circuit isn't some perfect panacea for noise. You could try powering your STM32 from a battery, see if that gets rid of it \$\endgroup\$
    – Ocanath
    Commented Mar 25, 2020 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.