How to Read Data from an MQTT Broker Using atvise connect, Send it to Builder, and Parse the Information

Created by Jose Fabian Solano, Modified on Sat, 13 Jul at 12:20 AM by Jose Fabian Solano


First, we need to create a communication channel towards the MQTT broker, specifically with Mosquitto, which is publishing a JSON in the following format:

```json
{
"timestamp": "2024-02-12T08:30:00",
"sensor": "T1",
"value": 35.8582
"unit": "Celsius"
}
```

Our main goal is to extract the value of T1, which in this case is 35.8582

Once we have our channel configured in atvise connect, we'll proceed to add a variable to read the JSON from the MQTT broker.

It's important to check 'Use String Type for Data' when creating our channel. Once we have our channel configured in atvise connect, we'll proceed to add a variable to read the JSON from the MQTT broker.


Afterwards, we need to create a variable in atvise connect using the following syntax. This will fetch the JSON in string format, where it's essential to specify the topic we want to access.



After completing that, we simply connect our Connect with the Builder by creating an OPC UA channel to send the information. It's necessary to create the variable as an object so we can use it in the script code.

Now, we need to go to the library section where we'll find an option called "Script Menu." Here, we'll create a new script that will parse the JSON we are receiving, and we'll add the following code:




We save the configuration of the script we created and test to see if atvise correctly extracts and parses the JSON into a variable named resultado.


Created by JF

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article