# Arduino - How do I reduce the noise in my circuit

I have a fairly simple circuit consisting of an arduino an accelerometer and an amplifier. I am collecting data from the accelerometer using I2C and playing some sounds through a switching amplifier (this). The problem is I am getting a constant noise in the background. I am 90% sure it is because of the I2C connection between the accelerometer and the arduino.

I am using an inductor of 10mH and cap 100nF The amplifier is connected across the capacitor and is receiving power from arduino 5 volt supply. (I didn't draw it here). Also, I am not using external pull-up resistors with the accelerometer because apparently I don't need to when working with adxl 345

How can I reduce this noise? Where is it coming from?

Edit :-

My code has if else statements that play sounds if the accelerometer value is above a threshold. I think the noise has something to do with the fact that I am polling the accelerometer all the time.

• Take out the ADXL345, does the noise stop. – geometrikal Nov 29 '14 at 9:48
• @geometrikal Yes there's no noise when the adxl is not connected. There's no noise even when the adxl power is connected and I2C lines are disconnected – Ajit Nov 29 '14 at 9:53
• The datasheet for the ADXL345 shows it's abs max Vdd as 3.9V but your diagram shows 5V to Vdd. Does the breakout board take care of that and the pullups etc..? A schematic would be helpful. – akellyirl Nov 29 '14 at 10:57
• Yeah. I am using this breakout board adafruit.com/product/1231 – Ajit Nov 29 '14 at 11:05
• It's a layout thing - please show how you have physically connected the grounds of the system. – Andy aka Nov 29 '14 at 14:53

I speculate that you're getting electromagnetic compatibility conductive coupling of noise through the power lines. I'm assuming you've already followed the best practice of making sure there is a a 1 microfarad (1 uF) capacitor or 0.1 uF cap connected to each power pin of each chip, with the other leg of that capacitor connected to GND.

If I were you, I would run a quick test something like this:

• Put some sort of buffer or inverter between the Arduino and the LC filter.
• Keep the GND connected between all the sections.
• Disconnect the +5V line between each section.
• Borrow 3 separate 5V power supplies to indepently power each section. (perhaps a independent mains-powered "USB recharger" wall-wart for each section +5V_a, +5V_b, and +5V_c).
• Also get 3 big capacitors -- 100 uF or 220 uF or larger capacitor -- and put one in each section across the local +5V power supply and the common GND. (These will likely be electrolytic capacitors, because they are adequate for this job and cost far less than other ways of getting at least 100 uF).

.      +5V_a              +5V_b    +5V_c
.      |                  |        |
. Accelerometer==(I2C)==Arduino--inverter--(LC filter)--speaker
.      |                  |        |            |
. GND--+------------------+--------+------------+-----------GND


To make sure I haven't accidentally connected the +5V lines together, I might spread them apart across my workbench, so I can visually see that it is obvious that the only connection between sections is the GND and the signal lines.

(I'd probably use a 74HC132 Schmitt NAND Gate or a 74HC253 or 74AC253 4:1 mux wired up as an inverter or buffer, because I have them in my stockpile of highly useful chips; but pretty much any 74xxx chip you happen to have on hand would work fine for this test).

Does this setup eliminate the noise you hear?

• If this setup eliminates the noise: Great, we know the noise came through the power lines, and we know one way to fix it. Take a photo of the known-working arrangement, and then try to "optimize" by running off only 2 power supplies or 1 power supply. It should rapidly become clear exactly which section(s) is the source of the noise and which section is the victim of the noise, and you can use standard noise-reduction techniques (series resistor on output pin; LC filters, RC filters, pi filters, ferrite beads, etc. between one chip's power and another chip's power; etc.) to reduce the noise at its source and reduce the amount of noise that leaks from the source to the target.

• If this setup does not eliminate the noise: there must be some other source of noise. Perhaps there is a bad interaction between the software that plays the sounds and the software that reads and writes the I2C bus? If you make a separate temporary test sketch that never talks to the accelerometer but always unconditionally plays sounds, do you still hear the noise? What's the shortest sketch you can make that exhibits the problem?

There are three sources of noise :

1- The noise which comes from the power lines (VCC,GND)

2- The noise which is caused by the components of the circuit and injected to the pins of an IC.

3- The radiations that come from the outside of the circuit.

So to reduce noise you must avoid those three types of noise.

• using the SMD packages of AVR.
• using a noise-less power courses (which has VDR and EMI filter)
• placing tantalum capacitors between the VCC and GND lines.
• always place a capacitor in the range of nano farads beside a capacitor in the range of micro farads.

• place a LC-filter after the regulation circuits.

• better to use linear-regulators instead of switching regulators for AVR.
• using a good PCB (that has polygon)
• very important : using a high-quality cable ( with shield ) and better to use twisted wires.

• putting the circuit in a metal box connected to GND (to avoid rays come to the circuit)

of course those tips are general but if you check them one by one , then you will be successful.

I hope it would help.

EDIT:

the best choice is to place a 220uF cap (electrolyte) and one 100nF cap (ceramic) between VCC and GND power lines.

on the input of an speaker , there must be no DC voltage (otherwise it will heat) so you shouldn't place any caps there.

on the I2C lines. there shouldn't be any capacitance, too.