The Raspberry Pi has found serious traction in industrial IoT applications — from factory floor monitoring to building management systems. With Modbus for communicating with industrial sensors, MQTT for lightweight messaging, and Node-RED for visual workflow programming, a single Pi 5 can serve as a powerful edge gateway connecting operational technology (OT) to IT infrastructure.
Table of Contents
- Why Raspberry Pi for Industrial IoT
- Industrial-Grade Hardware Setup
- Modbus Communication: RTU and TCP
- MQTT: Lightweight Industrial Messaging
- Node-RED: Visual Programming for IIoT
- Building an Industrial Dashboard
- Deployment and Reliability Considerations
- Frequently Asked Questions
- Conclusion
Why Raspberry Pi for Industrial IoT
Traditional industrial IoT gateways from Siemens, Advantech, or Moxa cost ₹50,000-2,00,000. A Raspberry Pi 5 with industrial accessories costs ₹15,000-25,000 and runs the same protocols (Modbus, MQTT, OPC-UA) with the flexibility of a full Linux system.
Where the Pi fits in industrial environments:
- Edge gateway: Collect data from PLCs, sensors, and meters via Modbus, and forward to cloud platforms or local databases
- Protocol translator: Bridge legacy serial devices (RS-485 Modbus RTU) to modern IP networks (MQTT, HTTP, OPC-UA)
- Local HMI: Display dashboards on factory floor screens showing real-time production metrics
- Data logger: Record temperature, pressure, flow, and energy consumption data for compliance and analysis
- Alerting: Monitor sensor thresholds and send SMS/email/WhatsApp alerts when values exceed limits
The Pi is not suitable for safety-critical control systems or real-time PLC replacement. It excels as a data collection, processing, and visualisation layer that sits alongside existing industrial equipment.
Industrial-Grade Hardware Setup
Industrial environments demand more robust hardware than a desktop setup:
Essential components:
- Raspberry Pi 5 (4GB) — main processing unit
- Industrial metal case — DIN rail mountable for control cabinet installation
- RS-485 HAT or USB adapter — for Modbus RTU communication with industrial devices
- PoE HAT — power over Ethernet eliminates separate power supplies
- RTC battery — for accurate timestamps when network is unavailable
- Reliable power supply — industrial 24V to 5V converter for DIN rail power
RS-485 communication: Most industrial sensors, meters, and PLCs communicate via RS-485 (Modbus RTU). The Pi needs an RS-485 interface — either a USB-to-RS-485 converter (₹300-800) or a HAT module with isolated RS-485.
Modbus Communication: RTU and TCP
Modbus is the most common industrial communication protocol. It comes in two variants:
Modbus RTU: Serial communication over RS-485 wiring. Used by most field devices — energy meters, temperature sensors, flow meters, and VFDs (variable frequency drives). Data is transmitted as binary over serial connections at 9600-115200 baud.
Modbus TCP: Modbus over Ethernet/IP networks. Used by modern PLCs, SCADA systems, and network-enabled devices. Uses TCP port 502.
Reading a Modbus RTU device with Python:
from pymodbus.client import ModbusSerialClient
# Connect to an energy meter on RS-485
client = ModbusSerialClient(
port='/dev/ttyUSB0', # USB-RS485 adapter
baudrate=9600,
parity='N',
stopbits=1,
bytesize=8,
timeout=3
)
client.connect()
# Read holding registers (function code 0x03)
# Slave ID=1, Start register=0, Count=10
result = client.read_holding_registers(address=0, count=10, slave=1)
if not result.isError():
voltage = result.registers[0] / 10.0 # Scale factor depends on device
current = result.registers[1] / 100.0
power = result.registers[2]
print(f"Voltage: {voltage}V, Current: {current}A, Power: {power}W")
client.close()
Reading Modbus TCP:
from pymodbus.client import ModbusTcpClient
client = ModbusTcpClient('192.168.1.50', port=502)
client.connect()
result = client.read_holding_registers(address=0, count=10, slave=1)
if not result.isError():
print(result.registers)
client.close()
Common Indian industrial devices with Modbus:
- Energy meters (Schneider, L&T, Elmeasure) — kWh, voltage, current, power factor
- Temperature controllers (Selec, Autonics) — process temperature, setpoint
- VFDs (ABB, Siemens, Danfoss) — motor speed, current, frequency
- Flow meters (various) — flow rate, totaliser readings
MQTT: Lightweight Industrial Messaging
MQTT is a publish/subscribe messaging protocol designed for unreliable networks and constrained devices. It is the standard for IoT data transport.
Install Mosquitto MQTT broker on the Pi:
sudo apt install -y mosquitto mosquitto-clients
sudo systemctl enable mosquitto
The Pi now runs a local MQTT broker. Devices publish sensor data to topics, and subscribers (dashboards, databases, cloud platforms) receive the data.
MQTT topic structure for a factory:
factory/floor1/machine1/temperature
factory/floor1/machine1/vibration
factory/floor1/machine1/status
factory/floor1/energy/total_kwh
factory/floor2/machine3/pressure
Publishing Modbus data to MQTT (Python):
import paho.mqtt.client as mqtt
from pymodbus.client import ModbusSerialClient
import time, json
# MQTT setup
mqttc = mqtt.Client()
mqttc.connect("localhost", 1883)
# Modbus setup
modbus = ModbusSerialClient(port='/dev/ttyUSB0', baudrate=9600)
modbus.connect()
while True:
result = modbus.read_holding_registers(address=0, count=5, slave=1)
if not result.isError():
data = {
"voltage": result.registers[0] / 10.0,
"current": result.registers[1] / 100.0,
"power": result.registers[2],
"energy": result.registers[3],
"timestamp": time.time()
}
mqttc.publish("factory/energy/meter1", json.dumps(data))
time.sleep(5) # Poll every 5 seconds
This script reads an energy meter via Modbus RTU every 5 seconds and publishes the data to the local MQTT broker. Any MQTT client — Node-RED, Grafana, a mobile app, or a cloud platform — can subscribe to this topic and receive live data.
Node-RED: Visual Programming for IIoT
Node-RED is a flow-based visual programming tool that runs on Node.js. You connect nodes (blocks) together to create data processing workflows — no traditional coding required.
Install Node-RED:
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
sudo systemctl enable nodered
sudo systemctl start nodered
Access the Node-RED editor at http://pi-ip:1880.
Essential Node-RED palettes for IIoT:
node-red-contrib-modbus— Read/write Modbus RTU and TCP devices directly from Node-REDnode-red-dashboard— Create real-time dashboards with gauges, charts, and buttonsnode-red-contrib-influxdb— Store time-series data in InfluxDB for historical analysisnode-red-node-email— Send alert emails when thresholds are exceeded
Example flow: Energy monitoring with alerts
- Modbus Read node polls energy meter every 10 seconds
- Function node extracts voltage, current, and power values
- Dashboard gauge nodes display live values
- Switch node checks if power exceeds threshold
- Email node sends alert to plant manager
- InfluxDB node stores all readings for historical charts
This entire flow is created visually by dragging, dropping, and connecting nodes — no Python scripts needed. For teams that include electricians and plant operators, Node-RED’s visual approach makes IIoT accessible without programming expertise.
Building an Industrial Dashboard
Combine Node-RED Dashboard, InfluxDB, and Grafana for a comprehensive monitoring stack:
Node-RED Dashboard: Quick, real-time dashboards for live monitoring. Gauges show current values, charts show recent trends, and buttons allow operator interaction. Access at http://pi-ip:1880/ui.
InfluxDB + Grafana stack: For historical analysis and reporting. InfluxDB stores time-series data efficiently (months of readings in minimal storage). Grafana creates professional dashboards with drill-down capabilities, alerts, and PDF report generation.
# Install InfluxDB
sudo apt install -y influxdb influxdb-client
sudo systemctl enable influxdb
# Install Grafana
sudo apt install -y grafana
sudo systemctl enable grafana-server
Grafana runs at http://pi-ip:3000 (default login: admin/admin). Add InfluxDB as a data source, create dashboards showing energy consumption trends, production output, temperature profiles, and equipment uptime.
Deployment and Reliability Considerations
Power protection: Industrial environments have power quality issues — surges, sags, and outages. Use a DIN rail-mounted 24V to 5V converter with surge protection, or power the Pi via PoE with a managed switch that has UPS backup.
Environmental protection: Factory environments involve dust, humidity, vibration, and temperature extremes. Mount the Pi in a sealed IP65 enclosure for harsh environments, or a DIN rail case for control cabinets with climate control.
Data integrity:
- Use a read-only root filesystem with tmpfs for log files
- Store persistent data on NVMe (more reliable than SD cards under constant writes)
- Implement circular buffers for data storage — never let the disk fill up
- Use MQTT QoS levels to ensure message delivery even during network interruptions
Remote monitoring: Install Tailscale or WireGuard for secure remote access. Monitor the Pi itself (CPU temperature, disk usage, network connectivity) alongside the industrial data it collects.
Frequently Asked Questions
Can a Raspberry Pi replace a PLC?
No. PLCs provide deterministic, real-time control with hardware-level safety features (watchdogs, fail-safe states). The Pi is a monitoring and data collection tool, not a control device. Use PLCs for machine control; use the Pi as an edge gateway to collect, process, and visualise the data PLCs generate.
How many Modbus devices can a Pi handle?
A single RS-485 bus supports up to 32 devices (or 256 with repeaters). Polling 30 devices with 10 registers each at 9600 baud takes approximately 15-20 seconds per cycle. For faster polling, use higher baud rates (19200, 38400) or Modbus TCP over Ethernet.
Is the Raspberry Pi reliable enough for industrial use?
With proper hardware protection (industrial case, surge protection, UPS), a Pi runs reliably for years. The main failure point is the SD card — mitigate this by using NVMe storage or read-only filesystem. Many companies deploy Raspberry Pi in production industrial environments.
Can I connect to a cloud platform like AWS IoT or Azure IoT?
Yes. Node-RED has nodes for AWS IoT Core, Azure IoT Hub, Google Cloud IoT, and ThingsBoard. The Pi acts as an edge gateway — collecting local data and forwarding it to the cloud for enterprise-wide analytics and storage.
What about the Raspberry Pi Compute Module for industrial use?
The CM4 and CM5 are designed for industrial applications. They mount on custom carrier boards that can include specific industrial interfaces (CAN bus, isolated RS-485, 24V I/O). For production deployments of 50+ units, the Compute Module with a custom carrier board is the professional approach.
Conclusion
The Raspberry Pi brings IT-level flexibility to operational technology environments. Modbus connects it to existing industrial equipment, MQTT provides a scalable messaging layer, and Node-RED makes data processing accessible to engineers who are not software developers. The result is an industrial IoT gateway at a fraction of the cost of commercial alternatives.
Start by connecting a single energy meter or temperature sensor. Once the data flows from Modbus through MQTT to a Grafana dashboard, the potential becomes clear — and expanding to additional devices and locations is straightforward.
Find Raspberry Pi boards and industrial accessories at Zbotic’s Raspberry Pi collection — fast shipping across India.
Add comment