OpenPLC on Raspberry Pi

Make sure that your Raspberry Pi is running a recent version of the Raspbian operating system. To avoid compatibility problems, it is better to download the most recent Raspbian form the Raspberry Pi website and make a fresh install.

The best way to get OpenPLC files into your Raspberry Pi is by using git. Usually, git comes preinstalled on Raspbian. If for some reason you don’t have git installed on your system, you can install it by typing:

sudo apt-get install git

To install OpenPLC type these lines on the terminal:

git clone
cd OpenPLC_v3
./ rpi

The installation process will take a while (up to 1 hour depending on your system). Meanwhile, grab a [insert your favorite beverage here] and relax! Once OpenPLC is installed, just reboot your device and it will start automatically after boot.


To use in-development capabilities, checkout the development branch (git checkout development) prior to running

The OpenPLC runtime has a built-in webserver that allows you to configure OpenPLC and also to upload new programs for it to run. This webserver can be accessed by opening a web browser on your computer and typing the IP address of your OpenPLC device at port 8080. For example, if your Raspberry Pi has the IP on your network, you should type this on your browser:

If you don’t know the IP address of your board, the Raspberry Pi foundation has a nice guide to help you out.

Once you access OpenPLC webserver, you should see in your browser window a login page like this:

The default username and password is openplc (login) and openplc (password). This means that the first thing you must do after logging in for the first time is change the default username and password! It is very easy to do that. Just go to the Users menu, click on the OpenPLC User and change the information as you like.

Once you save the changes you will be prompted to login again. Just login with your new credentials and you will be good to go!

Pin Mapping

By default OpenPLC runtime is installed with a blank driver. This means that it won’t be able to control your Raspberry Pi pins straight away. To enable the Raspberry Pi driver, go to the “Hardware” section and from the popup menu, select either “Raspberry Pi” or “Raspberry Pi - Old model (2011 model B)” depending on your board. Click on “Save changes” and wait for a little bit while the driver is applied.

Below you will find the OpenPLC I/O mapping for the Raspberry Pi header. The mapping should be the same across all the different board revisions.

There is only one analog (PWM-based) output on the Raspberry Pi, and it is used as the an Analog Out (%QW0.0) on the OpenPLC. Also, take note that the first two inputs (%IX0.0 and %IX0.1) have hardware pullups, which means that if you don’t connect anything to them, they will both read as TRUE. This is part of the design of the Raspberry Pi boards, and can’t be changed by the OpenPLC software. Therefore, the logic on these first two inputs must be reverse.

My First Project

The Reference menu on this website has a nice tutorial that teaches you how to create your first project. However, if you’re in a hurry, you can download the official Hello World project, which is basically one rung, a button, a timer and a coil, all connected together. The button is attached to %IX0.0 and the coil is attached to %QX0.0. When the button is pressed and released, the coil is energized and remains on for 2 seconds, and then turns off.

Download the project below and open it on OpenPLC Editor. Click on Generate program for OpenPLC Runtime in order to compile the diagram into a ST file. Then upload the ST file to the OpenPLC using the web interface.