I am making a tank rc car with the Raspberry Pi (model 2) and running the 2 DC motors with an L298N H-Bridge Motor Driver Board. I am using Putty (free SSH client) to SSH into my Pi (running raspbian) on from windows 10.


The problem is that when I turn my Pi on and off the motors start moving sporadically. They also go crazy when I turn the Pi off and leave the motor driver board powered on. This doesn't make sense to me, because the L298N board takes 5 Volts from the Pi to function (logic) and takes extra power from an external battery to drive the motors (which is the purpose of the chip). The motors act fine when I use the Pi via a monitor, it's when I SSH into it that they go crazy. This may be because I bought a very cheap Wi-Fi dongle.


My Pi also turns off without warning periodically. I'm thinking that could be because of my battery pack, but it is within the amperage range that the Pi requires.

update: I was told I should use pull up or pull down resistors. From my quick google research, I learned that these resistors should be connected (cut the wire and connect each end of the resistor) to the positive wire. Is this correct? What rating should the resistors be in Ohms?

  • The pull-ups or pull-downs should have roughly 5-10 times the resistance of the input resistors. If you don't use any input resistors, use 10 K pull-ups/down. If you turn the motor drivers on by writing a high to the Pi's GPIOs, you need pulldown (GPIO pin -> 10 k -> GND). If you turn the motors on by writing a low, you need pullup (GPIO pin -> 10 K -> 3v3). – jDo May 3 '16 at 0:58
  • Thanks, I'll try using resistors, but I checked the Voltage and amperage and they all complied. The battery pack is exactly 5 volts rated at 2100 mAmps or 1000 mAmps. I tried plugging them both into a AC -> DC wall charging block/ adapter and they worked just fine when they were BOTH plugged in. The battery packs I'm using are usb and I cut an old phone charger for the motors. One of the adapters/bricks only outputs 700 mAmps, but works fine for the Pi (and motors). – Green Plasma May 3 '16 at 1:13
  • "2100 mAmps or 1000 mAmps"??? 2000 is probably enough, 1000 isn't. "an old phone charger" rarely supplies more than 500-700 mAs. I normally only use laptop PSUs with a 2 - 3.5 A capacity for the Pi plus a few external units. They're solid and nicely regulated. Btw. batteries will often look alright when measured but drop to next to nothing under load if they're busted/worn out. Make sure to measure while everything is running. – jDo May 3 '16 at 1:22
  • I would like a portable power source, seeing that I will be remotely controlling it.Would you recommend a Lithium Polymer battery pack over Lithium Ion? Or would a better charging cable suffice? – Green Plasma May 3 '16 at 1:28
  • Would a battery from an electric drill or a laptop be too big? I'd use something like that if I had room for it. I'm not sure which of the two types is best (Li-ion or LiPo) - just make sure it has lots of juice and a higher-than-needed voltage so you have a bit of overhead (I'm assuming you'll step down and regulate the voltage using an efficient switching regulator module). The power cable could easily be the bottleneck in your set-up - those wires are often way too thin. I always solder a couple of nice, thick wires straight onto the Pi instead and don't use USB power-connector at all. – jDo May 3 '16 at 1:57

Your Answer

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

Browse other questions tagged or ask your own question.