Controlling RC servos wirelessly over UDP

In this project I want to use my iPhone to control RC servos. I’ll use the accelerometer to control two servos over UDP connection. This is a Proof Of Concept project to verify that a connection between an iPhone and a peripheral can achieve high update rates (higher than BLE) using UDP.



Hardware setup

The hardware setup is very simple. I use the D1 (pitch) and D2 (roll) output on the ESP8266 board to control the RC servos respectively. The board is powered from a USB power bank. The RC servos are powered from the 5v and GND pin of the board.

Software implementation on Arduino & iOS

The control app for the iPhone is written in Swift which connects to the ESP8266 controller board wirelessly and controls pitch and roll servos based on the iPhone motion data. The controller board creates a Wifi Access Point and listens for upcomming UDP packets which contains the servo position information as a stream of bytes with the following general format:

Servo index | Position MSB | Position LSB

The servo index is either 1 for pitch or 2 for roll. The servo position is calculated from the phone x, y tilt degrees and converted to microseconds between 1000 and 2000. The refresh rate is 20 milliseconds.

The app is using the new Network.framework to establish the UDP connection, so it is only running on iOS 12 and above.

This is a POC app to demostrate how easy to use UDP connection on iOS 12. To keep it simple the UDP packets are sent separately for pitch and roll. 

Please also look at my video how it works: 

Leave a Comment


No comments yet. Why don’t you start the discussion?

Leave a Reply

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