https://www.AutomationDirect.com/brx?utm_source=z0Hs83AXUrM&utm_medium=VideoTeamDescription
(VID-DM-0052)
BRX PLCs allow for creating JSON packets and also MQTT communications. You can then leverage these tools to integrate your control system with Node-RED.
This integration will allow connecting with various tools like SQL databases, creating flow-based workflows to handle text operations, and much more.
Online Support Page: https://community.automationdirect.com/s/?utm_source=z0Hs83AXUrM&utm_medium=VideoTeamDescription
**Please check our website for our most up-to-date product pricing and availability.
Node-RED is an open-source platform and is a great way to augment your PLC controls and integrate them quickly with multiple platforms allowing you to collect data and then pass it on to an SQL database, create dashboards for quick access on a web browser and much more. In this video, we will show connecting a BRX PLC to Node-RED and pass some data information to the Node-RED platform using MQTT communication. Then receive data back into the BRX PLC from Node-RED. How quick it was to set up surprised me. In a separate video, we will create a dashboard to show this data for quick access. For this example, I will be using Node-RED installed on a Raspberry Pi 4. In the description below there is a link to Nodered.org on how to set this up quickly. For this Node-RED setup, there are 6 parts to transferring data back and forth to Node-RED. Let's start in the BRX setup. I have already created this program, but I will go over the parts that you will need to set up. To set up, the MQTT Client in BRX enter your system configuration, select Device Configuration, and select to add a new device. Here is the client I have already set up. Give your device a name. Enter in the IP address of your Node-RED setup or if you are using a server name you can put that here. There are a few things for a more advanced setup, like MQTTs, enabling authentication, and Last Will, but for this example, I will forgo these. Now that you have the client set up let’s look at the data we will be sending to Node-RED Here I have a JSON Build instruction. In this JSON message, it packs these 5 data points together and then loads it to a long string address to be sent to Node-RED On names like this, make sure to not use spaces. It will confuse Node-RED when you unpack it. And parallel to this JSON build I have entered an MQTT Publish Instruction that will send this long string that contains our JSON message to Node-RED. Here enter the MQTT client device we created before. Set the rate at which you want to send this data to Node-RED. Here enter in the MQTT Topic name you will be sending this data to Node-RED. This will need to match exactly what you set up in Node-RED. To make this a little bit easier later on I just copy and paste. Then the Payload will be the JSON message we create above. I don’t want to retain this data in the broker and have the data only published if the data has changed. Now, since we are using seconds, of course, this is going to change every second. I also added an MQTT Subscribe to read data back from Node-RED. Notice here that my Topic is different from the Publish. Once you have this set up, go ahead and send this to your PLC. Access your Node-RED setup, open up a web browser and enter in the IP address of your Node-RED setup, and then colon 1880. Now with Node-RED, you can add on a lot of different things. If you will notice here on the left-hand side, here are all the Nodes that come pre-installed on Node-RED. We can add onto this so for example, I am going to add on the MQTT Broker to Node-RED so it will be acting both as my Broker and the Node-RED setup. To do this, I select Here, select Manage Pallete, select Install and then type in AEDES. This will be your MQTT Broker. Now that you have that installed, if you will look on the left-hand side in all of your nodes under the Network section, you will see the AEDES Broker. Drag that into your Workflow window. Now double-click on this node. This is the same port we had set up in our BRX MQTT Client setup. These do have to match. Now we enable the WebSocket by entering in a port number here. I will enter in 8080. Select Done. That is how easy it is to create your broker in Node-RED. Now let’s bring our MQTT message from BRX into our Node-RED. We'll do this by adding an MQTT in Node and dragging into our workspace. Double-click it. I'm going to go back to my BRX, copy the Topic message for my Publish and then paste that into my Node-RED setup. Make sure to remove the quotation marks here. To display the JSON message, that will be sent into this MQTT in, I will add a Debug node and drag a line between the two nodes. I will then select to deploy the workflow and to see the data I will need to enable the Debug window. We can do that by selecting here, View, and Debug Messages. Now we see the JSON packet updating every second. This is just how easy it was to get the data from my BRX PLC to my Node-RED setup. Now let’s send some data back to our BRX. Add an MQTT Out node. Double-click it. Copy the Topic from our MQTT Subscribe in BRX and paste it here. Remember to remove the quotation marks. Select your quality of service and I will select it to retain the data and then select Done. Now I'm going to grab an Inject node and add it to my workflow. By default, this is selected as Timestamp. I will set this to inject the Timestamp every second. I will leave that as it is and connect it to my MQTT out. And now just select to deploy. So, if we go back into our BRX and look at SL1 in our dataview, we see this updating every second. So this is a very basic setup but allows you to see how you pass information back and forth. There are tons of Node-RED resources online that can show you more advanced features in getting deeper into this. In our next video, we will show you how to create a dashboard to display some data and interact with Node-RED. If you would like to see more information on the BRX PLC select here and select here to subscribe to our YouTube channel for new products and solutions.
Voted #1 mid-sized employer in Atlanta
Check out our
job openings