How to configure S7-1200/S7-1500 as an MQTT Client with TIA Portal

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey hello and welcome to the automation station it's me how again and this time I'd like to tell you a bit about and qtt and also show you how to set up your s7 1200 or s7 1500 as an mqtt client empty TT stands for message queue telemetry transport and is a protocol widely used in home automation but it's making its way to the industrial automation as well the reason behind its popularity is its optimization or unreliable high latency networks and it's extremely small footprint thanks to its client broker architecture mqtt is also easily scalable while retaining the aforementioned and advantages this is because in the center of the protocol say it's an MQTT broker and it's the brokers job to handle all the data exchanged between different clients and message filtering as well which means that at any time any single client is just talking to the broker at South and from the clients perspective the total number of connections however big it was is completely irrelevant MQTT out of the box also supports some really handy features like different levels of quality of service on a feature called last will and testament this one for example allows the broker to hold the special message for a client it's called decline the client a so client a defines a special message the broker holds this message in case called a disconnects ungracefully the broker would then send the message in client base name so that any other clients b c d e f g yeah you can't just well immediately get notified that something happened to the client a other features are things like authentication authorization but also persistent sessions for example so it a lot of beauties in this MPD too bad for you so I guess it's time to set it up on an s7 1500 CPU now okay so I have my ti up and running already my s7 1500 is on my desk and powered up connected the same subnet to H on I did with my laptop let's create a fresh new project project let's go ahead and PTT demo hope there isn't one already but this shouldn't be ok so there we go fresh new project we go devices of networks as you can see currently it is absolutely nothing here let's find my 1511 have - - - - where is it there you go 15:11 the latest and greatest let's try bit block now okay let's align to the left that we go 1511 my 1511 is on 191 6/8 0.111 so I'm just going to change this small setting here now I'll have the CPE what next how can I actually make my CPU behave at like a MQTT broker well let's go on the internet and on to their support site if you are on the support site if you just look for the LED TT in library you should find yourself an m QT library for at the s7 CPE and get declined there you go the documentation there is a library for and t 951 ti 16 and there's also project 416 there seems to also be an archive for some old blogs can run with s 7 300 I just interested in the library itself or the latest version CIA there we go it's fine downloading this okay I'm going to log in here oh there we go we are now logged in let's go to a folder let's extract our files let's put them on the desktop so I can easily find them but till I know of course if you're interesting the detail there is a PDF here come on you can open the PDF for add repairing the wrist in about these blocks but I'm just gonna show you how to use them so you have over 1500 which is downtown library I use just like growing the part but let's delete this here and let's reload it again so if you have a fresh thing Eastern Studies this one I break I just go here open global rivalry I put mine on the desktop out encourage you to put it in a better place to go I'll empty it declined yeah let's open the library the library is open now and we have some types no master copies just type in types we have what some UD T's and the function block pretty easy okay so these are blocks because it's a 1511 F so tales of parent I had some safety related blocks here we're not going to be touching say today what I'm gonna do I'm just gonna grab this block from the libraries and throw directly into my project yeah create a single instance for it they go and key DT block nice thing about Shiva's blood as recently I would say that the ones we seen last couple of years on no longer know how protected so if you double click it you can find all the information and see how the block actually works it's quite nice it's quite nice a nice addition if you want to maybe add some stuff up your own ok but though so we have our block we are also going to take a it's actually copied Dutt is for us which is nice which is fine okay so we have all our duties we have to block now we need to toggle a block up for this I'm going to create myself and the globally I'm going to call this guy ng T this would act as an interface for me to exchange data with morning L MQTT client ok let's play screen here and what are we going to need well let's just see what there is to tea house the first thing we'll go publish data they get published data I'm gonna call this guy well accomplished data at the next movie subscribe to topic then I will have my TCP connection params MPPT params the sub message I'm gonna have the boolean for the output so TCP established o MP TT established well as well now if you know how the blocks work easily if something goes wrong here and there is an error we'll get the one-shot so it would be quite handy to maybe put an extra space to all the information about this so we'll actually put something called error here which would be a book and we put status on ID which I hope is an int we know should have everything let's just add the enable so it's a boolean yeah now let's target that so we have enable yeah these donuts are incorrect l MQTT on this call and subscribe data LM keep what is my key but LM tea tea tea mmm for the TCP connection parameters will be using this one LM key TT four days we'll be using the parameter and for the a.m. PDT easing up time subscribe data's time subscription data if you're not sure which ones to use were again just going through the documentation but you know just look at the nice you can get quite a good feel about it okay so let's go back to Target up so we have published data we have subscribed topic we have the TCP connection parameters we have the mqtt parameters we have our subscription message TCP established and he TT established and now you know you remember when I said there might be some problems some arrows for example and to be really good to capture them so for this I'm just going to add my cell I need Network and decide if I'm glad lazy a hidden be doing this but yeah yeah I'm just just scalded now there you go there's my little kitty T client and I'm gonna say that if I have an error on this guy yeah it'll be a single shot at this point if there is an error on this guy then I'm gonna actually cut to this error here and write one here but also override the status of this where the status on day coming from here and I'm going to zero these whenever M T DT enabled goes low okay so MQTT naval and go slow down I'm gonna zero my MQTT error and I'm gonna zero my mkdd status on D so that's a bit of well calling this error handling is probably an overstatement but as she did the job for us in case something goes wrong of course okay so we have these and I'm gonna just do software build or because it's TCP and would probably be unhappy about me downloading that's just straight away okay let's try to download let's see if I can find my CPU in the network yeah there is something we can connect to it nice that's loaded yeah so as I said I had some something running on this previously and this one I had to do these software build or if you have a fresh new CPU for example and this would probably not pop up but then if it does this that's all good or not okay compile softer rebuild oh I guess I didn't click it not sure what happened let's just download yeah it's fine oh yeah no more messages regarding sighting I could have disabled sites because I'm not using it but hey yeah so let's start the module app and let's go online yeah I'm going here let's go on the line here as well so you can see our block currently no connection established and we wouldn't be able to establish the connections I didn't put any connection parameters and so let's see what there actually is so you can either let me put it on the big stream so as you can see we can use qualifying domain name this if you want to use your domain for example and but I won't be using this then we have further identifiers so this is the hardware ID of the Prophet interface of the CPU there are two places where you can find us I'll shoot there is more two main places so we can go here properties of the internet port itself then the go system constants and there you go 64 another place you can just go to a word on my tags POC tags short tags system constants and find the same thing here on the left hand side but if you if you you know a lot of CPUs a lot of hard work it'll be harder to find here so device going directly to the CPU and finding the caller identified like that so it's 64 for us anyway close these mm-hmm so I'm gonna punch this it starts all ye then the next thing is gonna be our connection ID this just has to be a unique quarantine IP address my broker sits on one leg two one six eight 0.42 my guess we haven't really talked about the brokers so the CPU can be a client it can do the publishing and they're subscribing but then you still need a broker and the broker can be sitting somewhere on site on an IPC something like you know IPC 1 270 tiny IPC for example it could be sitting outside it could be sitting on an edge device as a little container for example but the test part is up to you I'm using a mosquito broker at one of the outside probably the most popular MQTT broker and available for free to download and open source software and they said you can run it either on that dedicated PC or maybe as as I was a container or as an X device on an edge to my sorry regardless this is running or C should be running I guess we can check think 191 6 8.0 just hold it - yeah so at least the machine that's falling this is running it should be running on 183 o changed to wrong one mmm what do you have there and qtt per arms so here you have connections lungs you can say is it gonna be a clean session so this is d if it's not a clean session then it's a persistent session I'm gonna have this C yes so it's going to be a clean session not a persisting one no data buffering no will and testament I so don't need to set these bus I will be using username and password yeah I'm changing Betty and it's there she just started changing start values and then I can copy everything as actual values makes more sense client identifier so by default semantics see mathematics sorry put whatever you like here the important thing is a broker can hello mmm well these needs to need to be unique within a broker so you can't have two three five more than one client with the same name connecting to one broker there we have the world topic we message not interested what's her password is the question so my username is gonna be somatic that's what we have configured in my broker already and the password will be I lost cinematic then is it it should be fine okay so let's just copy these values as as actual values yeah yeah yeah yeah that's all good so as you can see it copied them for me as stars once I don't need to download or do anything like let's go back let's look at our blog and let's see if we can get a connection then I'm gonna flip the enable as you can see TCP establishes true and then PDT establishes true though we have a connection nice so now I'd like to maybe send some some data I'll receive some data okay I can do the button how can we prove it so me for testing purposes I'm just using another open source and qtt client which is called mqtt explorer Thank You VT Explorer just allows you to act as a the client allows you to connect to a broker and by default subscribe see every single topic using a wild card so again the connection a new connection is gone I'm gonna call it smart tech what is our host one-line t16 8.02 42 1883 I'm gonna connect the different user line sir this is the one yeah so I'm not connected and yeah I have some topics but none of these are relevant this one actually is from another demo that I did and as you can see I used a retains line so it retains like is something that we haven't talked about but a retain flag sent on a message on a topic means that last message sent on this topic will always be retained by the by the broker so even if me as a client ID for example subscribed now to this topic Siemens / PLC just now I got the last message that a client sent on this topic if the retained flag wasn't here a little bit absolutely nothing after the point when the client sends a message on this topic again so that's something that important to keep in mind and think whether you need to retain flag or not it's especially handy when your sensors are not sending data very often let's say you're sensing sends data every hour or maybe every day then you might need to fly to know what was the lead last status of your sensor the last date Arabia and said okay so we have a connection now I'm going to send some data and so where can we send data well we don't need this and if there's let's expand publish data so there you go this published topic published message and I believe so I'm going to publish some data on the topic automation station and the message don't agree to be high automation oh nice then the Equality of service zero no retain flag and let's just fire it and see what happens yeah the message should now be sent let's go back there you go there's a new message on topic automation station will devalue high optimation so the words okay let's um get overexcited let's publish the data so sorry let's subscribe now so there you go subscribe to topic so I need to define a topic to which I'd like to subscribe so I'm going to say I'm going to be subscribing to oh I don't like it let's say automation station as well but the reason why I don't like it is because I would normally be getting all the messages that I'm sending myself but just for the purpose of the demo let's subscribe to automation station yeah let's subscribe to it we are now subscribed any messages that we get she'd be coming hey let's try to send a message on the topic so my MD client MQTT Explorer I can now send a message to automation station topic at will to body hello let's hope it goes through there you go we have the message we have touchdown so yeah we can subscribe we can publish what else do mighty possibly what so yeah there's a certain events for you at CERN 1200 works exactly the same so should be an easy job for you to get it going take her and feed by [Music]
Info
Channel: AutomationStation
Views: 16,855
Rating: undefined out of 5
Keywords:
Id: pB0isTaZ72I
Channel Id: undefined
Length: 21min 20sec (1280 seconds)
Published: Mon Jun 08 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.