How to Read Modbus Data from Milesight Controller and sent to Mqtt broker

Step1. Add Device to Milesight gateway

To add a device to the Milesight gateway you will need to define an application and a profile first. The application is a collection of devices with the same purpose and a profile defines the devices capabilities.

To configure an application do the following:

  1. login to the Milesight Web GUI.

  2. Go to “Network Server” -> “Applications”.

  3. Press the ‘+’ button.

  4. Name the application and save.

To configure a profile do the following:

  1. login to the Milesight Web GUI.

  2. Go to “Network Server” -> “Profiles”.

  3. Press the ‘+’ button.

  4. Name the profile and save.

To add the device do the following:

  1. login to the Milesight Web GUI.

  2. Go to “Network Server” -> “Device”.

  3. Press the ‘Add’ button.

  4. Fill in the Device EUI and Application Key

  5. Select the Application and Device-Profile

  6. Name the device.

  7. At Modbus RTU Data transmission : Modbus RTU over TCP and set port “502” *fport is slave ID, NetID (ICP Das Device)

Step 2 Start Node-red

  1. Go to “App > Node-RED” to enable the Node-RED feature.

  2. After enabled, click “Launch” to go to the Node-RED web GUI and to log in with the same username and password as gateway

  3. Add Modbus read Node and Configured Sensors address then click ✎

  4. Setting Host by use gateway IP, Port 502 and TCP Type Telnet and save

  5. Add function node for convert Array to string. If original data type not array, no need to add function node

  6. Add Mqtt out node for public data to Mqtt broker.