In the area of industrial internet of things, there are so many industrial slave devices behind the programable logic controller, they are not given any ip address or identity, how would we to map these devices 's identity and their controls over the application level on the cloud. For example, I am going to use the rasberrypi as a gateway, this gateway is connected with a PLC. Behind the PLC are many connected many slave devices like fans, LED lights, CO2 sensors.

I am very new to PLC and modbus protocol, even after reading the introduction, I still have the questions, the main question is how could we register and map the slave devices to gateway and finally to the IOT application layer. and under the main question there are many small questions to be answered like

  1. how could I determine the address for each device, is it determined manually or can be discovered from the slave device ?
  2. if one slave device is disfunctional, how could we find it out?
  • I see this as a general networking question, and not IoT specific. Normally, the server does not discover the clients. It binds to a port and they connect. That is to say, that they register with it. At which point, the server has the clients addresses. You can also google for modbus discover devices
    – Mawg
    Jan 15, 2017 at 10:25
  • 1
    @Mawa, I had searched the google however not finding too much valuable answers. I think one point for the question is there are so many industrial devices behind the programable logic controller, they are not given any ip address or names, how would we to map these devices 's identity and their controls over the application level on the cloud.
    – user824624
    Jan 15, 2017 at 10:38
  • 1
  • I hope all the Slave devices are controlled by the PLC. there aren't directly connected to the Internet or are assigned with any IP. So signalling the PLC and Making the PLC understand when to do what would be the option! Jan 15, 2017 at 11:54
  • Doesn't it depend on what you're using to capture the data, etc. and how to map the IO addresses from that device to whatever? For example an eWon e.g. ewon.biz/products/ewon-flexy has settings within it to do the address mappings, etc. I assume the Rasberry Pi would need something similar or you're need to program the logic. What PLC are you using exactly?
    – Facebook
    Jan 15, 2017 at 18:46

3 Answers 3


Looking at the Modbus function codes at wikipedia

Determine addresses

You can query the function codes Report Slave ID 17 and Read Device Identification 43.

Though your devices may not support this function and return with an exception code 1 (illegal function). If you don't get any response the device is either off or the ID is unoccupied.

You could list these devices on your raspberry pi. So you can create a list with values either: ID + identification, ID set, ID not set.

For Modbus/TCP this link may be usefull.

Find out of a device is dysfunctional

To find out if it's dysfunctional, you can poll diagnostics every now and then and listen for any exception messages.

If you do not get a message back, that could also indicate a problem (if the ID did have a device connected before).


The 'mapping' of the PLC will be done with variable tags.

You will structure the tagnames, and then route the data out over whatever protocol, in this case modbus. Check out the Advantech WISE-4060

Alternatively, you can have an OPC running on your network where you pull the data tags and their statuses.


Take a look at Node-Red. It runs on RPI and one of the node suites covers pretty much anything you would want to do with Modbus. It is open source and you can download a working image and run a script to get started.

I recently created a control system for water and temperature control using it and it was quick and easy.

As far as the discovery, I am afraid it will likely be akin to cleaning out grandma's attic. Just have to go through it all one box at a time! With the RPI on a network, it opens a world of connectivity as Node-Red can handle database, twitter, email, MQ, and just about any other protocol you can imagine. In addition, all the data can be surface to a web page by just dropping a couple of node on the canvas and dragging wires between them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.