Good morning everyone,
I’m facing some issue in establishing an MQTT connection to the open server of mosquitto. I just want to run few tests in order to get ready for future implementations of this protocol.
I’m using a customized board including a stm32u75 microcontroller from st and a Quectel BG95 M3 module for IoT purposes (basically I need to send some data over it): they’re communication via uart port.
I’ve already implemented successfully an FTP protocol which is working fine, but I have problems in dealing with MQTT instead.
Once i give the command AT+QMTOPEN everything works correctly but then, as soon as i try to send the connect command AT+QMTCONN I immediately get the disconnecting message +QMTSTAT 0,1.
I paste down below both the source code and the response I’m getting back from the module. Can anyone help me in solving this? It’s one of my first experience, I’m not really into the subject yet.
Code:
//open
uart_command(“AT+QMTOPEN=0,"“IP_ADDRESS”",“PORT”\r”);
HAL_Delay(1000);
//open info
uart_command("AT+QMTOPEN?\r");
HAL_Delay(1000);
//connect test
uart_command("AT+QMTCONN=?\r");
HAL_Delay(2000);
//connect info
uart_command("AT+QMTCONN?\r");
HAL_Delay(2000);
//connect
uart_command("AT+QMTCONN=0,\""CLIENT_ID"\"\r");
HAL_Delay(7000);
//publish
mqtt_publish("epebbs/test2025","{\"InizioAnnoNuovo\":\"vai\"}");
HAL_Delay(2000);
Response (from Teraterm):
+QMTOPEN: 0,“5.196.78.28”,1883
+QMTOPEN: 0,0
+QMTCONN: (0-5),,,
+QMTCONN: 0,1
+QMTSTAT: 0,1
I tried to add the read and test commands in order to deeper understand but it didn’t help me out.
I have a similar problem, but I have +QMTSTAT: 0,3. The strange thing it’s that I can publish messages with QoS=0…
Was your code similar to the one I wrote?
It also happened to me to get +QMTSTAT 0,3 back from the module.
Do you have any suggestions? My publish command is never reached i suppose.
However, I can’t understand where the problem could arise: the opening part seems to work properly but the connection and publishing stages are driving me crazy.
Yes, my code is similar, also I tried manually and the same problem. I think that is a bug in the BG95 firmware… which firmware do you have? I’m running BG95M3LAR02A03_01.200.01.200.
I’ve been using the command “AT+CGMR\r” in order to get the firmware version of the module and it is the following:
BG95M3LAR02A03.
I don’t know if this is the entire alphanumeric code.
Which is the procedure to update it anyway?
I was wondering about something more. What about the “inizialization” of the module.. I used these two AT commands to set everything up:
“AT+QICSGP=16,1,<APN>","","",0\r”
“AT+QIACT=16\r”
I don’t know how to update the module. I am not part of quectel’s staff, only a guy with a similar problem…
I can solve my problem, when you need to publish a message with QoS=2 you need to specify a messageID (1 to 65535).
I use this config if help you:
AT+QMTCFG=“pdpcid”,0,1
AT+QMTCFG=“timeout”,0,60,10,1
AT+QMTCFG=“version”,0,4
AT+QMTOPEN=0,“server_domain”,1883
AT+QMTOPEN?
AT+QMTCONN=0,“BG95”,“user”,“password”
AT+QMTCONN?
AT+QMTPUBEX=0,1,2,0,“bg95/topic”,“Hello from BG95”
AT+QMTDISC=0
AT+QMTCLOSE=0
Thanks for the suggestion, tomorrow I’ll try to test it and I’ll come back here on the forum for updates!
Hi,
I’ve been offline for a while..
I tried many times to implement MQTT instructions, also following your tips but I didn’t manage to succeed.
I’m obtaining the same results given in the very beninning of this forum talk.
Any other suggestions? I recall that I’m working with STM32u575 microcontroller combined with Quectel BG95 M3 modem.
Regards,
Elia