stephennn
Posts: 11
Joined: Wed Aug 28, 2019 12:40 pm

How to wire pi, battery and servo

Sun Sep 08, 2019 7:31 am

Hi
I am trying to connect a servo motor to a AA battery pack and my pi.

When I connect it to the pi, it restarts so I bought the battery pack but now I can't understand how to connect the wires.

I am using pin 21 on my code but could someone please explain how to connect the 3 elements together, or if i still need to buy something




thanks
stephen
Attachments
DSC_1172.jpg
DSC_1172.jpg (203.89 KiB) Viewed 570 times
DSC_1171.jpg
DSC_1171.jpg (148.86 KiB) Viewed 570 times
DSC_1170.jpg
DSC_1170.jpg (185.69 KiB) Viewed 570 times

User avatar
joan
Posts: 14476
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: How to wire pi, battery and servo

Sun Sep 08, 2019 8:37 am

See https://learn.sparkfun.com/tutorials/ho ... torial/all

I'm not sure if you are asking which wires to connect where or physically how to connect the wires.

stephennn
Posts: 11
Joined: Wed Aug 28, 2019 12:40 pm

Re: How to wire pi, battery and servo

Mon Sep 09, 2019 7:29 am

I'm not sure which wire to connect where.
I'm not sure if the red and black from the power supply are interchangable or if one is + and the other - , i didn't get any paper with them.

but then do I plug the 2 wires from the batery in to the brown and red to the servo and the orange from the pi?

thanks

drgeoff
Posts: 9929
Joined: Wed Jan 25, 2012 6:39 pm

Re: How to wire pi, battery and servo

Mon Sep 09, 2019 8:11 am

1. Almost all electronic circuits are polarity sensitive. And the majority of times connecting power the wrong way round kills them.

2. Are you trying to run the RPi from the AA battery pack? You cannot. Those cells don't give a suitable voltage to run a RPi.

Need more detail of what bits you are attempting to connect together.

stephennn
Posts: 11
Joined: Wed Aug 28, 2019 12:40 pm

Re: How to wire pi, battery and servo

Mon Sep 09, 2019 8:16 am

I'm trying to run the motor from the battery pack, the pi is plugged in to the mains but reboots when I try to use it to also power the motor

User avatar
joan
Posts: 14476
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: How to wire pi, battery and servo

Mon Sep 09, 2019 8:59 am

Servo brown to battery negative (- or black).
Servo red to battery positive (+ or red).
Servo orange to a Pi GPIO.

You also need to connect the battery negative to a Pi ground.

It's not clear if the wires coming out of the battery pack are fixed or you have inserted them. If they are fixed red is +ve and black is -ve.

User avatar
davidcoton
Posts: 4263
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: How to wire pi, battery and servo

Mon Sep 09, 2019 9:27 am

When you have a battery pack with loose wires attached, make sure the ends are insulated (almost any sort of sticky tape) when it's not in use. Bare ends like in your photo is asking for trouble (destruction of the batteries at a minimum).
Signature retired

stephennn
Posts: 11
Joined: Wed Aug 28, 2019 12:40 pm

Re: How to wire pi, battery and servo

Mon Sep 09, 2019 12:44 pm

thanks
how do i connect the battery negative to both the pi ground and the servo brown?

can i use another wire and just wrap the metal spikes together? and then take the new wire and connect it to the pi ground?

thanks

User avatar
neilgl
Posts: 1197
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: How to wire pi, battery and servo

Mon Sep 09, 2019 12:50 pm

Maybe connect battery GND to one of the pi Ground pins (female to female DuPont cable). Then the servo brown (gnd) to a different GND on the pi. Those pi GND pins are all connected to each other, so OK.
See
https://pinout.xyz/

pcmanbob
Posts: 7306
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: How to wire pi, battery and servo

Mon Sep 09, 2019 1:59 pm

neilgl wrote:
Mon Sep 09, 2019 12:50 pm
Maybe connect battery GND to one of the pi Ground pins (female to female DuPont cable). Then the servo brown (gnd) to a different GND on the pi. Those pi GND pins are all connected to each other, so OK.
This not something I would recommend as the full current drawn by the servo from the battery will be passed between the 2 ground pins , depending on the current drawn you may damage the PCB track on the pi.
Especially as the servo in question has a current rating of 2.5A at 6V.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
neilgl
Posts: 1197
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: How to wire pi, battery and servo

Mon Sep 09, 2019 3:00 pm

Yes good point.

stephennn
Posts: 11
Joined: Wed Aug 28, 2019 12:40 pm

Re: How to wire pi, battery and servo

Wed Sep 11, 2019 8:16 am

Hi
thanks for this, I connected the wires last night and the motor just goes crazy and jitters like a madman without any instructions from me or even connected to the pi, just connected as per:
servo brown - battery black
servo red - battery red

any idea what is happening?

thanks

User avatar
joan
Posts: 14476
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: How to wire pi, battery and servo

Wed Sep 11, 2019 8:18 am

We need photo(s) showing the connections.

Have you tried sending servo pulses?

stephennn
Posts: 11
Joined: Wed Aug 28, 2019 12:40 pm

Re: How to wire pi, battery and servo

Thu Sep 12, 2019 8:31 am

I've attached the photo of the wiring.
Is the battery pack not pushing out enough power? everything is new including the batteries

thanks
Attachments
DSC_1179.jpg
current wiring
DSC_1179.jpg (221.19 KiB) Viewed 337 times

calleblyh
Posts: 71
Joined: Thu Feb 12, 2015 6:14 pm
Location: Southwest Finland

Re: How to wire pi, battery and servo

Thu Sep 12, 2019 9:10 am

Unfortunately I cannot see how you power the RPi. Anyhow battery black wire needs also to be connected to RPi ground. Otherwise orange wire is kind of "floating".
calleblyh / southwest finland

pcmanbob
Posts: 7306
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: How to wire pi, battery and servo

Thu Sep 12, 2019 9:32 am

You need to connect the brown wire on the servo ( ground ) to the pi as well as the battery pack, at the moment you only have a completed power circuit , once you connect the missing servo ground to the pi ground your will then have a completed control circuit.

until this is done no control ( pwm signals ) will reach your servo.

Image
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

stephennn
Posts: 11
Joined: Wed Aug 28, 2019 12:40 pm

Re: How to wire pi, battery and servo

Thu Sep 12, 2019 9:44 am

ok,
so does that mean I now need to buy a breadboard like this?
https://www.amazon.co.uk/gp/product/B00KM1EETU

thanks

pcmanbob
Posts: 7306
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: How to wire pi, battery and servo

Thu Sep 12, 2019 9:50 am

That would be one way of doing it, or you could just connect one dupont cable to the servo ground, one to the battery ground and one to the pi ground and then connect all 3 using a soldered joint or a simple screw terminal block.

but if you intend to continuing experimenting with your pi gpio a breadboard will come in very handy.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

stephennn
Posts: 11
Joined: Wed Aug 28, 2019 12:40 pm

Re: How to wire pi, battery and servo

Thu Sep 12, 2019 10:01 am

I have screw blocks, i'll try that tonight.
thanks

stephennn
Posts: 11
Joined: Wed Aug 28, 2019 12:40 pm

Re: How to wire pi, battery and servo

Thu Sep 26, 2019 9:51 am

fyi,
wiring the pi as described with the additional ground wire solved the issue and everything is now working as expected.
thanks all.

Return to “Beginners”