🤝 Can CODESYS Work with Arduino?
✅ YES — With Communication Protocols
You can connect Arduino to a CODESYS-controlled system by using common
communication protocols like:
Modbus RTU or Modbus TCP
Serial (UART)
MQTT
CAN bus (if Arduino has a CAN shield)
❌ NO — You Can’t Run CODESYS on Arduino
Arduino hardware (e.g., ATmega328, ESP32, etc.) cannot run the CODESYS runtime,
because:
It's not supported officially.
The microcontroller doesn't have the required OS or memory resources.
🧩 Integration Options
1. Arduino as Modbus Slave
Let CODESYS act as a Modbus master and Arduino as a Modbus slave.
Use a Modbus library on Arduino like ModbusRTU or ModbusTCP.
Connect over Serial or Ethernet (e.g., using an Ethernet Shield).
In CODESYS, use the Modbus Master configuration to read/write data.
✅ Best for simple sensor/actuator communication.
2. Arduino & MQTT (with CODESYS MQTT Client)
Use Arduino to publish/subscribe data via MQTT to a broker.
Arduino publishes data to MQTT topics (e.g., temperature).
CODESYS subscribes to these topics using its MQTT client libraries.
✅ Good for IoT and wireless setups.
3. CAN Bus (Advanced)
If both Arduino and CODESYS PLC support CAN, use it to exchange messages.
Arduino uses CAN shield.
CODESYS uses CANopen (more structured, industrial standard).
4. Serial/USB Communication
Arduino sends data via serial to a CODESYS controller (e.g., Raspberry Pi or IPC
with UART).
Use SysCom libraries in CODESYS to read/write serial data.
Arduino can send structured messages like:
cpp
Copiar
Editar
Serial.println("TEMP:24.5");
✅ Good for low-cost solutions, but requires message parsing logic.
Tools You Might Use
Platform Role Library/Tool Needed
Arduino Sensor/Actuator Modbus, MQTT, Serial, CAN libraries
CODESYS PLC (Master) Modbus Master, MQTT Client, SysCom
Broker MQTT Gateway Mosquitto (if using MQTT)
📦 Example: Arduino (Temperature Sensor) to CODESYS via Modbus
Arduino reads temperature from DHT sensor.
Writes the value to Modbus holding register 40001.
CODESYS reads that value and displays it in HMI.