I'm working on a project to measure the frequency of a small voltage (~0.1V peak-to-peak, with 1.4 VDC offset) sine wave of 1-100Hz. I only care about the frequency. I'm using a LM324 quad op amp (with Schmitt trigger to remove chatter) to turn the sine wave into a 0-5V square wave for measurement with a microcontroller. This all works great but I've noticed that the circuit is susceptible to noise on the mains power line, specifically when my furnace turns off. This causes my microcontroller to have false readings.

The circuit is powered by a 5V USB adapter. What's the best way to isolate my circuit form the power line noise?

Additional Information:

I do have an oscilloscope. The source of the voltage is a magnetic field sensor. https://www.vernier.com/product/magnetic-field-sensor/

The USB adapter is an Apple one with pretty stable output. I originally started with a generic USB adapter which was outputting a noisy 5V.

I'm adding a crudely drawn MS Paint schematic. schematic of current setup

  • 1
    \$\begingroup\$ Low pass filter the signal? \$\endgroup\$ Nov 29, 2021 at 14:40
  • \$\begingroup\$ What is the source of the sine wave? \$\endgroup\$
    – Rens
    Nov 29, 2021 at 15:20
  • \$\begingroup\$ To add on @Rens question: how is this connected to the source of the sine wave? Is there a ground/Earth loop in the GND wire? How long are the wires? Are they shielded? What is the source impedance? Is it possible to get a differential voltage instead of single ended? What else is connected to the PCB, especially long wires, and especially other ground loops? Is it a breadboard? \$\endgroup\$
    – bobflux
    Nov 29, 2021 at 15:44
  • \$\begingroup\$ Most sure-fire method is to not use an adaptor or mains attachment at all. Can you run this on batteries??? \$\endgroup\$
    – Kyle B
    Nov 29, 2021 at 17:13
  • \$\begingroup\$ @Rens I've added a schematic to better describe what the set-up looks like. \$\endgroup\$
    – Snerler
    Nov 29, 2021 at 17:27

2 Answers 2


First, I recommend isolating the entry point of the noise, either before the LM324 or after. This is important, because if before the LM324 then no hope of fixing it on the long 20 foot run. Use the o-scope to help find the circuit being affected by noise.

If before the LM324, then I recommend using a shielded cable for the 3 foot to your proto-board. Also, as already suggested, add some bypass caps to the LM324 chip. Check if the proto-board happens to be near an AC power line, and if so reduce the EMI coupling by shielding the board or moving further away.

If after the LM324, then switch to a differential signal if possible. I suggest adding an RS485 chip on the output of the LM324. The RS485 only requires 5V, so this should be an easy upgrade. The 20 foot cable will need another conductor though. You will also need to add another RS485 chip as the receiver on the other end of the 20 foot cable. Just hard wire the control signals for fixed transmit/receive mode.

If switching to differential pair is not possible (such as cable cannot be replaced) then try switching to an RS232 chip instead. You can find single supply chips that work off the 5V power. Again, you will need another RS232 chip on the other end of the 20 foot cable. This interface standard is well tested for 20 foot distances even though it is single-ended signal. The extra -6V to +6V is what improves the signal to noise.


For a small analog signal and long cables, you should add shielding the cables. The shielding needs to be connected to the ground path that you have drawn as a black line. It should be connected at both ends on both cables.

For more information on shielding and grounding check out:
Henry Ott
Grounds for Grounding


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.