Crane at Pi Party

Raspberry Pi Controlled Crane

Raspberry Pi Controlled Crane

We’ve been working on a few fun projects recently. One of our favourites is our Makerspace CPC crane, which we’ve adapted to be controlled by a Raspberry Pi and Astro Pi. This proved to be a big hit at the recent Raspberry Pi 5th birthday party.

Crane at Pi Party

The Crane

This project involved taking a remote controlled model crane, and removing the hand held remote control unit that came with it.


We cut into the remote control wire as close as we could to the remote control unit, as we would not be using that again. We then needed to strip back the 4 wires inside the remote control wire (2 wires for each of the 2 motors in the crane), and attach these 4 wires to a 4tronix RoboHAT motor control board. This would allow each of the 2 motors to be controlled by a Raspberry Pi. Note that the individual motor wires are very thin, and consist of 3 or 4 strands of very fine copper wire, so stripping these wires was a very delicate process. The picture below shows the wiring for the crane with the RoboHAT board.

RoboHAT Wiring

Having done this we wrote a simple python program to allow us to control each of the 2 motors individually. One of the motors controls the raising and lowering of the crane hook, and the other motor controls the rotation of the crane boom. To fully control the crane, we would need to drive the motors in either direction, and also provide a certain degree of speed control.

The Astro Pi Controller

Happy that the motors could be controlled in the way we required, we took our Astro Pi, and wrote some more code to allow us to control the crane by using the tilt sensor in the Astro Pi. Our aim was to write a program which would control the crane such that tilting the Astro Pi backwards or forwards would raise or lower the crane hook, and tilting the Astro Pi left or right would rotate the crane boom anti-clockwise or clockwise. We wanted the Astro Pi to communicate with the crane Raspberry Pi using Bluetooth.

Having written the code for the Astro Pi, we modified our code in the Raspberry Pi on the base of the crane to run as a Bluetooth server which would accept Bluetooth signals from the Astro Pi Bluetooth client program.

The Hook

We also modified the crane to use a magnet instead of a hook. The holder for the magnetic pickup assembly is 3D printed, and by pausing the 3D print process at a print height of 4.5mm we were able to insert the magnets into the pickup assembly.

Crane Magnet

You can download the 3D print file for this hook attachment from Thingiverse.

The Code

The code for the Makerspace UK crane can be found on github. There are two folders under this github repository; one for the crane itself (Server) and one for the Astro Pi (Client).

Each of these folders contains the Python code file that you will need to run on each Raspberry Pi; the server program on the crane, and the client program on the Astro Pi. You will need to modify the Python program on the Astro Pi (client), as it contains a line of code that defines the bluetooth MAC address of the crane Raspberry Pi:-

serverBTAddress = "00:00:00:00:00:00"