A process control demonstration using the Arduino UNO Q dual-processor development board to monitor a temperature sensor and remotely control coils on an Arduino Opta PLC over Modbus TCP. A Python mock server is included for development and testing without hardware.
Arduino UNO Q
┌──────────────────────────────────────────────┐
│ MCU (STM32) │
│ sketch.ino (C++) │
│ - Simulates temperature sensor │
│ - Broadcasts samples via Bridge │
│ │ Bridge.notify("sample_temperature")
│ MPU (Qualcomm / Debian Linux) │
│ main.py (Python) │
│ - Receives temperature via Bridge │
│ - Connects to Opta as Modbus TCP client │
│ - Threshold: 8000 (80 °C) │
│ ≥ 80 °C → coil_1=OFF, coil_2=ON │
│ < 80 °C → coil_1=ON, coil_2=OFF │
└──────────────────────┬───────────────────────┘
│ Modbus TCP (port 502)
┌────────┴────────┐
│ Arduino Opta │
│ (PLC server) │
│ 4 coils │
└─────────────────┘
For development without an Opta, replace the PLC with the mock server (port 5020).
| Directory | Description |
|---|---|
unoq-modbustcp-coil-controller/ |
Main UNO Q application — C++ MCU sketch + Python MPU client |
mock-opta-modbus-tcp-server/ |
Python async Modbus TCP server simulating the Opta PLC |
opta-modbustcp-server/ |
Arduino Opta firmware (AlPlc library + WiFi) |
articles/ |
Tutorial article, images, and demo video |
The UNO Q application split across two processors:
sketch/sketch.ino (C++ — MCU side)
Simulates a temperature sensor by ramping an integer value between 5000 (50 °C) and 10000 (100 °C) in steps, then back down, broadcasting each sample every second via Bridge.notify("sample_temperature", celsius).
python/main.py (Python — MPU side)
Receives temperature values via the Bridge callback, then writes to 4 coils on the Opta over Modbus TCP:
| Constant | Default | Description |
|---|---|---|
HOST |
"opta" |
Opta hostname (use IP or "YOUR HOST") |
PORT |
502 |
Modbus TCP port (5020 for mock server) |
DEVICE |
255 |
Modbus unit ID |
THRESHOLD |
8000 |
80 °C threshold |
COIL_ADDRESS |
0 |
Starting coil address |
COIL_COUNT |
4 |
Number of coils |
Change detection skips redundant writes; up to 3 retries with automatic reconnection on failure.
python/requirements.txt
pymodbus
An async Python Modbus TCP server that simulates an Arduino Opta with 4 coils (device ID 255). Useful for development and testing without physical hardware.
python3 mock_opta.py # listens on port 5020
python3 mock_opta.py 5021 # custom portSupports function codes FC01 (Read Coils), FC05 (Write Single Coil), and FC15 (Write Multiple Coils). PDU tracing is enabled for debugging.
To target the mock server from the UNO Q app, set HOST and PORT in main.py:
HOST = "YOUR HOST" # IP address of the machine running the mock server
PORT = 5020Arduino Opta PLC firmware acting as the Modbus TCP server. Built with the AlPlc library and WiFi connectivity.
| File | Description |
|---|---|
LLSketch/LLSketch.ino |
Main sketch — WiFi setup, AlPlc initialisation |
LLSketch/sketch.yaml |
Board/library configuration for Opta 1.0.3–1.3.0 |
Opta_ModbusTCP_Server.imgx |
Pre-built firmware image |
Opta_ModbusTCP_Server.plcprj |
Arduino Create project file |
Update the WiFi credentials in LLSketch.ino before flashing.
A full tutorial article (uno-q-modbus-controller.md) covering board setup, Arduino App Lab IDE installation, WiFi onboarding, source code walkthrough, and testing with both the mock server and real Opta hardware. Supporting images (img/) and a demo video (video/uno-q-to-opta.mp4) are included.
# Terminal 1 — start the mock Modbus TCP server
cd mock-opta-modbus-tcp-server
python3 mock_opta.py
# In main.py, set:
# HOST = "<your machine IP>"
# PORT = 5020Then deploy the UNO Q app via Arduino App Lab IDE.
- Update WiFi credentials in
opta-modbustcp-server/LLSketch/LLSketch.ino - Flash the Opta using Arduino App Lab or the pre-built
Opta_ModbusTCP_Server.imgx - In
unoq-modbustcp-coil-controller/python/main.pysetHOST = "opta"andPORT = 502 - Deploy the UNO Q application via Arduino App Lab IDE
- Arduino UNO Q (2 GB or 4 GB)
- Arduino Opta (optional — mock server can substitute)
- DIN rail power supply
- Indicator LEDs (e.g. Schneider Electric green/red)
- pymodbus — Modbus TCP client and server
- Arduino App Lab IDE — unified IDE for UNO Q dual-processor development
- Arduino platform:
arduino:mbed_opta(≥ 4.5.0) for Opta firmware - AlPlc_Opta library (1.3.2) for PLC functionality