Connecting Modbus RTU Smart Energy Meter and Siemens Simatic IoT2040 to NETPIE

This article explains how to read data from Mitsubishi Modbus Energy Meter using industrial gateway Siemens Simatic IoT2040. The Simatic IoT2040 is the most preferred choice for industries to make their production data visualized in the domain of Industrial Internet-of-Things (IIoT).

Requirements:

  1. Modbus Energy Meter (Mitsubishi SX1-A31E)
  2. Siemens Simatic IoT2040
  3. Power supply 24V DC
  4. SD-card with Yocto Linux
  5. Ethernet Cable
  6. Node-Red
  7. NETPIE account

Simatic IoT2040 Specifications:

  1. Intel Quark X1020 processor
  2. 1 GB RAM
  3. 2 X Ethernet interfaces
  4. 2 X RS232/422/485 interface
  5. Battery-buffered real-time clock

Mitsubishi Modbus Energy Meter Specifications:

  1. RS485 2 wires half-duplex
  2. RTU Mode
  3. BaudRate 1200bps
  4. Distance 1200m
  5. Response time 80ms~200ms (programmable)

Preparing Simatic IoT2040:

The first step is to boot image onto Simatic, for this SD-card of atleast 8GB is required. The Yocto Linux image can be downloaded from Siemens website. Insert SD-card into the SD-card slot of Linux computer and follow below instructions

a) On Linux, open Terminal (ctrl+alt+t) and go to the location where the zip files are downloaded.

b) Unzip the folder using command below

c) Verify the location of SD-card by running the command below

d) Unmount the SD-card

e) Burn the image file onto SD-card

NOTE: Replace the name of the image with downloaded image version and location of SD-card, detected by your computer.

Once the image is installed onto SD-card, place the SD-card into SD-card slot of Simatic as shown below.

SD-card installation on Simatic

Communicating with Simatic:

Through Secure Socket Shell (SSH), one can talk to Simatic. The Simatic comes with the default DHCP address 192.168.200.1 on Ethernet port X1P1LAN. Connect one end of ethernet cable to Linux computer with WiFi enabled and other end of ethernet cable to X1P1LAN port of Simatic and power on Simatic (require 24V DC ). When you turn on the Simatic the three LED’s will start blinking, Once the ‘SD’ led stops blinking, it means that, Simatic is now ready to communicate.

Simatic Initialization

Once the device has initialized follow below instructions

a) On the linux computer with wifi enabled go to Edit connections, Add Ethernet connection type, and give a name to the connection. In IPv4 settings change the method to ‘Shared to other computers’ and save.

Sharing computer WiFi with Simatic through Ethernet

b) Open Terminal and execute below command to make your computer to be on same subnet as Simatic.

c) Login into Simatic using SSH

d) On first login, type ‘yes’ to continue

e) Assign a password

After successful login, it will appear as:

f) Add gateway for internet connectivity

g) Check for internet connectivity using ping

h) Set the time and date of Simatic in below format (Month:Date:hour:minutes:Year)

Setting-up Node-Red on Simatic:

Some configurations need to be setup, to start Node-Red on Simatic

a) Go to opkg directory

b) Add following lines in opkg.conf

c) Add following lines in arch.conf

d) Update configurations using

All the configurations for Node-Red will be updated. To make Node-Red to Autostart when Simatic powers on, type iot2000setup.

A GUI will be appeared, select software-Manage Autostart options-Autostart Node-Red and press ‘Done’.

Next, go to peripherals-Configure External COM Ports-select-X30 COM-RS485 and press ‘YES’.

To assign baudrate for X30 COM port type following command in terminal. This step is important because by default Simatic operates on 9600 baudRate, but Mitsubishi Energy Meter operates on 1200 baudRate, so by changing Simatic BaudRate to 1200, RS485 communication between Simatic and energy meter can be established.

Once all the settings are changed reboot the Simatic.

Installing Modbus and netpie nodes on Simatic:

NOTE: Before installing nodes on Simatic, make sure your Simatic is connected to Internet by ping test.

Install Modbus Node

Install Netpie node

Connecting Modbus Energy Meter to Simatic:

NOTE: Power off the Simatic before connecting it with Energy meter.

The Modbus Energy Meter consist of two wires +ve and -ve. These two wires need to be connected to the 2 and 1 pins of X30 COM port of Simatic as described in below table.

Pins description of X30 COM Port configured as RS485 output

Pin diagram of X30 COM Port:

X30 COM Port pin diagram

Final connections:

RS485 connections between Energy Meter and Simatic

Node-Red Flow:

Open browser and type 192.168.200.1:1880, Node-Red GUI will be displayed.

a) Bring the Modbus Read node to read the data from Energy Meter and Modbus Response node to view the data.

Node-Red Flow

b) The configuration settings of Modbus Read node are

Unit Id — 72

FC — Read Holding Registers

Address — 0x0066 ( for Voltage )

Number of Registers — 1

Poll Rate — 1s

Method — RTU

Mode — Serial Expert

BaudRate — 1200 ( Mitsubishi default baudRate )

Databits — 8, Stopbits — 1, Parity — Even

c) Configure Microgear and Publish node to send data to NETPIE, required parameters are

APPID

KEY

SECRET

ALIAS

TOPIC

NOTE: The guide for configuring above parameters can be found here.

d) In NETPIE, add widget to visualize the data.

Configuring widget to display Energy Meter data

Result:

Visualizing Modbus Energy Meter data on NETPIE

Conclusion:

This article is the Proof-of-Concept (PoC) for using Siemens Simatic IoT2040 as a industrial gateway that handles production data in industries. Integration of Modbus Energy Meter with Simatic was discussed in this article. Similarly other industrial sensors can be integrated with Simatic that opens the path to IIoT.

Karthik Muthineni

Masters in Telecommunications/ICT


Connecting Modbus RTU Smart Energy Meter and Siemens Simatic IoT2040 to NETPIE was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.