I have a Sharp proximity sensor connected to my Arduino (analog input). This Arduino is connected and powered through USB by a laptop.

  • When the laptop is plugged in, everything works fine (I get consistent readings).

  • When the laptop is running on batteries, the values I'm reading are "chaotics". I mean that they vary a lot.

I also have an Arduino motor shield, which is powered by an external battery, but that's just for the motors (sensors are powered by the Arduino). The GND of the battery and of the Arduino are connected though, maybe that's causing the problem?

Or is too much power required from the USB?

Well, do you have any idea to understand that and fix it?

Additional informations:

  • Sensors reading are "smoothened" using a low pass filter (see my previous question about it).
  • (if you need some more information, that will show up here)
  • \$\begingroup\$ Too much noise? Have you got decoupling capacitors on the sensor? See this question \$\endgroup\$
    – Dean
    Aug 7, 2011 at 20:02
  • \$\begingroup\$ Can you post a block diagram or schematic? Is the circuit grounded to something? Does it go away if you ground it to something? Do you have an oscilloscope to get a trace of the signal while plugged and unplugged? I'm guessing it's an issue caused by floating a circuit and high common-mode voltages somewhere. \$\endgroup\$
    – endolith
    Aug 7, 2011 at 23:11
  • \$\begingroup\$ Disconnecting (or at least not driving) the motors to see if the problem remains when the laptop runs off batteries would be an obvious experiment. If so, it could be the laptop's USB bus power is noisy in battery mode. \$\endgroup\$ Aug 8, 2011 at 18:57
  • \$\begingroup\$ @Dean As I said in the question I used a low pass filter (see electronics.stackexchange.com/questions/17754/…) \$\endgroup\$ Aug 9, 2011 at 11:29
  • \$\begingroup\$ @Chris I'm doing those tests without driving the motors, there's no difference with the motors running. \$\endgroup\$ Aug 9, 2011 at 11:29

3 Answers 3


Based on the report that it works when the circuit is powered by its own battery, it really sounds like the laptop's USB VBUS supply is noisy when operating off batteries.

Maybe the VBUS comes from a badly implemented switching regulator or DC/DC converter or one with some failed components in it, that is under more stress when operating off batteries than when off the likely higher charger voltage.

It should be possible to filter this supply using both a series inductor and a cap - this will be more effective than a capacitor alone. You can even do multiple stages of such filters.

But it may be easier to just use a battery if that works for you.

  • \$\begingroup\$ Thanks, I'll do that then. But in order to avoid having 3 batteries, do you reckon I can end up with the same problem (i.e. noise on power source) if I power my Arduino with the battery I use for the motors (voltage ajusted of course)? I mean, motors turning won't affect the Arduino? \$\endgroup\$ Aug 10, 2011 at 13:15
  • \$\begingroup\$ Motors can definitely be an issue, but one that can be dealt with using good supply filtering between the motor drivers and the rest of the circuit. Or you can not run the motors and read the sensors and the same time (assuming the noise is not so bad it distrubs the arduino's internal state). Getting motor grunge back into the USB (when not using a battery) doesn't sound like a great idea either but it seems like that USB supply is ugly to begin with. \$\endgroup\$ Aug 10, 2011 at 15:23

Sounds like a ground loop.

The laptop's DC output (-) terminal is connected to the earth pin of the plug inside the adapter. The problem is usually resolved by eliminating all other ground connections. Check if your Arduino is connected to any other device which is grounded, for example an oscilloscope.

  • 4
    \$\begingroup\$ This does not sound like a ground loop. A ground loop would cause problems when the laptop is plugged in, and the problems would go away when it is running on batteries. This is the opposite, according to the question. \$\endgroup\$
    – endolith
    Aug 7, 2011 at 23:09
  • \$\begingroup\$ @endolith There could be multiple high impedance grounds, for example through a protection diode in a CMOS IC. The low impedance ground of the laptop may be, for lack of a better word, "overriding" these other grounds, causing the effect to go away when that ground is connected. \$\endgroup\$
    – Thomas O
    Aug 8, 2011 at 0:04
  • \$\begingroup\$ How is that a ground loop issue? \$\endgroup\$
    – endolith
    Aug 8, 2011 at 3:50
  • \$\begingroup\$ The Arduino is connected to nothing else. But I tried connecting the Arduino at the same time to USB (laptop) and to a battery (9V, not the same as the motors). Now my sensors work correctly! Is that helpful? \$\endgroup\$ Aug 9, 2011 at 11:31

Try adding a LARGE capacitor on the power supply rail - at least 1,000uF. 10,000 uF if available. If that makes no difference then it's liable to be a radiated noise issue. If adding the capacitor helps its liable to be a conducted noise issue.

Motors can be very nasty - even on their own supply. If motors are driven in one direction only then reverse diodes across the motor are essentially essential. If the motors are bidirectionally driven then some sort of snubbing is essentially essential. (Are motors mono or bidirectionally driven?)

  • \$\begingroup\$ USB shouldn't have more than 10 µF connected across it, according to the spec's inrush current limits \$\endgroup\$
    – endolith
    Aug 8, 2011 at 20:20
  • \$\begingroup\$ Yes. But. For temporary trouble shooting purposes, as here, the extra capacitance is very very very unlikely to cause a problem. As with any such activity - playing with systems out of spec may cause problems. But it's unlikely here. User has to decide what is 'acceptable risk". Many people abuse USB by drawing excess power from it - doesn't make it "good" but it's usually doable. . 1000 uF takes about a negligible 12 mW.second to charge and 10,000 uF about 0.12 Watt.seconds. Add a small series cap for charging id desired and short out when charged. Power dip may be main risk. \$\endgroup\$
    – Russell McMahon
    Aug 9, 2011 at 3:23
  • \$\begingroup\$ I tried connecting the Arduino at the same time to USB (laptop) and to a battery (9V, not the same as the motors). Now my sensors work correctly! Is that helpful? \$\endgroup\$ Aug 9, 2011 at 11:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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