Skip to main content
IoT

Building Industrial IoT Gateway with Raspberry Pi

Guide to building IoT Gateway for industrial factories using Raspberry Pi and Protocol Converters

SmileX

SmileX

Founder & CEO

1 min read
Building Industrial IoT Gateway with Raspberry Pi

Introduction

An Industrial IoT (IIoT) Gateway is the bridge between factory devices and the cloud platform. In this article, we will build a gateway using a Raspberry Pi.

Hardware Requirements

  • Raspberry Pi 4 (4GB+ recommended)
  • RS-485 HAT for Modbus RTU
  • Digital I/O HAT
  • UPS HAT (for power backup)
  • Industrial case

Software Stack

Base System

Terminal window
# Install Raspberry Pi OS Lite (64-bit)
# Then install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

Docker Compose Stack

version: '3.8'
services:
# MQTT Broker
mosquitto:
image: eclipse-mosquitto:2
volumes:
- ./mosquitto:/mosquitto/config
ports:
- "1883:1883"
# Node-RED for flow programming
nodered:
image: nodered/node-red
volumes:
- ./nodered:/data
ports:
- "1880:1880"
# Telegraf for metrics collection
telegraf:
image: telegraf
volumes:
- ./telegraf:/etc/telegraf
privileged: true

Modbus RTU Integration

// Node-RED function node
const ModbusRTU = require("modbus-serial");
const client = new ModbusRTU();
// Connect to Modbus device
await client.connectRTUBuffered("/dev/ttyAMA0", {
baudRate: 9600,
parity: "none"
});
// Read holding registers
const data = await client.readHoldingRegisters(1, 0, 10);
msg.payload = data.data;
return msg;

Edge Computing with Node-RED

[
{
"id": "temperature_alert",
"type": "function",
"func": "if (msg.payload.temp > 80) {\n msg.alert = 'HIGH_TEMP';\n}\nreturn msg;"
}
]

Conclusion

Building an Industrial IoT Gateway with a Raspberry Pi is a cost-effective and flexible choice that can be customized to suit the needs of any factory.

Share:
SmileX

About the Author

SmileX

Founder & CEO

Founder of RACKSYNC with 14+ years of experience in IoT, Cloud Infrastructure, and Smart Home solutions.