Generic MQTT Help


I have been working on this for a while and now I am stumped. I tried to figure it out on my own but now I am in need of assistance. I am trying to connect up my PicoLTE to a HiveMQ Cloud MQTT broker but get error messages.

Here is the code:

import time
from pico_lte.core import PicoLTE
from pico_lte.common import debug
from pico_lte.utils.status import Status


picoLTE = PicoLTE()“Opening Connection”)
picoLTE.mqtt.open_connection()“Connecting to broker”)
picoLTE.mqtt.subscribe_topics()“Publishing Message to topics…”)

#first_time = time.time()
while True:
result = picoLTE.mqtt.read_messages()

Here is the config:

“port”: 8883,
“client_id”: “USERNAME”,
“sub_topics”: [
[“gate/opener”, 0],

Here is the shell output:

DEBUG: Power status: 0
DEBUG: Power status: 0
DEBUG: Response: [‘\r\nOK\r\n’]
DEBUG: Processed: [‘OK’]
DEBUG: COM: {‘response’: [‘OK’], ‘status’: 0}
DEBUG: Response: [‘\r\nOK\r\n’]
DEBUG: Processed: [‘OK’]
DEBUG: Response: [‘\r\n+CREG: 0,5\r\n\r\nOK\r\n’]
DEBUG: Processed: [‘+CREG: 0,5’, ‘OK’]
DEBUG: Desired: +CREG: 0,5
DEBUG: check_network_registration : {‘response’: [‘+CREG: 0,5’, ‘OK’], ‘status’: 0}
DEBUG: success : {‘response’: [‘+CREG: 0,5’, ‘OK’], ‘status’: 0}
DEBUG: Response: [‘\r\n+CGACT: 1,1\r\n+CGACT: 2,0\r\n\r\nOK\r\n’]
DEBUG: Processed: [‘+CGACT: 1,1’, ‘+CGACT: 2,0’, ‘OK’]
DEBUG: Desired: +CGACT: 1,1
DEBUG: check_pdp_context_status : {‘response’: [‘+CGACT: 1,1’, ‘+CGACT: 2,0’, ‘OK’], ‘status’: 0}
DEBUG: success : {‘response’: [‘+CGACT: 1,1’, ‘+CGACT: 2,0’, ‘OK’], ‘status’: 0}
INFO: Opening Connection
DEBUG: Response: [‘\r\nOK\r\n’]
DEBUG: Processed: [‘OK’]
DEBUG: Processed: [‘+QMTOPEN: 0,0’]
INFO: Connecting to broker
DEBUG: Response: [‘\r\nOK\r\n’]
DEBUG: Processed: [‘OK’]
DEBUG: Processed: [‘+QMTSTAT: 0,1’]
INFO: Subscribing
DEBUG: Response: [‘\r\nERROR\r\n’]
DEBUG: Processed: [‘ERROR’]
INFO: Publishing Message to topics…
DEBUG: Response: [‘\r\nOK\r\n’]
DEBUG: Processed: [‘OK’]

DEBUG: Response: [‘\r\nOK\r\n’]
DEBUG: Processed: [‘OK’]

No matter what I send to gate/ or gate/opener, no messages are recieved.

I know the code is super primitive, I kept messing with it, stripping it down, adding more in etc…


Thank you for bringing this to our attention. We’re on it and will get back to you with a solution as soon as possible.

Thank you, to add to the above. I am able to connect to Hive MQ using a web client and the desktop MQTT explorer with the same credentials/topics/address/client id that I am trying to use in Pico.

Any updates? I have tried using the dev SDK with MQTTHG, I still get the same results. The issue is entirely when trying to subscribe.



Hi @ollie,

Sorry for the late response. To set up a connection with HiveMQ Cloud, you need to provide proper certificates. So, I guess you are encountering this error because of lacking certificates.

The SDK doesn’t directly support HiveMQ Cloud, and the provided MQTT examples are not written for SSL connection.

  • You can use a public broker and establish a connection with the code provided above.
  • There are AWS, Azure, and Thingspeak applications in the SDK, which can be preferred for a more secure and stable MQTT solution.
  • Additionally, you can establish an MQTT connection for HiveMQ by providing SSL certificates. You may refer to this MQTT document for SSL, and this one for HiveMQ certification. Use the methods in file and auth modules of the SDK, and upload the certificates for the connection.

Thanks for the response. When I switch the MQTT broker to be the one from the tutorials i get the same result. AWS and Azure work flawlessly.

I beleive you need to set your SNI:

command_sni = f’AT+QSSLCFG=“SNI”,2,1’
command_sni_results = self.atcom.send_at_comm(command_sni)

the print statement is not necessary i just added it in to confirm that the command was a success. Cloudflare has a nice article on sni – What is SNI? How TLS server name indication works. I had the same issue when i went from unsecure self hosted using IP to ssl in the cloud using domian name. Hope this helps!

1 Like