paint-brush
Siemens Simatic Iot2040 as Mqtt Broker [NETPIE]by@karthik-muthineni
1,301 reads
1,301 reads

Siemens Simatic Iot2040 as Mqtt Broker [NETPIE]

by Karthik MuthineniSeptember 7th, 2018
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

<strong>System Model:</strong>

Coin Mentioned

Mention Thumbnail
featured image - Siemens Simatic Iot2040 as Mqtt Broker [NETPIE]
Karthik Muthineni HackerNoon profile picture

This article explains how to install Mqtt broker on Siemens Simatic IoT2040. In this article Mosca Mqtt broker is used.

System Model:

The Modbus Energy Meter is used as client that publishes Voltage, Current, and Frequency values to Mosca broker installed on Siemens Simatic IoT2040. The broker on Simatic will then publish the data to NETPIE APP ID that is subscribed to the same topic as publisher.

Getting Started:

The Simatic IoT2040 works based on Yocto Linux, the image need to be installed on SD -card and should be inserted into Simatic. The detail instructions of installing Yocto Linux and connecting Modbus Energy Meter to Simatic can be found here.

Siemens Simatic IoT2040

Modbus Energy Meter

Installing Mosca on Siemens Simatic IoT2040:

Install Mosca on Simatic using npm as described below

npm install mosca bunyan -g

To test Mosca, run the below command

mosca -v | bunyan

If you get the output similar to below picture, “Congrates”, you have successfully installed Mosca on Simatic IoT2040.

Running Mosca broker on Simatic IoT2040

Installing nodes on Node-Red:

Install netpie node

npm install -g node-red-contrib-netpie

Install Mosca Mqtt broker node

npm install -g node-red-contrib-mqtt-broker

Install modbus node

npm install -g node-red-contrib-modbus

For transfering data from broker (installed on Simatic) to NETPIE, first the Simatic should be authenticated by NETPIE, for this purpose microgear node (netpie) is used. Once the device is authenticated, connection between Simatic and NETPIE establishes and data gets transmitted using Mosca mqtt broker. Modbus node is used to read data from Modbus Energy Meter.

Node-Red Flow:

Node-Red Flow

Mosca Broker Node:

Mosca Mqtt node

Mqtt out node (publisher):

Pub node

Mqtt in node (subscriber):

Sub node

Microgear node:

MicroGear node

Modbus node:

Modbus node

Modbus client settings

Function node:

Function node

The data read from Modbus Energy Meter will be enclosed in brackets (Ex: Voltage value: [23200]). To remove brackets and extra characters on data we use function node.

NETPIE:

Create Application Id on NETPIE that is subscribed to same topic as publisher node.

Creating APP ID on NETPIE

Creating Data Source:

Datasource

Creating Widget:

Widget to display data

Result:

Energy Meter data published on NETPIE through Mosca broker