PLC Programmer | HMI & SCADA Developer | Control Panel Designer | Siemens & CODESYS Expert
This Repository is to build DIY PLC for LOW Cost using Raspberry PI and CODESYS for real-world automation solutions using modern industrial technologies
Hardwares List
- Raspberry Pi 5 (4GB or 8GB)
- microSD card (16GB or higher, Class 10) #Installed PI OS 64 / If not see Installation
- Power supply (USB-C, 5V 3A+)
- Ethernet cable (for stable communication)
- Breadboard
- Jumper wires
- Optional: GPIO-connected 12V push buttons, LED indicators (via relay/level shifter)
- Optional: Raspberry pi TCobbler if using breadboard
- Optional: High voltage appliances (AC/DC)
- Optional: Power Adapter (0-36V DC)
Softwares Download and Install
- Download and Install Raspberry Pi Imager for Windows
- Download and Install CODESYS for Windows
- Download and Install CODESYS Control for Raspberry Pi SL (SoftPLC runtime) for Windows
- Download and Install PUTTY on Windows
- Download and Install WinSCP for manual installation
- Download CODESYS License (free demo or paid full)
Installation
Raspberry pi Setup
Install Raspberry PI OS
- Rasoberry PI 5
- Micro-SD Card (atleast 16GB)
- USB SD Card Reader
- Open PI Imager
- Flash “Raspberry Pi OS 64-bit (Lite or Desktop)” to SD card and config additional settings before FLASH.
Open PI Imager![]() |
Choose Device![]() |
Choose OS![]() |
Select Storage![]() |
Edit Settings![]() |
Configure OS![]() |
Enable SSH and Save![]() |
OS Writing![]() |
OS Verifying![]() |
PUTTY Setup
Once PI OS 64/32 Installed on raspberry pi 5
Open PUTTY and Login with raspberrypi.local -> Click OK
- Login as: Your pi ID
- Password: Your pi password
# Note password not visible
PUTTY Login![]() |
PUTTY pi Login![]() |
# After successfully logged in get your pi IP
- ifconfig or hostname -I (Keep the IP of your PI similar like Ex: 192.168.xxx.xx)
- sudo apt update && sudo apt upgrade -y
Click Down Arrow key on keyboad to select "Interface Options"
- Use Right Arrow key on keyboard to select "SELECT" Click Enter
↓
- Use Down Arrow key on keyboard to select VNC
- Use Right Arrow key to Select the option click enter and enter again
↓
- Use Right Arrow key to Select "YES" and Enter
↓
--> To finsh the setup use Right arrow key 2 times select Finish and click Enter on keyboard
Install CODESYS Control Runtime on Raspberry pi
Install CODESYS Control Runtime from Windows
- Open CODESYS Development System on Windows
- From CODESYS Development System:
- Go to Tools → Package Manager / Codesys Installer → Browse search below listed 4 package and install
- ✅ CODESYS Control for Raspberry Pi SL
- ✅ CODESYS Edge Gateway for Linux
- ✅ CODESYS Control SL Extension Package
- ✅ CODESYS SL Deploy Tool
- Boot your Pi with the OS
- Ensure it's connected to the same network as your PC
- On your Windows PC, open CODESYS Development System
- Go to Tools → Device Installer
- Install Raspberry Pi runtime:
- Menu: Tools → Update Raspberry Pi
- Enter your Pi IP address
- Provide username (pi) and password (raspberry or your custom)
- In CODESYS → Go to:
- Tools → CODESYS Control for Raspberry Pi → Update Raspberry Pi
- Enter your Raspberry Pi’s IP address
- Choose:
- Login: pi ( Your ID or default)
- Password: raspberry (default; change if needed)
- Select the Demo License (free, 2-hour runtime)
- Wait for the runtime to install — success message will appear.
- You can run a demo version (2 hours runtime).
- For production: Buy license from CODESYS Store and activate via License Manager.
Manual Installation from Raspberry Pi
Choose anyone ( I'm using VNC, you can use anyone process is same)
- External Monitor
- VNC Software laptop
- PUTTY
- Download or Locate "CODESYS Control for Raspberry Pi SL.deb" file on Windows folder
Ex: C:\Program Files\CODESYS 3.5.21.0\CODESYS\CODESYS Control for Raspberry PI\Delivery\raspberry
- Open WinSCP, login with:
- Host: Your Pi’s ip or rapberrypi.local
- User: Your ID
- Password: Your password
- ✅ Drag & drop the .deb file to any folder (Ex: Downloads).
Locate ".deb" file into your PC, Drag & Drop into pi Folder "Downloads"
After Successfully Copied ".deb" file into pi folder
Open PuTTY / VNC:
- Enter ip of your Raspberry Pi
- Login:
- Username: Your ID
- Password: Your password
# PI Comand line (Update pi if needed "sudo apt update && sudo apt upgrade -y")
- Locate The copied file .deb (Use below command)
> ls (Pi folders)
> cd Downloads (Copied file folder: you can "cd" where you have copied the ".deb" file)
> ls (You will see .deb file Ex: codesyscontrol_raspberry_4.15.0.0_all.deb)
> sudo dpkg -i [codesyscontrol_raspberry_4.15.0.0_all.deb] ( [] Rename with yours file name)
> sudo systemctl status codesyscontrol (Check PLC Status Active or Dead)
> cd (Come back to Starting section)
> sudo systemctl start codesyscontrol (manual Start PLC Runtime)
> sudo systemctl status codesyscontrol (#it will show Active)
> sudo systemctl stop codesyscontrol (#it will stop PLC)
PLC Project creation
Create a New PLC Project
Go to: File → New Project → Standard Project
Select device:
CODESYS Control for Raspberry Pi 64 SL (64 bit)
Choose programming language: Ladder Diagram (LD), ST, etc.
Project Creation: Go to: File → New Project → Standard Project
Select the Device :
If no Hardware : WIN v3 64
If using pi 64 : pi 64 SL
Choose the logic lagnuage: I'm using "LD"
Programming Environment
Left side Device's/ POU's/ Modules | Middle LD logic page | Right side LD logic Tools | Upper side Menu
Setup PLC Development Environment without Raspberry pi
- If no hardware select Simulation
- Click login -> Click Start
- If have hardware no need to select Simulation
After Writing Logic Go to : File → Save → Generate Code (F11) to Compile
Down side you can see if there is any Error or Not
After Compilation Go to : Online → Click Simulation → Click Login
You'll see Application in Stop Mode To Run the Code : Ciick on ▶ Play button
You'll see Application in Run Mode
To Change the I/O's : click on → Prepfered value it will show TRUE / FALSE : Click Ctrl + F7 to change the Input state
You can see the Output Change :
Output LED Turned ON
Again click on → Prepfered value it will show TRUE / FALSE : Click Ctrl + F7 to change the Input state
Setup PLC Development Environment for Raspberry pi
Go to: PLC PRG(PRG): Write down your PLC code -> Save it -> Click Generate code to compile
- Add devices:
- GPIO (Digital Input/Output)
- Modbus, Ethernet/IP, etc. (if needed)
- Map GPIOs (I/O Configuration)
- Under “Device → Raspberry Pi GPIOs”
Write your PLC code → Click Generate code to compile and Save
Go to GPIOs → GPIO Parameters → Double click to Asign GPIO as INPUT or OUTPUT
GPIO IO Maping → Double click on variable → Click Application → PLC PRG → Click the Ladder Logic I/Os and OK
# Note : Asign Digital Input & Output Seperately
Right click on Application → Add Object → Visualization click Active and OK
Go to Visualization → Drag and Drop icons → Double Click on variable → Click 3 dots → Application → PLC PRG → Click the Ladder Logic I/Os and OK
Do it for all HMI icons
Go to deploy Control → Click → Scan → click on Pi IP → Give User name and Password → Click Connect :
It will show connected (pi connected to CODESYS)
Go to Device → Scan Network → Click raspberrypi and OK
Go to Taskber → Right click on Drop Down → Right Click on .64 and Start PLC
Go to Online : → It will ask for CODESYS login ID and Password → Enter → PLC will be in STOP Mode → Ciick on ▶ Play button → PLC will be in RUN mode
Project | Description | Tech Stack |
---|---|---|
Raspberry Pi 5 Relay Control | PLC automation with Raspberrypi 5 and Codesys Runtime basic relay control, using push button and LED feedback | CODESYS, Pi 5, LD |
Item | Description | Qty |
---|---|---|
Raspberry Pi 5 (4GB) | Main controller | 1 |
microSD (128GB) | Storage | 1 |
USB-C PSU (5V 3A) Pi Official | Power supply | 1 |
GPIO TCobbler Board | Easy I/O access | 1 |
12V Relay Module (16 Channel) | For output control | 1 |
12V LED indicators | For output test | 2–4 |
3.3V Push Buttons | For input | 2–4 |
12V power supply | Relay & LED power | 1 |
Ethernet cable / WiFi | Communication | 1 |
Bread Board, Jumper wires | For Connection | 1-10 |
Connector | Connected | ||
---|---|---|---|
Raspberry pi VCC | 5v | Relay Channel | 5v |
Raspberry pi GND | GND | Relay Channel | GND |
Raspberry pi GPIO | 23 | Relay Channel | IN 7 |
Raspberry pi GPIO | 24 | Relay Channel | IN 6 |
Raspberry pi GPIO | 3.3v | 4x4 PB Matrix | R 1 |
Raspberry pi GPIO | 17 | 4x4 PB Matrix | C 1 |
Raspberry pi GPIO | 18 | 4x4 PB Matrix | C 2 |
Raspberry pi GPIO | 22 | 4x4 PB Matrix | C 3 |
Raspberry pi GPIO | 27 | 4x4 PB Matrix | C 4 |
Relay Channel VCC | 12v | 12v Power Supply | VCC |
Relay Channel GND | GND | 12v Power Supply | GND |
Relay Channel D7 | NO | Connected to Green LED +ve | 12v |
Relay Channel D7 | COM | Connected to 12v Power VCC + D6 COM | 12v |
Relay Channel D6 | NO | Connected to Red LED +ve | 12v |
Relay Channel D6 | COM | Connected to 12v Power VCC + D7 COM | 12v |
12v Green LED | GND | Connected to 12v Power GND + D6 COM | 12v |
12v Red LED | GND | Connected to 12v Power GND + D6 COM | 12v |
#NOTE: I have used Active LOW Relay Channel (Activate on LOW signal) and Raspberry PI 5 Output is Active High to avoid logic error, i have inverted my Active HIGH GPIO OUT Logic to LOW in my Code
- Upcoming – Upcoming Project Repositories