Temperature Measurements with RevPi Core as Modbus TCP Master

This tutorial is valid from the Image Jessie. Unfortunately, it doesn’t apply to Wheezy.

In the following example we measure the temperature with a sensor and use our RevPi Core as Modbus TCP Master.

You have a similar project? Great, then just follow our example! Of course, you have to adjust some data..

Requirements:

  • RevPi Core and Modbus-TCP slaves are located in the same network
  • Modbus-TCP slaves have static IP addresses.

Connecting the Slave to the RevPi Core

  • Connect the slave to your RevPi Core via the RJ45 jack.
  • Connect your RevPi Core to the power supply.

Determine Modbus TCP network data

In order to configure the slave, we need some data beforehand, so that we can address the sensor via our RevPi Core. We find this data in the user manual of our slave.

In this example we use the temperature sensor “Inveo NANO TEMP” as slave.

  • Note the following data from the manual of your slave:
Name Value
IP adress 192.168.0.103
Port 502
Modbus register temperature x10 4004
Modbus function „Read Holding Registers“
Slave adress 1

Enable Modbus-TCP Master function

  • Open your web browser.
  • Enter the IP address of your RevPi Core in the address bar of your web browser.

The login window appears.

pictory-anmelden
  • Log in with the username “admin”.
  • Enter the password. You can find it on the sticker on the side of your RevPi Core.
  • Click „Login“.

You can now see the current device status of your RevPi Core.

  • Click the „Services“ tab.
  • Click “Enabled” in the Enable/Disable Modbus Master line.
  • Click the “Save All” button.
Services tab screenshot

Note! You can also activate the Master function on the command line. Enter the following command: “sudo revpi-config enable pimodbus-master”.

  • Click the „Apps“ tab.
  • Click the start button behind the entry “PiCtory”.
Apps tab screenshot

PiCtory starts.

Modbus-TCP Master Configuration

  • Open the folder “Virtual Devices”in the device catalog.
  • Select Modbus-TCP Master.
  • Hold down the left mouse button and drag the Modbus TCP Master to your RevPi Core.

Your Modbus-TCP Master will now appear on the far right of the Configuration Board.

  • Set the basic settings for your adapters in the “Device Data” window. This entry is optional.  If you use a lot of devices and want to process the data later in another program, this input can be very helpful.
PLEASE NOTE
For each slave you want to use, you need a virtual master.
  • In the “Value Editor” we define the settings for the TCP connection.  We’ve already determined the values from the sensor’s instruction manual::

 

  • Right-click on the Modbus-TCP Master on the Configuration Board.
  • A context menu opens.
  • Select the entry “Extended Data”.

An input mask opens.

This is where we set the Modbus commands. In this example, we need a command to read the temperature values of the sensor. We have already gathered the necessary information from the sensor’s operating instructions:

    Slave Addr.: 1
    Function Code: READ_HOLING_REGISTERS
    Register Addr.: 4004
    Quantity of Registers: 1
    Action Interval (ms): 1000
    Device Value: Input_Word_1

Save configuration

  • Click on „File>Save“ to save the file.

  • Click on “Tools>Reset Driver”. This activates the changes for the adapter.

Query values in the process image

  • Open command line and enter following command:
piTest -r Input_Word_1

You receive the data of your slave:  

 2 Byte-Value of Input_Word_1: 284 dez (=011c hex)

In our example, we get the temperature data. The value 284 corresponds to 28.4 °C