Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
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 IoT2040Modbus 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:
Mosca Broker Node:
Mqtt out node (publisher):
Mqtt in node (subscriber):
Microgear node:
Modbus node:
Modbus nodeModbus client settings
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 Data Source:
Creating Widget:
Result:
Energy Meter data published on NETPIE through Mosca broker
Siemens Simatic Iot2040 as Mqtt Broker [NETPIE] was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.