1
Application Note
__________________________________________________________
Sending Siemens S7 controller data to cloud over
MQTT using Node-Red with Revolution Pi
Version 1.0.0
______________________________________________________________________________
2
© 2021 by UL Electrodevices Pvt Ltd All rights reserved.
UL Electrodevices Pvt Ltd
Nirman Classic,
III Floor, S. No. 36,
Katraj - Kondhwa Road,
Pune - 411046.
Technical Support
Tel.: +91 8956 79 4030
E-Mail: iiot@ulepl.com
revpi@ulepl.com
Every conceivable measure has been taken to ensure the accuracy and
completeness of this documentation. However, as errors can never be
fully excluded, we always appreciate any information or suggestions for
improving the documentation.
We wish to point out that the software and hardware terms, as well as
the trademarks of companies used and/or mentioned in the present
document are generally protected by trademark or patent.
3
Notes about this Documentation
Copyright
This documentation, including all figures and illustrations contained
therein, is subject to copyright protection. Any use of this documentation
that infringes upon the copyright provisions stipulated herein is
prohibited. Reproduction, translation, electronic and phototechnical
filing/archiving (e.g., photocopying), as well as any amendments require
the written consent of UL electrodevices Pvt Ltd. Pune, India. Non-
observance will entail the right of claims for damages
Personnel Qualification
The use of the product described in this document is exclusively geared
to specialists having qualifications in Linux based PLC programming,
electrical specialists or persons instructed by electrical specialists who
are also familiar with the appropriate current standards. Moreover, the
persons cited here must also be familiar with all of the products cited in
this document, along with the operating instructions. They must also be
capable of correctly predicting any hazards which may not arise until the
products are combined. UL Electrodevices Pvt Ltd assumes no liability
resulting from improper action and damage to the products and third-
party products due to non-observance of the information contained in
this document.
Limitation of Liability
This documentation describes the use of various hardware and software
components in specific example applications. The components may
represent products or parts of products from different manufacturers.
The respective operating instructions from the manufacturers apply
exclusively with regard to intended and safe use of the products. The
manufacturers of the respective products are solely responsible for the
contents of these instructions. The sample applications described in this
4
documentation represent concepts, that is, technically feasible
application. Whether these concepts can actually be implemented
depends on various boundary conditions. For example, different versions
of the hardware or software components can require different handling
than that described here. Therefore, the descriptions contained in this
documentation do not form the basis for assertion of a certain product
characteristic. Responsibility for safe use of a specific software or
hardware configuration lies with the party that produces or operates the
configuration. This also applies when one of the concepts described in
this document was used for implementation of the configuration. UL
Electrodevices Pvt Ltd is not liable for any actual implementation of the
concepts.
5
Table of Contents
Table of Contents...................................................................................5
1. Description.........................................................................................6
2. Used material.....................................................................................6
2.1 Hardware............................................................................................6
2.2 Software..............................................................................................6
3. System Architecture......................................................................... 7
3.1 Block Architecture.............................................................................7
3.2 Real Architecture…...........................................................................8
3.3 Real Connection Screenshot………………………………….….…9
4. Programming...................................................................................10
4.1 Node-Red Flows...............................................................................14
6
1. Description
This application note shows how to send any Siemens S7 profinet
controller data to cloud over MQTT using Revolution Pi with Node-Red
2. Used Material
2.1 Hardware
Provider Sr.
No.
Product Details Orde Code Quantity
KUNBUS 1 RevPi Connect 100274 1
LUTZE 2 SMPS 24VDC 722754 1
SIEMENS 3 S7-1200 PLC
CPU 1212C
AC/DC/RLY
6ES7 212-
1BE40-
0XB0
1
HELMHOLZ 4 REX 250 as
switch
700-878-
UMT01
1
2.2 Software/Utilities
➢ TIA Portal v15.1
➢ Node-Red
➢ node-red-contrib-s7comm library
➢ Advance IP Scanner
➢ Web Browser (Google Chrome)
➢ MQTTlens
➢ HIVEMQ cloud MQTT Broker
7
3. System Architecture
3.1 Block Architecture
8
3.2 Real Architecture
9
3.3 Real Connection Screenshot
The Programming PC, RevPi Connect and Siemens S7-1200 PLC
connected in the same network using Helmholz REX 250 in 3 Different
LAN port of it.
10
4. Programming
We are using node-red-contrib-s7comm A Node-RED node to
communicate with Siemens S7 PLCs .
Node-RED node-red-contrib-s7comm node is designed to communicate
with a SIMATIC S7-300/1200/1500 PLC of SIEMENS based on the
RFC1006-communication protocol. The S7comm node can build up a
connection with the SIMATIC-S7. Furthermore, it can Read/Write
Addresses of the PLC with specific S7-Datatype.
To Establish the communication with Siemens S7 PLCs we need IP
address, Port No, Rack and Slot number as shown in below Image. After
setting connection parameter you can read and write the memory
addresses of the PLC with specific to S7-Datatype same is shown in
below image under Signals
11
Once you read data from PLC now you can use MQTT nodes to send
that data to any cloud over MQTT. Only things we need to have is
MQTT broker address. In this application note we are using HIVEMQ
public MQTT broker address and sending data on PLC_1/Motor topic
Now, To check the data on cloud over MQTT we are using MQTTlens
browser based application as MQTT client or subscriber.
➢ Installing MQTTlens in Chrome.
➢ Open the MQTTlens
➢ Give connection Name
➢ MQTT Broker address and Port Number
And click on CREATE CONNECTION Button. As shown in below
image.
12
After creating connection you can subscribe and publish the data on the
topics
We have now subscribed the topic PLC_1/Motor
13
After Subscribing the topic we will get the data which is being published
on the topic (i.e. data from Siemens S7-PLCs). In below Image The
“value”:[false] and “value”:[true] is actual status Q0.0 in Siemens
PLC which is being received by MQTT client Over Internet.
14
Use below Json to use this program readily
[{"id":"9555a608.bdef78","type":"tab","label":"S7 PLC data to
MQTT","disabled":false,"info":""},{"id":"eda5b488.0567e8","typ
e":"s7comm
read","z":"9555a608.bdef78","connection":"3622a876.d4faf8","pa
yload":"{"S7_Type":"Q","S7_DBnum":"0","S7_Datatype"
:"X","S7_Offset":"0","S7_BitOffset":"0","S7_Quantity":
"1","S7_Name":"lamp"}","s7Name":"lamp","topic":"","nam
e":"","signalSetted":false,"none":"true","repeat":"","once":false,
"x":320,"y":20,"wires":[["135afe7f.0180d2"]]},{"id":"a328b28e.5b
605","type":"s7comm
write","z":"9555a608.bdef78","connection":"3622a876.d4faf8","p
ayload":"{"S7_Type":"M","S7_DBnum":"0","S7_Datatype
":"X","S7_Offset":"0","S7_BitOffset":"1","S7_Quantity"
:"1","S7_Name":"button_2_hmi"}","s7Name":"button_2_hmi
","topic":"","name":"","signalSetted":false,"x":351,"y":281,"wir
es":[["3b5f3fb0.141af"]]},{"id":"3b5f3fb0.141af","type":"debug",
"z":"9555a608.bdef78","name":"","active":true,"tosidebar":true,
"console":false,"tostatus":false,"complete":"false","x":561,"y":36
1,"wires":[]},{"id":"135afe7f.0180d2","type":"mqtt
out","z":"9555a608.bdef78","name":"","topic":"PLC
1/Motor","qos":"","retain":"","broker":"7431e2cf.3dd69c","x":5
50,"y":20,"wires":[]},{"id":"1ba4da5d.e9b336","type":"mqtt
in","z":"9555a608.bdef78","name":"","topic":"PLC
1/Motor","qos":"2","datatype":"auto","broker":"7431e2cf.3dd69
c","x":270,"y":100,"wires":[["29b92629.99272a"]]},{"id":"29b926
29.99272a","type":"debug","z":"9555a608.bdef78","name":"","a
ctive":true,"tosidebar":true,"console":false,"complete":"false","x
":590,"y":100,"wires":[]},{"id":"523d22cb.1fadfc","type":"ui_but
ton","z":"9555a608.bdef78","name":"","group":"8aa3fc07.43f25"
,"order":0,"width":0,"height":0,"passthru":false,"label":"Turn
Off
15
DO_1","tooltip":"","color":"","bgcolor":"Red","icon":"","paylo
ad":"{"value":[false]}","payloadType":"json","topic":"","x":17
1,"y":401,"wires":[["a328b28e.5b605","6b5ec5b3.00c9ec"]]},{"id":
"7d89600b.9fd55","type":"ui_button","z":"9555a608.bdef78","na
me":"","group":"8aa3fc07.43f25","order":0,"width":0,"height":0
,"passthru":false,"label":"Turn On
DO_1","tooltip":"","color":"","bgcolor":"Green","icon":"","pay
load":"{"value":[true]}","payloadType":"json","topic":"","x":1
71,"y":361,"wires":[["a328b28e.5b605","6b5ec5b3.00c9ec"]]},{"id
":"6b5ec5b3.00c9ec","type":"ui_led","z":"9555a608.bdef78","ord
er":2,"group":"8aa3fc07.43f25","width":0,"height":0,"label":"S-7
PLC
Q0.0","labelPlacement":"left","labelAlignment":"left","colorFor
Value":[{"color":"#ff0000","value":"{"value":[false]}","valueTy
pe":"json"},{"color":"#008000","value":"{"value":[true]}","val
ueType":"json"}],"allowColorForValueInMessage":false,"shape":
"circle","showGlow":true,"name":"","x":561,"y":261,"wires":[]},
{"id":"6f7076ee.7488f8","type":"inject","z":"9555a608.bdef78","
name":"","topic":"","payload":"","payloadType":"date","repeat
":"15","crontab":"","once":false,"x":90,"y":40,"wires":[["eda5b
488.0567e8"]]},{"id":"3622a876.d4faf8","type":"s7comm","z":"",
"ip":"192.168.10.2","port":"102","rack":"0","slot":"1","payload
":[{"S7_Type":"Q","S7_DBnum":"0","S7_Datatype":"X","S7_O
ffset":"0","S7_BitOffset":"0","S7_Quantity":"1","S7_Name":"la
mp"},{"S7_Type":"M","S7_DBnum":"0","S7_Datatype":"X","S7
_Offset":"0","S7_BitOffset":"1","S7_Quantity":"1","S7_Name":
"button_2_hmi"}]},{"id":"7431e2cf.3dd69c","type":"mqtt-
broker","z":"","name":"","broker":"mqtt.contineonx.com","por
t":"41883","clientid":"","usetls":false,"compatmode":true,"keepa
live":"60","cleansession":true,"birthTopic":"","birthQos":"0","b
irthPayload":"","closeTopic":"","closePayload":"","willTopic":"
","willQos":"0","willPayload":""},{"id":"8aa3fc07.43f25","type":
16
"ui_group","z":"","name":"Control S7
PLC","tab":"4f1db04a.9f253","order":1,"disp":true,"width":"6",
"collapse":false},{"id":"4f1db04a.9f253","type":"ui_tab","z":"","
name":"Siemens 1200 PLC
data","icon":"dashboard","disabled":false,"hidden":false}]

Sending Siemens S7 Controller Data to Cloud Over MQTT Using Node Red With Revolution Pi