A CODESYS runtime on a Pi can communicate with an Arduino Nano over Modbus RTU, but the reported installation has two distinct faults: an initial “not running” condition and a connection that does not recover after the Arduino is unplugged. Treat startup and reconnection separately because the available evidence does not establish a common root cause.
Interpret the CODESYS Device States
The initial configuration showed red triangles beside both the Modbus master and slave, while the slave reported “not running.” Another Arduino program later established communication, confirming that the hardware path can work. The evidence does not identify which Arduino library version, CODESYS runtime version, serial settings, or device diagnostic produced the initial failure.
| Observed condition | What is confirmed | Engineering decision |
|---|---|---|
| Master and slave show red triangles | The CODESYS device tree reports a fault state. | Read the master and slave diagnostics before changing hardware. |
| Slave reports “not running” | The configured slave is not operating. | Resolve master startup and serial-port access before troubleshooting register data. |
| Different Arduino code works | Communication can be established through the existing hardware path. | Compare the working program's protocol and serial configuration with the failed program. |
| Unplugging and reconnecting does not restore communication | The established connection does not recover after USB removal. | Troubleshoot port recovery independently from initial communication. |
Verify the Initial Modbus RTU Configuration
Start from the configuration that successfully exchanges data. Record the selected serial interface and every configured Modbus RTU communication setting on both endpoints, then confirm that the Arduino program implements the same slave behavior expected by CODESYS. Do not attribute the failure to a library change until the working and failing Arduino programs have been compared under identical CODESYS settings.
- Start CODESYS with the Arduino connected and capture the master and slave status details.
- Confirm that the configured serial interface is the interface actually assigned to the Arduino connection.
- Compare all serial and Modbus settings between CODESYS and the working Arduino program; the evidence supplies no values, so do not assume defaults.
- Prove a successful data exchange before testing disconnect recovery.
Characterize the USB Reconnection Failure
With communication established, unplug the Arduino, record the resulting master and slave states, reconnect it, and determine whether the operating system presents the same serial interface afterward. If the interface identity changes, correct interface selection before investigating the Modbus master. If it remains the same, capture the CODESYS diagnostics to distinguish a retained fault state from a missing or inaccessible port.
The reported Auto-reconnect setting is not a demonstrated workaround: enabling it prevented normal operation and produced a flashing red/orange triangle beside the slave. Reproduce that behavior from a clean startup with Auto-reconnect disabled and enabled, changing no other setting. The resulting diagnostic text is required to identify why enabling the option blocks operation.
Plan a Controlled Recovery
The evidence does not provide a verified CODESYS command, function block, or API for resetting this Modbus master, so an exact reset implementation cannot be specified safely. First verify whether the configured master exposes a documented application-controlled stop/start or reinitialization mechanism. If it does, invoke recovery only after detecting the communication fault and confirming that the serial interface is available again; then verify that the slave returns to an operating state and resumes data exchange.
If no supported runtime reset mechanism is available, retain the diagnostic record and escalate the runtime version, device configuration, Auto-reconnect behavior, and post-reconnect interface identity through the official CODESYS support channel.
FAQ
Why does my CODESYS Modbus slave say “not running”?
The evidence confirms that this state appeared with red triangles beside both the master and slave, but it does not identify the cause. Inspect both device diagnostics and verify serial-interface access and matching Modbus RTU settings before testing register data.
Why will CODESYS not reconnect to an Arduino after USB unplugging?
First check whether the Arduino returns on the same serial interface. If it does, capture the CODESYS master and slave diagnostics after reconnection to determine whether the master retained a fault state.
Should I enable Auto-reconnect for CODESYS Modbus RTU?
Not without a controlled test on this installation. In the reported case, enabling Auto-reconnect prevented operation and produced a flashing red/orange slave triangle, so compare enabled and disabled startups and record the associated diagnostic text.