Bg95 m3 mqtt connection issues

Hi guys,
I’m here again cause I cannot solve my problems regarding MQTT connection using Quectel modem bg95 m3.
Making it simple, my hardware setup is made of an st microcontroller (STM32U575) plus a BG95 M3 modem from quectel, communicating serially via UART port.

I’m attaching my main problem.
I want to test MQTT protocol for a project by publishing/subscribing some data over Mosquitto public MQTT server but I’m encountering a massive issue.
Up to the opening phase everything seems to be working fine but as soon as I try to run the QMTCONN command, the connection falls apart and the +QMTSTAT 0,1 message pops up.

To give you as much information as possible I’m pasting the code snippet and module response I get by taking a look at teraterm terminal.

CODE:

		uint16_t rep;

		if(checkService()!=0)
			return 1;

		REFRESH_IWDG;	// refresh watchdog
		HAL_Delay(200);

		REFRESH_IWDG;	// refresh watchdog
		rep=LTE_FTP_SendCommand(LTE_QICSGP,NO_REQUEST, LTE_MAX_RESPONSE_TIME_QICSGP,RETRY_1);
		myUartPrintf( "LTE_QICSGP %d\r\n",rep);
	        if (rep==ERROR_LTE)
			return 2;
		HAL_Delay(200);
		rep=LTE_FTP_SendCommand(LTE_QIACT,NO_REQUEST, LTE_MAX_RESPONSE_TIME_QIACT,RETRY_1);	// risponde solo con 0 o 4
		myUartPrintf( "LTE_QIACT %d\r\n",rep);
	        if (rep==ERROR_LTE)
			return 3;
		HAL_Delay(200);


		//open
		uart_command("AT+QMTOPEN=0,\""IP_ADDRESS"\","PORT"\r");
		HAL_Delay(1000);

		//connect
		uart_command("AT+QMTCONN=0,\""CLIENT_ID"\"\r");
		HAL_Delay(1500);

		//publish
		mqtt_publish("epebbs/test2025","{\"InizioAnnoNuovo\":\"vai\"}");
		HAL_Delay(2000);

Where :
LTE_QICSGP “AT+QICSGP=16,1,"inetd.it.vodafone.iot","","",0\r”
IP_ADDRESS “5.196.78.28”
CLIENT_ID “GUYS_EPEBBS”
PORT “1883”

RESPONSE:
+CREG: 0,5
Creg: 0,5 0
Creg: 5
+CEREG: 0,4
Cereg: 0,4 0
Cereg: 4
LTE_QICSGP 0
LTE_QIACT 0
+QMTOPEN: 0,0
+QMTSTAT: 0,1

Can someone help me out?

Thank you in advance!
Kindly
Elia

Cereg:4 means Unknow and check if your network connection is good please.

Hi, I noticed the CEREG return message too.
On the contrary the CREG return code is satisfying and should be enough, shouldn’t it?

However the connection seems to be established correctly: I used the command AT+CSQ to retrieve the signal strength and I got 14 (which is “good” as for the table provided in quectel application note).

I’ll be online.
Let me know if there’s something more I could check.

Elia

Sorry, the connection strength corresponding to number 14 is “OK”, not “good”.
Furthermore, this morning I tried to test once again the same script and:
+CEREG: 0,5
Cereg: 0,5 0
Cereg: 5

The remaining lines are unchanged

How long has it been since executing QMTOPEN to execute the QMTCONN, because if there is no operation for too long, it will automatically disconnect.

Right, I’ve read about it.
I’m giving a delay:
HAL_Delay(1500);

In this case it’s 1.5 seconds but I’ve been trying to both reduce and increase that value without any luck so far.

It sounds strange to me that the network is correctly opened but never able to connect. I mean, I can’t understand where I am missing something (because I think I’m definitely missing something).

I’m not an IoT pro

Could you please show me your entire AT log from CFUN0/1 to the issue appear?

I’m attaching the log from the turning on of the module to the QMSTAT error.
I also included the signal strength parameter.
I left CFUN as 1 meaning that full functionalities are on.

ATE0
ATE0
OK
ATV0

+CREG: 0,5
Creg: 0,5 0
Creg: 5
+CEREG: 0,5
Cereg: 0,5 0
Cereg: 5

LTE_QICSGP 0
LTE_QIACT 0

+CSQ: 15,99
+CFUN: (0,1,4),(0,1)
+CFUN: 1
+QMTOPEN: 0,0
+CFUN: 1
+QMTSTAT: 0,1
+CFUN: 1

Perhaps I’m not following the correct procedure to establish the mqtt connection.
As a matter of fact, I successfully implemented the FTP protocol and that works fine for my application.

What are your suggestions about AT commands for mqtt connection? Is my procedure acceptable?

I don’t know if this response is satisfying, let me know if more insigths are needed.

Elia

I will send you the BG95 MQTT application note and you can refer to this document.

Thank you mikey,
I already consulted the application note many times but still I haven’t figure it out.
I’m writing here because I think I’m done with the all possible documentation concerning bg95 mqtt commands :frowning:

Elia

I will send you the latest FW version via email.

Update to the latest version and see if that fixes the issue

Hi mickey, sorry for the response delay (the timeout interval locked me out from the forum (saying that as a new user I reached the limit number of messages sent).

Sorry for my very little experience, but I don’t know how to update it.
Mainly because in my board modem and microcontroller are communicating via uart port but i have no access to usb pins of the bg95 (there’s no routing for them).

Is there any other way I can upload the new version on?
Forgive my unexperience in the field.

Thanks for the support!
Elia

Never mind, I will send you the upgrade tool and user guide via email.

Hello Mickey,
I was unable to update bg95 firmware version due to some job troubles.
I had no chance to read the flashing procedure you sent me, I’ll try to do it as soon as I can.

I was wondering, in the meanwhile, if you might know other possible reasons regarding my issue with mqtt connection command.
Maybe inizialition procedure, debugging commands in order to understand what’s going on.

I’ll keep you posted on my progresses, please let me know if you have comments.

Have a nice day
Elia

I think the procedure is normal and excuted QIOPEN command successful means your network connection may have no problem. Maybe the server is unstable and the connection disconnected. This is just my guess and will need to be updated for further testing.

Hi Mikey,
I’ve trying to download many times the procedure to flash the latest firmware on the BG95 module but download failed every time (don’t know why).

Can you please resend me the zip file?

I’d like trying to update the firmware version