Third party cookies may be stored when visiting this site. Please see the cookie information.
PenguinTutor YouTube Channel

Model Railway Automation - OLED Station Digital Departure board

This is part of my projects on building an indoor (OO Scale) and outdoor (G-Scale) model railway. The FreeCAD design is based around G-Scale, but it would be possible to create a smaller version for other railways.

This project creates a station departure board using a miniature OLED display. This is controlled using a Raspberry Pi which allows the current time to be used to make the display appear more realistic. This can be used in conjunction with the Raspberry Pi Model Railway Automation project.

Model railway departure board with OLED display controlled by a Raspberry Pi computer

Video demonstration of the model railway departure board

This video explains how the OLED display is controlled by a Raspberry Pi using I2C. Details are provided of the code which is created using Circuit Python. It also shows how the stand is created in FreeCAD and shows how the display changes to display different train times.

Please Subscribe and click the bell icon to be notified of my future videos.

OLED display

The OLED display is a miniature 0.91" display. The version that I used is the I2C model which has the fixed I2C address of: 0x3C.

Model railway digital departure display controlled by a Raspberry Pi computer

Programming the OLED SSD1306 using Circuit Python

To program this using Python I used the AdaFruit Circuit Python library. This requires the Circuit Python libraries to be installed on the Raspberry Pi, but uses the normal Python 3 interpretter. This allows the display to be created using the Python Imaging Library (PIL).

To install the libraries:
sudo pip3 install --upgrade setuptools

Then you can run the adafruit install script from github

sudo pip3 install adafruit-python-shell


sudo python3

What this is doing is downloading a script and then running it with the root permissions. You should only do this if you trust the code that you have downloaded. You can either view the file and see what it is doing, or whether you trust the source. In this case it’s coming from an adafruit repository on github which I’m happy to trust.

If your default version of Python is 2, which is the default for the Raspberry Pi at the moment then it will switch that to version 3. You will need to agree to proceed with the setup.
You will then need to reboot the Raspberry Pi.

Now that circuitpython is installed you can add the adafruit library for the ssd1306 using:
pip3 install adafruit-circuitpython-ssd1306

Then add the Python Imaging Library using
sudo apt install python3-pil
This is used to create an image object from the text, and then that image is what is shown on the screen.

The code to display to the board is included in the downloads below. The file shows how you can display three lines of basic text. The file shows example departure board display. For more details see: Video showing Raspberry Pi Model railway departure board.

Model Railay FreeCAD 3D printer design

The display stand is created in FreeCAD and then 3D printed. The video above shows the FreeCAD design speeded up, to learn more about FreeCAD see my Beginners guide to designing for a 3D printer using FreeCAD.

The design is created as 4 parts. The display is the main part that holds the SSD1306 I2C OLED display, a piece of transparent acetate should be glued across the front for waterproofing. The back fits into the back of the display. It is not waterproof so it should be held in place using hot melt glue or similar.

The stand is the post that holds up the display and can be used to run wires through. Finally there is an optional base. The base is not intended for use on the railway (which will be incorporated into the platform), but provides a way that I could stand it up for the demonstration.


Related projects

Also see:

Future projects

For the latest updates please:
Subscribe to the PenguinTutor YouTube Channel
Follow @penguintutor on Twitter