Building Industrial IoT Gateway with Raspberry Pi
Guide to building IoT Gateway for industrial factories using Raspberry Pi and Protocol Converters
SmileX
Founder & CEO
1 min read
บทนำ
Industrial IoT (IIoT) Gateway เป็นสะพานเชื่อมระหว่างอุปกรณ์ในโรงงานกับ Cloud Platform ในบทความนี้ เราจะสร้าง Gateway ด้วย Raspberry Pi
Hardware Requirements
- Raspberry Pi 4 (4GB+ recommended)
- RS-485 HAT สำหรับ Modbus RTU
- Digital I/O HAT
- UPS HAT (สำหรับ power backup)
- Industrial case
Software Stack
Base System
# ติดตั้ง Raspberry Pi OS Lite (64-bit)# จากนั้นติดตั้ง Dockercurl -fsSL https://get.docker.com -o get-docker.shsudo sh get-docker.shDocker 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: trueModbus RTU Integration
// Node-RED function nodeconst ModbusRTU = require("modbus-serial");const client = new ModbusRTU();
// Connect to Modbus deviceawait client.connectRTUBuffered("/dev/ttyAMA0", { baudRate: 9600, parity: "none"});
// Read holding registersconst 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;" }]บทสรุป
การสร้าง Industrial IoT Gateway ด้วย Raspberry Pi เป็นทางเลือกที่คุ้มค่าและยืดหยุ่น สามารถปรับแต่งได้ตามความต้องการของโรงงาน