Change the future

Serpint - Controlling Raspberry Pi GPIO with a Serial Port/Socket

Louis Goessling

Audience level:


Serpint is software for controlling the GPIO pins on a Raspberry Pi over a socket or serial port. It can be used to control the GPIO pins from languages that don't already have a GPIO library, but do for sockets or serial, or from programs that expect a serial port, and do that from half a world away.


Serpint is a toolkit for controlling the GPIO (general purpose input/output) pins on a Raspberry PI. The software is written in Python. The main functions of Serpint have to do with controlling the GPIO pins as if they were a serial device. It can also be used to control the GPIO pins over a network. Another use is reformatting the control of the GPIO pins so that the serial device controlling them emulates a different device like a Scratchboard. The source code of Serpint is available and I hope that many other people will make use of/ make new uses for it.

The main function of Serpint (of which most others are extensions) is the gpiotoserial command. It creates a virtual serial port/device that is being controlled by a Python script. This allows you to control the GPIO pins as if they were a serial device. Through that serial port you then can turn pins on and off, and read their values.

The 2nd and 3rd functions of Serpint come as a pair, allowing you to have a link between a serial port on one machine, and a serial port on another. This allows you to remotely control the GPIO pins on your Raspberry Pi. For example, this could be used to allow you to put the Raspberry Pi and some sensors on the roof and read the wind speed and barometric pressure from downstairs.

The 4th use of Serpint allows you to reformat the data flowing out of a serial port, allowing it to emulate other serial devices. This could be used to have the GPIO pins emulate the signals generated by a Scratchboard or other device.