How to Control Servos with Serial Ports on Raspberry Pi

A few hours ago, I had communication issue between my Raspberry Pi and Servo Control Board using URAT(Universal Asynchronous Receiver/Transmitter).

I confirmed many times that the wire connection was right, but it just did not work. After referencing many articles, I found out how to make it work perfectly.

For the latest Raspbian installed Raspberry Pi, there are 2 steps to go.

Enable Serial Port & Disable Serial Console

Use serial0 instead of ttyAMA0

As reference 1 mentioned, because of the Bluetooth conflict, you’d better use

import serial
ser = serial.Serial('/dev/serial0', 9600)

instead of

ser = serial.Serial('/dev/ttyAMA0', 9600)

Since we have known the reason for this issue, it may also be possible that you disable Bluetooth on your Raspberry Pi(Though I have not tried it yet)


  1. Change ttyAMA0 to Serial0: