WolkWriter
Published © GPL3+

Modbus IoT Gateway

Read and write to multiple Modbus RTU slaves from the cloud through serial communication using WolkAbout IoT Platform.

IntermediateProtip1 hour2,758
Modbus IoT Gateway

Things used in this project

Hardware components

IOT-GATE-RPi Industrial Raspberry Pi IoT Computer
×1

Software apps and online services

WolkAbout IoT Platform
WolkAbout IoT Platform

Story

Read more

Schematics

Connection schematic

Connecting Modbus slaves to IOT-GATE RPi

Code

wolk_gateway.service

Plain text
Service that will run WolkGateway
[Unit]
 Description=Gateway for connecting non-IP enabled devices to WolkAbout IoT Platform
 After=multi-user.target

[Service]
 Type=idle
 WorkingDirectory=/home/<USER_NAME>/WolkGateway/out/
 ExecStart=/home/<USER_NAME>/WolkGateway/out/WolkGatewayApp gatewayConfiguration.json
 Restart=always

[Install]
 WantedBy=multi-user.target

modbus_module.service

Plain text
Service that will run WolkGatewayModule-Modbus
[Unit]
 Description=WolkAbout Gateway Module for Modbus devices
 After=multi-user.target

[Service]
 Type=idle
 WorkingDirectory=/home/<USER_NAME>/WolkGatewayModule-Modbus/out/
 ExecStart=/home/<USER_NAME>/WolkGatewayModule-Modbus/out/modbusModule deviceConfiguration.json modbusConfiguration.json modbusRegisterMapping.json
 Restart=always

[Install]
 WantedBy=multi-user.target

modbusConfiguration.json

JSON
This is the Modbus connection configuration used for DC motor slaves
{
    "ip": "192.168.100.1",
    "port": 502,

    "serialPort": "/dev/ttyAMA0",
    "baudRate": 115200,
    "dataBits": 8,
    "stopBits": 1,
    "bitParity": "NONE",
    "slaveAddress": 1,

    "connectionType": "SERIAL/RTU",

    "responseTimeoutMs": 200,
    "registerReadPeriodMs": 500
}

modbusRegisterMapping.json

JSON
This is the Modbus register mapping used for DC motor slaves
{
   "modbusRegisterMapping":[
      {
         "name":"Slave 1 Speed",
         "reference": "s_1_speed",

         "minimum": 0,
         "maximum": 200,

         "address": 0,
         "registerType": "HOLDING_REGISTER_ACTUATOR",
         "dataType": "UINT16",
         "slaveAddress" : 1
      },
      {
         "name":"Slave 1 Direction",
         "reference": "s_1_direction",

         "address": 0,
         "registerType": "COIL",
         "dataType": "BOOL",
         "slaveAddress" : 1
      },
      {
         "name":"Slave 1 Stop-Start",
         "reference": "s_1_stop_start",

         "address": 1,
         "registerType": "COIL",
         "dataType": "BOOL",
         "slaveAddress" : 1
      },
      {
         "name":"Slave 1 Short Brake",
         "reference": "s_1_short_brake",

         "address": 2,
         "registerType": "COIL",
         "dataType": "BOOL",
         "slaveAddress" : 1
      },
      {
         "name":"Slave 1 Standby",
         "reference": "s_1_standby",

         "address": 3,
         "registerType": "COIL",
         "dataType": "BOOL",
         "slaveAddress" : 1
      },
      {
         "name":"Slave 2 Speed",
         "reference": "s_2_speed",

         "minimum": 0,
         "maximum": 200,

         "address": 0,
         "registerType": "HOLDING_REGISTER_ACTUATOR",
         "dataType": "UINT16",
         "slaveAddress" : 2
      },
      {
         "name":"Slave 2 Direction",
         "reference": "s_2_direction",

         "address": 0,
         "registerType": "COIL",
         "dataType": "BOOL",
         "slaveAddress" : 2
      },
      {
         "name":"Slave 2 Stop-Start",
         "reference": "s_2_stop_start",

         "address": 1,
         "registerType": "COIL",
         "dataType": "BOOL",
         "slaveAddress" : 2
      },
      {
         "name":"Slave 2 Short Brake",
         "reference": "s_2_short_brake",

         "address": 2,
         "registerType": "COIL",
         "dataType": "BOOL",
         "slaveAddress" : 2
      },
      {
         "name":"Slave 2 Standby",
         "reference": "s_2_standby",

         "address": 3,
         "registerType": "COIL",
         "dataType": "BOOL",
         "slaveAddress" : 2
      }
   ]
}

WolkGatewayModule-Modbus

Modbus DC motor slave

WolkGateway

Credits

WolkWriter

WolkWriter

10 projects • 20 followers
With WolkAbout IoT Platform, we give you proven technology to develop powerful IoT applications and control your business ecosystem.

Comments