Raspberry Pi User Help

Trouble getting sg-90 servo to work with R-PI 4

I have read several answers and approaches to controlling an SG-90 servo with a raspberry pi and I have tried the following approaches, with varying but never satisfactory results.

Wiring Setup:

  • Servo + to 5V external power
  • Servo – to external ground
  • External ground connected to R-PI ground
  • R-PI PIN 13 (BCM 27) to servo signal

First approach was to use RPi.GPIO with PIN set to output and GPIO.PWM(13, 50). None of the values used had any effect whatsoever on the servo, no movement at all.

Second approach was to use pi-blaster. I’ve used the default rates and did some echo "27=0.075" > /etc/pi-blaster and could get the motor to move. However lets say moving from -90 to +90 degrees would not be a continous movement, it was more like 3 intervals where it moved fast, halted a while, moved again until it reached the position. Otherwise it was fine, i.e. reliable movements, no jerking except the very large intervals.

Third approach was with some additional helper. I have used one of my Arduino motor shields that I have used on the arduino to successfully control that same servo and connected the external power to the shield, used pin 9 and ground of the shield to the R-PI and connected the servo to the second servo slot. I tried both pi-blaster and RPi.GPIO but neither of them had any effect on the motor.

What am I missing here? I saw many articles where people were pretty much hooking up an sg-90 to an external PSU (and connect grounds) and directly to the R-PI and then using pythons RPi.GPIO without any issues, but this wont even get the motor to move in my case.

Leave a Reply

Your email address will not be published. Required fields are marked *