Tutorial Modbus TCP Slave (Jessie)

In the following example, we provide a Modbus TCP master with the CPU temperature of the RevPi core. The RevPi Core takes on the role of a slave. You have a similar project? Great, then just follow our example! Of course, you have to adjust some data.

Info! In this example, we use the software “qModMaster” on a Windows PC to simulate a Modbus master. You can download this software at https://sourceforge.net/projects/qmodmaster if you want to follow this example.

Let’s go!

Connect your RevPi Core to the Master via the RJ45 connector.

Connect your RevPi Core to the power supply.

Enable Modbus-TCP Slave 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.

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 Slave line.

Click the “Save All” button.

Click the “Apps” tab.

Click the start button behind the entry “PiCtory”.

PiCtory starts.

Modbus TCP Slave Configuration

Open the folder “Virtual Devices”in the device catalog.

Select Modbus TCP-Slave.

Hold down the left mouse button and drag the Modbus TCP slave to your RevPi Core.

Your Modbus TCP slave 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.

In the “Value Editor” we define the settings for the TCP connection. In our example, this is:

TCP_port: 502

The default value of the TCP port is “502”according to Modbus specification. You can change this value. That makes sense, if you want to implement 2 different controllers in the same network, which should not interfere with each other..

max._modbus_TCP_connections: 10

Saving PiCtory configuration

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

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

Query CPU temperature

You can query the CPU temperature of your RevPi Cores with the following command in the command line:

/usr/bin/vcgencmd measure_temp

You get the current output of the temperature:

/usr/bin/vcgencmd measure_temp
temp=48.7'C

In order to process the values on the Modbus, we have to convert this output. The temperature must be output as x10 °C:

Sign up to our newsletter and be among the first to hear about the latest development.

We use double opt-in for our newsletter subscription so we are 100% sure we aren't spamming anyone. Please pay attention to the confirmation email, you get after your signup. If you don`t confirm your email address, your newsletter subscription won`t be activated. If you don`t get any confirmation email, it may be in your Junk or Spam mailbox. If not, please email us at admin@kunbus.de to confirm your email subscription.