This project demonstrates the integration of the Sixfab Pico LTE board with HiveMQ Cloud to publish and subscribe to MQTT topics, enabling efficient communication between IoT devices and applications.
Hardware Requirements | Software Requirements |
---|---|
|
|
If you have completed all the requirements, you are ready to use HiveMQ Cloud with the Pico LTE device.
Let's get started!
- Download the Pico LTE SDK repository to your local machine. If you have already downloaded it, skip this step.
- Open script "examples → hivemq → mqtt_publish.py / mqtt_subscribe.py" from the repository via Thonny IDE.
- If you haven't, create a
config.json
file in the root directory of Pico LTE device.
- Visit the HiveMQ Cloud sign-up page.
- Choose your preferred sign-up method: GitHub, Google, LinkedIn, or email.
- Complete the sign-up process to create your HiveMQ Cloud account.
- Once logged in, you’ll be prompted to choose a plan.
- For small projects or learning purposes, the Serverless plan is a great starting point with up to 100 devices and 10 GB of data traffic free.
- Select the plan that fits your project needs and proceed with the "Get Started" option.
- Click on the
Create
button. - Your cluster will be provisioned and ready to use in a few moments.
- Click on
Manage Cluster
to view its details.
- Here you will find your cluster URL and port, which is crucial for connecting your IoT devices.
- For security, you have to set up credentials that IoT devices will use to connect to your cluster.
- Navigate to the 'Access Management' section.
- Create new credentials, specifying a username, password, and permissions.
- Follow the steps to generate and configure your certificates.
- Before proceeding to the certificate creation step, OpenSSL must be installed on your computer.
- You must run the commands in the terminal.
-
First we need to create the private key by running the command.
openssl genrsa -out user_key.pem 2048
-
After generating the private key, create a CSR which will be used to request an SSL certificate.
openssl req -new -key user_key.pem -out request.csr
-
You will need a client certificate to authenticate with the HiveMQ broker.
openssl x509 -req -days 365 -in request.csr -signkey user_key.pem -out client.pem
- Download the CA Certificate from HiveMQ's frequently asked questions website.
- Create a folder named 'cert' and upload the
cacert.pem
,user_key.pem
, andclient.pem
certificates to the Raspberry Pi.
-
Create the
config.json
file as shown below inside the Raspberry Pi and fill it with your parameters.{ "hivemq": { "host":"[CLUSTER_URL]", "port": [PORT_NUMBER], "username": "[MQTT_USERNAME]", "password": "[MQTT_PASSWORD]" } }
-
Save this configuration and then run the example script
mqtt_publish.py
.
-
Create the
config.json
file as shown below inside the Raspberry Pi and fill it with your parameters.{ "hivemq": { "host":"[CLUSTER_URL]", "port": [PORT_NUMBER], "username": "[MQTT_USERNAME]", "password": "[MQTT_PASSWORD]", "sub_topics": [ ["MQTT_TOPIC", QOS], ["MQTT_TOPIC", QOS], ... ] } }
-
Save this configuration and then run the example script
mqtt_subscribe.py
.
config.json
: Configuration file containing HiveMQ Cloud connection parameters.mqtt_publish.py
: Script to publish messages to MQTT topics.mqtt_subscribe.py
: Script to subscribe to MQTT topics and listen for incoming messages.
This setup enables a robust platform for developing and testing IoT applications using MQTT protocol with HiveMQ Cloud and Sixfab Pico LTE. It is suitable for anyone looking to implement IoT solutions efficiently.