How to Access Allen Bradley Data Via MQTT
![How to Access Allen Bradley Data Via MQTT How to Access Allen Bradley Data Via MQTT](https://openautomationsoftware.com/wp-content/uploads/2022/02/how-to-access-allen-bradley-data-via-mqtt.png)
Open Automation Software Tags can be defined to connect directly to Allen Bradley controllers with the built in ABLogix and ABClassic Driver Interfaces which support communications over Ethernet to ControlLogix, CompactLogix, GuardLogix, and Micro800 with the ABLogix driver, and MicroLogix, SLC 500, and PLC-5 with the ABClassic driver. OAS can act as both an MQTT Client and an MQTT Broker allowing you to access your Allen Bradley data via MQTT. This tutorial walks you though downloading and installing OAS, configuring a Allen Bradley driver, configuring tags and reading and writing to them via MQTT.
Step 1. Download and Install the Open Automation Software and Start the OAS Service
If you have not already done so, you will need to download and install the OAS platform. Fully functional trial versions of the software are available for Windows, Windows IoT Core, Linux, Raspberry Pi and Docker on our downloads page.
On Windows run the downloaded Setup.exe file to install one or more of the Open Automation Software features. Select the default Typical installation if you are not sure what features to use or the Custom installation if you want to save disk space on the target system. When prompted agree to the End User License Agreement to continue the installation.
For more detailed instructions and video tutorials, visit the installation guide for your system:
Windows Installation | Linux Installation | Raspberry Pi Installation | Dockers Installation
The OAS Service Control application will appear when the installation finishes on Windows. Use this application to start the 3 Services. Run the Configure OAS application on Windows and select Configure-Tags; if the first time running, the AdminCreate utility will run to create an Administrator login as shown in Step 1 of Getting Started – Security.
Step 2. Configure Your Allen Bradley Data Source
- First, you will need to open the Configure OAS application from the program group Open Automation Software.
- Select Configure >> License from the top menu and verify that Allen Bradley is one of the available Drivers in the lower left of the form. The demo license will have this by default. If you do not see Allen Bradley available, contact support@openautomationsoftware.com to update your license.
- Select Configure >> Drivers from the top menu.
- Select localhost or the remote service you wish to modify with the Select button to the right of the Network Node list.
- The Configure Drivers Screen will appear. Select either AB Classic for MicroLogix, SLC 500, and PLC-5 or AB Logic for ControlLogix, CompactLogix, GuardLogix, and Micro800 from the Driver dropdown box.
- Enter a meaningful Driver Interface Name that you will refer to this physical connection when defining Tags with an Allen Bradley Data Source.
- Define the properties for the desired physical connection.
- Click the Add Driver button above the Driver list in the left pane to add the Driver Interface as an available selection when defining Tags in the next step.
For more detailed instructions on configuring your Allen Bradley data source, click here to see our Getting Started Allen Bradley tutorial.
Step 3. Configure Your Tags
OAS provides multiple ways to add and define tags:
- Manually add and define Tags using the Configure OAS application. …learn more…
- CSV Import and Export …learn more…
- Programatically …learn more…
- One Click Allen Bradley …learn more…
- One Click OPC …learn more…
To add a Tag manually:
- In the OAS Configure Application, select Configure >> Tags from the top menu.
- Select localhost or the remote service you wish to modify with the Select button to the right of the Network Node list.
- Click on the Add Tag button located at the top of the Tag browser on the left portion of the screen.
- A dialog box will appear. Enter a name for your new tag and click ok.
- A configuration screen will appear for your new tag. Select your data source type in in the Data Source dropdown box.
- Specify the correct data type in the Data Type dropdown box.
- Click Apply Changes at the bottom right of the window.
For more detailed instructions on configuring your tags, click here to see our Getting Started Tags tutorial.
Step 4. Access Your Data with the OAS MQTT Broker
The OAS MQTT broker will work without configuration but if you want to use SSL or have security set on your OAS Service you will need to configure it. Please see our Getting Started – MQTT Broker page in the knowledge base if this applies to you.
Accessing Your Tag Data (Subscribing)
This example uses MQTT Explorer, it is a free MQTT client and you can download it here.
![](/wp-content/uploads/2021/07/mqtt_connect.png)
Enter the address of your MQTT Broker in the host name. This will be the IP address or domain name of where you have the OAS Server installed. If it is on your local machine, you can just enter localhost. The name field is just a friendly-name so enter something meaningful to you, perhaps your Broker ID. Enter the Port and Username and Password if you have set one up. Click on the Advanced button.
![](/wp-content/uploads/2021/07/MQTT_topics.png)
Here is where you can subscribe to your topics (OAS tags). In the Topic box, enter TagName.Value, for example, Ramp.Value and click Add. You can also subscribe to any other property of the tag, for example, Ramp.DataSource. Once you are done adding topics, click Back.
![](/wp-content/uploads/2021/07/mqtt_data.png)
Now click on save and then connect. You should now see your data coming in. The payload is in standard JSON format and includes the Value, Timestamp, and Quality.
Writing to Your Data Source (Publishing)
Follow the same setup for the MQTT Explorer client that you did for subscribing to connect to the OAS MQTT Broker but you can skip the Advanced button part. Click Connect.
![](/wp-content/uploads/2021/07/mqtt_publish.png)
In the lower right portion of the client window, enter in your Topic, this will be the tag you are trying to write to, for example, MyValueTag.Value. Switch the selector to raw and enter a value in the text box below the Publish button. Click Publish. If you would like to write your value in json format, you can. Using the JSON Calculations in OAS you can parse the JSON message for extended functionality.
The video below, goes into detail about how to do that as well as an overview of the OAS Broker.