Tutorials: Connect to an MQTT Broker

Send data using MQTT with TLS Security to a designated MQTT Broker

DESIGNED IN AUSTRALIA. BUILT IN USA. 

 
 
 
 
 

Send JSON data using MQTT with TLS Security to a MQTT Broker

In this tutorial, we will explain the simple steps to modify our standard Ubidots MQTT script to send your Modbus or CAN bus device data (in JSON) to a MQTT broker with TLS security. We will be using the Mosquitto test server in this article, from there you can implement the same with your own MQTT broker.

SSH over to your FATBOX and modify the following in the scripts/ubidots/ubidots_client.py file, 

BROKER_ENDPOINT = "test.mosquitto.org" #mosquitto test server TLS_PORT = 8883 # Secure port
MQTT_USERNAME = ""
MQTT_PASSWORD = ""

TOPIC = "your_topic" #we use “fatbox” in our example
DEVICE_LABEL = ""
TLS_CERT_PATH = "/scripts/ubidots/mosquitto.org.crt" #you will need to copy and paste *

You can download the certificate from https://test.mosquitto.org/, please try to leave a donation to show appreciation of the nice job done by team Mosquitto!

As we are using the existing framework of our Ubidots client, you will need to ‘Enabled’ Ubidots in the ‘IoT Client’ tab of your gateway.

You can leave both Device Token and Name empty as it’s not used in this mode.

After saving the modifications to the client file and also copied over the certificate file, you are ready to go after a reboot.

If your Modbus or CAN bus settings are already working, you should be able to subscribe to your MQTT publisher topic and receive the JSON device data like in the following screen-shots.

Ask Us Your Questions

Get a prompt response to your query.

 

BUY A GATEWAY ROUTER

E-commerce Shop

HARDWARE-AS-A-SERVICE

Leasing Plans

PRODUCT CUSTOMISATIONS

Custom the G3

CONTACT US

Sales Enquiries

Technical Enquiries

Amplified Engineering Pty Ltd  

Suite 4 Enterprise Unit 3,

9 De Laeter Way,

Bentley WA 6102, Australia

ABN 44127163035