**Table 2.**

*Input/output variables for Problem 1.*

We propose to use the library SimpleModbusSlave [7] which allows the Arduino board to communicate using Modbus RTU protocol. Note however that it does not fully comply with Modbus specifications, as only functions 3, 6 and 16 are implemented. Similarly, the check for inter character time-out and frame timeout are combined by checking a maximum time allowable when reading from the message stream. This library implements an unsigned int. return value on a call to modbus\_update(), which is the total error count since the slave started. Once this function is called, the input/output register defined during setup with function

### *Teaching IIoT through Hands-on Activities DOI: http://dx.doi.org/10.5772/intechopen.100217*

modbus\_configure() will be updated. Note that we have also successfully tested this library with Arduino Nano.

In addition to communication setup, it is possible to add other features in this Arduino program, to make it dynamic when visualizing the dashboard, as follows:


An example of code complying with these specifications is available in this link: https://bit.ly/3eqHmxB. It is possible to test this code, previously to developing user dashboard, with QModbus, which implements a master application through a graphical user interface, allowing communication with slaves over serial line interface [8]. Students are able to analyze Modbus frames, from master and slave.

The previous explanation corresponds to the edge layer. Now considering the gateway layer, Node Red is able to run in different devices. We have used a laptop for convenience. The following palettes must be installed:


An example of Node-Red code is available in this link https://bit.ly/2RnA9q0, as shown in **Figure 4**. The corresponding dashboard is shown in **Figure 5**.
