Closed droidblastnz closed 1 year ago
Q1. If the network light is not doing what it is supposed to be doing - it's probably a network issue. What provider are you using? Have you tried other providers? Try testing the broker connection with a client that isnt the lilygo and see if the problem persists. You could also just go the route of shutting the modem off and back on again if you can go without a couple minutes of data.
Q2. You're getting extra characters because you're using software Serial instead of hardware Serial. Software Serial is known to be less than reliable. See this post to get you in the right direction.
Q1. If the network light is not doing what it is supposed to be doing - it's probably a network issue. What provider are you using? Have you tried other providers? Try testing the broker connection with a client that isnt the lilygo and see if the problem persists. You could also just go the route of shutting the modem off and back on again if you can go without a couple minutes of data.
Q2. You're getting extra characters because you're using software Serial instead of hardware Serial. Software Serial is known to be less than reliable. See this post to get you in the right direction.
Q1. Thanks, after quite a few attempts the netlight is still flashing when MQTT is disconnected at 200ms which to me is still connected. But the logs show +NETCLOSE: 0 which is the TCP port closed. Also if I try to ring the SIM7600x during this condition it doesn't answer. I set a function to reboot if rung from number xxxx.
Q2 #define SerialAT Serial1 using hardware serial. Found similar to your post comment but mine is hardware so also tried to adjust the baud rate lower from 115200. At all speeds still get the same noise on MQTT messages. Also worth mentioning is its had a random ? when watching the serial debug console during modem activity.... CIPSEND still returns OK which is the correct response but again randon character no MQTT this time, and this is repeated every few minutes.
07:23:03.038 -> AT+CIPSEND=0,2
07:23:03.038 ->
07:23:03.038 -> >⸮
07:23:03.084 -> OK
Revised code to remove loop due to network provider disconnecting, was not MQTT
if (!mqtt.connected()) {
SerialMon.println("MQTT NOT CONNECTED! ");
SerialMon.print("Disconnecting from: ");
SerialMon.println(broker);
mqtt.disconnect(); // Disconnect from MQTT //added 08/04/2023
delay(500);
SerialMon.print("Network State is: ");
SerialMon.println(modem.isGprsConnected()); //added 08/04/2023
// Reconnect every 10 seconds
uint32_t t = millis();
if (t - lastReconnectAttempt > 10000L) {
lastReconnectAttempt = t;
if (!modem.isGprsConnected()) {
// Reconnect to GPRS network if not connected
SerialMon.println("GPRS not connected, reconnecting...");
if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
SerialMon.println("GPRS reconnect failed");
delay(10000);
return;
}
}
if (mqttConnect()) {
lastReconnectAttempt = 0;
}
}
delay(100);
return;
}
Team,
Have a T-Sim7600G-H and using Tiny_GSM, Pub Sub client to connect to MQTT. The SIM connects to GPRS and MQTT (HiveMQ) out issues. I can send and receive Pub/Sub Topics/Messages ok apart from some extra or garage characters.
Baud rate is set 115200 and have checked lower rates with not success at removing these extra or garage characters.
void setup() { //Set console baud rate Serial.begin(115200); //115200 delay(10); SerialAT.begin(UART_BAUD, SERIAL_8N1, MODEM_RX, MODEM_TX);
SIM7600 disconnects from broker.hivemq.com I see this error.
07:38:06.912 -> AT+CIPCLOSE? 07:38:06.946 -> 07:38:06.946 -> +CIPCLOSE: 1,0,0,0,0,0,0,0,0,0 07:38:06.980 -> 07:38:06.980 -> OK 07:38:08.078 -> AT+CGREG? 07:38:08.078 -> 07:38:08.078 -> +CGREG: 0,1 07:38:08.112 -> 07:38:08.112 -> OK 07:38:08.112 -> AT+CIPRXGET=4,0 07:38:08.147 -> 07:38:08.147 -> +CIPRXGET: 4,0,0 07:38:08.147 -> 07:38:08.147 -> OK 07:38:08.180 -> AT+CIPCLOSE? 07:38:08.180 -> 07:38:08.180 -> +CIPCLOSE: 1,0,0,0,0,0,0,0,0,0 07:38:08.214 -> 07:38:08.214 -> OK
23-24hrs later we see we cant connect to MQTT.
Note: -Status RED LED is on solid -Network/Netlight red LED that normally flashes is off
18:51:18.272 -> MQTT NOT CONNECTED! 18:51:18.344 -> AT+CGREG? 18:51:18.344 -> 18:51:18.388 -> +CGREG: 0,1 18:51:18.388 -> 18:51:18.388 -> OK 18:51:18.388 -> AT+CIPRXGET=4,0 18:51:18.432 -> 18:51:18.432 -> +CIPRXGET: 4,0,0 18:51:18.432 -> 18:51:18.432 -> OK 18:51:18.432 -> AT+CIPCLOSE? 18:51:18.476 -> 18:51:18.476 -> +CIPCLOSE: 0,0,0,0,0,0,0,0,0,0 18:51:18.518 -> 18:51:18.518 -> OK 18:51:18.518 -> MQTT NOT CONNECTED! 18:51:18.606 -> AT+CGREG? 18:51:18.650 -> 18:51:18.650 -> +CGREG: 0,1 18:51:18.650 -> 18:51:18.650 -> OK 18:51:18.650 -> MQTT NOT CONNECTED! 18:51:18.781 -> AT+CGREG? 18:51:18.781 -> 18:51:18.781 -> +CGREG: 0,1 18:51:18.827 -> 18:51:18.827 -> OK 18:51:18.827 -> MQTT NOT CONNECTED! 18:51:18.899 -> AT+CGREG? 18:51:18.919 -> 18:51:18.919 -> +CGREG: 0,1 18:51:18.964 -> 18:51:18.964 -> OK
I used the example MQTT code to test and I get disconnects every 23.5-24hrs. SIM is powered off a 3A/5v supply.
In Tiny_GSM details it mentions the following:
"When using MQTT, to keep a continuous connection you may need to reduce your keep-alive interval (PINGREQ/PINGRESP)"
Rather than editing the Pub/Sub library directly added
mqttClient.setKeepAlive(30); // Set the keep-alive interval to 30 seconds
Also some people report adding this helps (tried 1,2,4,6ms).
#define TINY_GSM_YIELD_MS 2 //was 2 milliseconds
In my case still have the SIM disconnect at 23/24hrs running.
Final info is I do see a lot of extra characters for example this ? repeats
07:38:18.207 -> +CIPCLOSE: 1,0,0,0,0,0,0,0,0,0 07:38:18.244 -> 07:38:18.244 -> OK 07:38:18.244 -> AT+CIPSEND=0,2 07:38:18.278 -> 07:38:18.278 -> >⸮ 07:38:18.278 -> OK 07:38:18.392 -> 07:38:18.429 -> +CIPSEND: 0,2,2
Sending a simple LED toggle via 4G/MQTT Pub/Sub we see extras characters.
Checking with MQTT explore to HiveMQ I dont see any extra characters, I see the expected Pub/Sub topics/messages.
Note every 8hrs the SIM 7600 will send a Pub/message of CPU temp, Powersupply Voltage and Credit check again this works after 8hrs. At 23/24hrs the SIM drops of MQTT or suspect dropping of the network (RED LED network/netlight light if off).
Q1. Why is the SIM7600 disconnecting after 23/24hrs running without issue? How do I fault find this better than above?
Q2. Why am I getting extra characters in the serial console when debugging? How do I fault find this better than above?