This repository contains prototype codes that demonstrate how Arduino Opta PLC, Raspberry Pi, and Blockchain can work together in real-world IoT and supply chain contexts. The focus is on reliable data collection, secure communication (via Modbus TCP), and blockchain anchoring of sensor data for tamper-proof Digital Product Passports (DPP).
This sketch configures the Arduino Opta PLC to act as a Modbus TCP client. It communicates with a Raspberry Pi acting as a Modbus server.
Uses the ArduinoModbus and Ethernet libraries in Aeduino IDE.
Establishes static IPs for both Opta (192.168.60.2) and Pi (192.168.60.1).
Polls three Modbus Holding Registers every second:
HR0: sensor voltage (mV → V)
HR1: sensor resistance Rs (kΩ)
HR2: normalized Rs/R0 ratio
It avoids small fluctuations by applying threshold filters (EPS). Only significant changes trigger new serial output, reducing spam.
Key Outcome: The PLC continuously monitors sensor values sent from the Raspberry Pi and can later use them to drive actuators or alarms.
The Python script demonstrates the data acquisition and blockchain anchoring pipeline:
-
Sensor Interface
-
Reads analog signals from an MQ gas sensor using an ADS1115 ADC via I²C.
-
Performs calibration in clean air to determine baseline R0.
-
Computes Rs and the ratio Rs/R0.
-
Emission Data XML
Formats sensor readings into an XML payload:
<EmissionData>
<DeviceID>MQ_01</DeviceID>
<Timestamp>2025-08-17T10:00:00Z</Timestamp>
<GasType>CO2</GasType>
<Voltage unit="V">0.542</Voltage>
<SensorResistance unit="ohm">9,800</SensorResistance>
<RsOverR0>1.235</RsOverR0>
<Location>Warehouse_A</Location>
</EmissionData>
Hashes the XML payload using SHA-256.
Anchors the hash to an Ethereum in-memory blockchain (EthereumTester).
Stores the proof of immutability on-chain, along with transaction details (TX hash, block number).
Key Outcome: The Pi acts as both a sensor gateway and a blockchain anchor node, bridging the physical and digital layers.

A separate PLC-IDE/ folder will later include IEC 61131-3 compliant PLC projects (.plcproj) created with the Arduino PLC IDE, showcasing ladder logic or structured text versions of the same workflow.
-
Raspberry Pi reads CO₂ sensor → converts values → builds XML.
-
Raspberry Pi anchors XML hash on blockchain → proof of immutability.
-
Arduino Opta PLC connects to Pi via Modbus TCP → polls sensor values in real time.
-
PLC can use these values for decision-making (e.g., trigger ventilation, alarms, or actuators).
-
This creates a verifiable chain of trust:
-
Arduino Opta PLC (Ethernet-capable PLC)
-
Raspberry Pi (any model with I²C + Ethernet)
-
ADS1115 ADC module
-
MQ-series gas sensor (e.g., MQ-135 for CO₂ equivalent)
-
Ethernet network (or direct cable Pi ↔ Opta)
-
Arduino IDE with ArduinoModbus and Ethernet libraries
-
Python 3 with dependencies:
pip install adafruit-circuitpython-ads1x15 web3
- Local EthereumTester (built into Web3.py)
Supply Chain Sustainability: Tamper-proof CO₂ emission logs tied to Digital Product Passports.
IoT–PLC Interoperability: Real-time monitoring where industrial controllers can act on IoT sensor data.
Research Prototypes: Academic demonstration of blockchain-based sustainability tracking.
This project is licensed under the MIT License – see the LICENSE file for details.