Xinyuan-LilyGO / LilyGO-T-SIM7000G

LilyGO T-SIM7000G
https://pt.aliexpress.com/item/4000542688096.html
284 stars 123 forks source link

Modem turns on & off periodically in short time intervals #144

Closed jonrot1906 closed 2 years ago

jonrot1906 commented 2 years ago

Hey folks, I currently can't get my LilyGo-T-SIM7070G module to work properly. When trying the NetworkTest sketch in the example folder the modem does connect over NB-Iot but will turn off completely after a few seconds (status and network led will turn off and won't respond to AT commands). This process repeats infinitely. I tried to do a factory reset, but this always fails on this device.

With Mongoose OS and the PPPos library I couldn't get the device to work permanently at all.

Device is connected per USB to my laptop, no battery inserted, no solar panel attached. Network Carrier is 1NCE, NB-Iot is possible.

Any help is appreciated!

LilyGO commented 2 years ago

Will there be a reboot if you re-upload the factory firmware?

jonrot1906 commented 2 years ago

Hi @LilyGO, you mean when I upload the ResetModem sketch to reset the modem? After the usual "Hard resetting via RTS pin" by the Arduino software followed by the reboot of the device there is no "extra" reboot. I also tried to manually reboot the device pressing the RST pin but the sketch will still fail.

When I run the modem reset commands manually, the device always fails at the "AT&W" step.

jonrot1906 commented 2 years ago

https://user-images.githubusercontent.com/15570687/138434610-88bf83be-5bf9-4b46-8872-a3ae00d4a79a.MOV

Please see my short video which shows what I mean. This happens while running the "NetworkTest" sketch.

As I have obtained a few devices, I will try another one soon and report if the problems are occurring there as well.

LilyGO commented 2 years ago

What does the serial port output? You try this example

jonrot1906 commented 2 years ago
Wait...
Initializing modem...
ATE0

OK
AT+CFUN=0

+CPIN: NOT READY

OK
AT+CFUN=1,1

OK
AT
AT
AT

OK
ATE0
ATE0

OK
AT+CMEE=0

OK
AT+CLTS=1

OK
AT+CBATCHK=1

OK
AT+CPIN?

+CPIN: READY

OK
AT+CFUN=0 

+CPIN: NOT READY

OK
AT+CFUN=1 

OK
Initializing modem...
AT

OK
ATE0

OK
AT+CMEE=0

OK
AT+CLTS=1

OK
AT+CBATCHK=1

OK
AT+CPIN?

ERROR
AT+CPIN?

+CPIN: READY

SMS Ready
AT

+CPIN: READY

OK
ATE0

OK
AT+CMEE=0

OK
AT+CLTS=1

OK
AT+CBATCHK=1

OK
AT+CPIN?

+CPIN: READY

OK
AT+GMM

SIMCOM_SIM7070

OK
Modem Name: SIMCOM SIM7070
ATI

R1951.04

OK
Modem Info: R1951.04
AT+SGPIO=0,4,1,0

OK
AT+CPIN?

+CPIN: READY

OK
AT+CNMP=38

OK
AT+CMNB=2

OK
AT+CGDCONT=1,"IP","iot.1nce.net","0.0.0.0",0,0,0,0
AT+CGDCONT=2,"IP","iot.1nce.net","0.0.0.0",0,0,0,0

Waiting for network...
AT+CEREG?

ERROR

DST: 1

*PSUTTZ: 21/10/22,11:24:53","+08",1
AT+CGREG?

+CGREG: 0,5

OK
AT+CEREG?

+CEREG: 0,5

OK
Network connected

---Starting GPRS TEST---

Connecting to: iot.1nce.net
AT+CIPSHUT

ERROR
AT+SAPBR=3,1,"Contype","GPRS"

ERROR
AT+SAPBR=3,1,"APN","iot.1nce.net"

ERROR
AT+CGDCONT=1,"IP","iot.1nce.net"

OK
AT+CGATT=1

OK
AT+CGACT=1,1

OK
AT+SAPBR=1,1

ERROR
AT+SAPBR=2,1

ERROR
Initializing modem...
AT

OK
ATE0

OK
AT+CMEE=0

OK
AT+CLTS=1

OK
AT+CBATCHK=1

OK
AT+CPIN?

+CPIN: READY

OK
AT+GMM

SIMCOM_SIM7070

OK
Modem Name: SIMCOM SIM7070
ATI

R1951.04

OK
Modem Info: R1951.04
AT+SGPIO=0,4,1,0

OK
AT+CPIN?

+CPIN: READY

OK
AT+CNMP=38

OK
AT+CMNB=2

OK
AT+CGDCONT=1,"IP","iot.1nce.net","0.0.0.0",0,0,0,0
AT+CGDCONT=2,"IP","iot.1nce.net","0.0.0.0",0,0,0,0

Waiting for network...
AT+CEREG?

ERROR
AT+CGREG?

+CGREG: 0,5

OK
AT+CEREG?

+CEREG: 0,5

OK
Network connected

This is a short excerpt of the serial output when using the AllFunctions sketch.

LilyGO commented 2 years ago

+CGREG:0,5 indicates to register with roaming network. It has to do with your SIM card. The serial port is connected to the network. Everything looks fine.

jonrot1906 commented 2 years ago

But it shouldn't turn on and off, right? The above was only a short excerpt because this happens periodically. Another example is the use with Mongoose OS: the connection to the modem only works sometimes, although using a similar code to the one in the NetworkTest sketch (PIN 4 low for 1000 ms, then high), sometimes I get this (which will work once I add "AT+CEREG"):

[Oct 24 14:21:16.180] mgos_pppos.c:664        Connecting (UART1, APN 'iot.1nce.net')...
[Oct 24 14:21:16.180] mgos_pppos.c:707        Automatic operator selection
[Oct 24 14:21:18.277] mgos_pppos.c:738        Command timed out: AT
[Oct 24 14:21:18.277] mgos_net.c:86           PPP: connecting
[Oct 24 14:21:18.277] mgos_pppos.c:664        Connecting (UART1, APN 'iot.1nce.net')...
[Oct 24 14:21:18.277] mgos_pppos.c:707        Automatic operator selection
[Oct 24 14:21:19.697] mgos_pppos.c:279        R1951.04, IMEI: 865456054319114
[Oct 24 14:21:20.000] mgos_pppos.c:349        SIM is ready, IMSI: 901405101075862, ICCID: 89882806660010758623
[Oct 24 14:21:20.407] mgos_pppos.c:408        Not connected to mobile network, status 2 (searching) 600
[Oct 24 14:21:22.497] mgos_pppos.c:408        Not connected to mobile network, status 2 (searching) 600
[Oct 24 14:21:24.599] mgos_pppos.c:408        Not connected to mobile network, status 2 (searching) 600
[Oct 24 14:21:25.325] main.c:25               Tock uptime: 350.88, RAM: 286084, 229916 free
[Oct 24 14:21:26.704] mgos_pppos.c:408        Not connected to mobile network, status 2 (searching) 600
[Oct 24 14:21:30.792] mgos_pppos.c:738        Command timed out: AT+CREG?
[Oct 24 14:21:30.792] mgos_pppos.c:369        Error response to AT+CREG, proceeding anyway
[Oct 24 14:21:30.792] mgos_net.c:86           PPP: connecting
[Oct 24 14:21:30.792] mgos_pppos.c:664        Connecting (UART1, APN 'iot.1nce.net')...
[Oct 24 14:21:30.792] mgos_pppos.c:707        Automatic operator selection
[Oct 24 14:21:32.835] mgos_pppos.c:738        Command timed out: AT
[Oct 24 14:21:32.835] mgos_net.c:86           PPP: connecting
[Oct 24 14:21:32.835] mgos_pppos.c:664        Connecting (UART1, APN 'iot.1nce.net')...
[Oct 24 14:21:32.835] mgos_pppos.c:707        Automatic operator selection
[Oct 24 14:21:32.986] mgos_pppos.c:776        Command failed: ATH
[Oct 24 14:21:32.986] mgos_net.c:86           PPP: connecting
[Oct 24 14:21:33.062] mgos_pppos.c:664        Connecting (UART1, APN 'iot.1nce.net')...
[Oct 24 14:21:33.062] mgos_pppos.c:707        Automatic operator selection
[Oct 24 14:21:34.606] mgos_pppos.c:279        R1951.04, IMEI: 865456054319114
[Oct 24 14:21:34.909] mgos_pppos.c:349        SIM is ready, IMSI: 901405101075862, ICCID: 89882806660010758623
[Oct 24 14:21:35.197] mgos_pppos.c:408        Not connected to mobile network, status 2 (searching) 600
[Oct 24 14:21:35.333] main.c:25               Tick uptime: 360.88, RAM: 286084, 229912 free
[Oct 24 14:21:37.298] mgos_pppos.c:408        Not connected to mobile network, status 2 (searching) 600
[Oct 24 14:21:39.402] mgos_pppos.c:408        Not connected to mobile network, status 2 (searching) 600
[Oct 24 14:21:41.496] mgos_pppos.c:408        Not connected to mobile network, status 2 (searching) 600
[Oct 24 14:21:45.321] main.c:25               Tock uptime: 370.88, RAM: 286084, 229912 free
[Oct 24 14:21:45.581] mgos_pppos.c:738        Command timed out: AT+CREG?
[Oct 24 14:21:45.581] mgos_pppos.c:369        Error response to AT+CREG, proceeding anyway
[Oct 24 14:21:45.581] mgos_net.c:86           PPP: connecting
[Oct 24 14:21:45.581] mgos_pppos.c:664        Connecting (UART1, APN 'iot.1nce.net')...
[Oct 24 14:21:45.581] mgos_pppos.c:707        Automatic operator selection
[Oct 24 14:21:47.682] mgos_pppos.c:738        Command timed out: AT
[Oct 24 14:21:47.682] mgos_net.c:86           PPP: connecting
[Oct 24 14:21:47.682] mgos_pppos.c:664        Connecting (UART1, APN 'iot.1nce.net')...
[Oct 24 14:21:47.682] mgos_pppos.c:707        Automatic operator selection
[Oct 24 14:21:49.775] mgos_pppos.c:738        Command timed out: AT
[Oct 24 14:21:49.775] mgos_net.c:86           PPP: connecting
[Oct 24 14:21:49.775] mgos_pppos.c:664        Connecting (UART1, APN 'iot.1nce.net')...
[Oct 24 14:21:49.775] mgos_pppos.c:707        Automatic operator selection

but mostly this, meaning communication with the modem is not possible at all:

[Oct 24 14:52:42.521] mgos_pppos.c:738        Command timed out: AT
[Oct 24 14:52:42.521] mgos_net.c:86           PPP: connecting
[Oct 24 14:52:42.521] mgos_pppos.c:664        Connecting (UART1, APN 'iot.1nce.net')...
[Oct 24 14:52:42.521] mgos_pppos.c:707        Automatic operator selection
[Oct 24 14:52:44.625] mgos_pppos.c:738        Command timed out: AT
[Oct 24 14:52:44.625] mgos_net.c:86           PPP: connecting
[Oct 24 14:52:44.625] mgos_pppos.c:664        Connecting (UART1, APN 'iot.1nce.net')...
[Oct 24 14:52:44.625] mgos_pppos.c:707        Automatic operator selection
[Oct 24 14:52:46.726] mgos_pppos.c:738        Command timed out: AT
[Oct 24 14:52:46.726] mgos_net.c:86           PPP: connecting
[Oct 24 14:52:46.726] mgos_pppos.c:664        Connecting (UART1, APN 'iot.1nce.net')...
[Oct 24 14:52:46.726] mgos_pppos.c:707        Automatic operator selection
[Oct 24 14:52:48.826] mgos_pppos.c:738        Command timed out: AT
[Oct 24 14:52:48.826] mgos_net.c:86           PPP: connecting
[Oct 24 14:52:48.826] mgos_pppos.c:664        Connecting (UART1, APN 'iot.1nce.net')...
[Oct 24 14:52:48.826] mgos_pppos.c:707        Automatic operator selection

In my opinion this is not related to my SIM card but to the modem. If it wouldn't turn on and off, the PPP connection could be established successfully (the Mongoose OS app uses RX 26, TX 27, baud rate 9600, equal code as in NetworkTest sketch).

LilyGO commented 2 years ago

AT+CEREG?

+CEREG: 0,5

OK Network connected ..... What will it print?

Can you send me the serial printout ? I would like to know when the modem will restart

jonrot1906 commented 2 years ago

Sorry for my belated answer. So this is what I get for a few days now:

SDCard MOUNT FAIL

Wait...
Initializing modem...
ATE0
AT+CFUN=0
AT+CFUN=0

+CPIN: NOT READY

OK
AT+CFUN=1,1
AT+CFUN=1,1

OK
AT
AT
AT

OK
ATE0
ATE0

OK
AT+CMEE=0

OK
AT+CLTS=1

OK
AT+CBATCHK=1

OK
AT+CPIN?

+CPIN: READY

OK
AT+CFUN=0 

+CPIN: NOT READY

OK
AT+CFUN=1 

OK
Initializing modem...
AT

OK
ATE0

OK
AT+CMEE=0

OK
AT+CLTS=1

OK
AT+CBATCHK=1

OK
AT+CPIN?

ERROR
AT+CPIN?

+CPIN: READY

SMS Ready
AT

+CPIN: READY

OK
ATE0

OK
AT+CMEE=0

OK
AT+CLTS=1

OK
AT+CBATCHK=1

OK
AT+CPIN?

OK

+CPIN: READY

OK
AT+GMM

SIMCOM_SIM7070

OK
Modem Name: SIMCOM SIM7070
ATI

R1951.04

OK
Modem Info: R1951.04
AT+SGPIO=0,4,1,0

OK
AT+CPIN?

+CPIN: READY

OK
AT+CNMP=38

OK
AT+CMNB=2

OK
AT+CGDCONT=1,"IP","iot.1nce.net","0.0.0.0",0,0,0,0
AT+CGDCONT=2,"IP","iot.1nce.net","0.0.0.0",0,0,0,0

Waiting for network...
AT+CEREG?

ERROR
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK
AT+CEREG?

+CEREG: 0,2

OK
AT+CGREG?

+CGREG: 0,2

OK

Interestingly, I find out that when I change the AllFunctions sketch to turn PWR key/GPIO 4 low for 1 second and then turn high, the modem will periodically restart, if I use the provided sketch (300 ms high, then low), it does not happen. I tried the SIM card with a Waveshare SIM7600 and SIM7000E module (as RPi hat) as well and was able to get a connection there (4G/NB-IoT).

jonrot1906 commented 2 years ago

Okay, so setting NetworkMode to 38 and PreferredMode to 3, this happens:


ERROR
AT+SAPBR=2,1

ERROR
Initializing modem...
AT

OK
ATE0

OK
AT+CMEE=0

OK
AT+CLTS=1

OK
AT+CBATCHK=1

OK
AT+CPIN?

+CPIN: READY

OK
AT+GMM

SIMCOM_SIM7070

OK
Modem Name: SIMCOM SIM7070
ATI

R1951.04

OK
Modem Info: R1951.04
AT+CPIN?

+CPIN: READY

OK
AT+CNMP=38

OK
AT+CMNB=3

OK
AT+CGDCONT=1,"IP","iot.1nce.net","0.0.0.0",0,0,0,0
AT+CGDCONT=2,"IP","iot.1nce.net","0.0.0.0",0,0,0,0

Waiting for network...
AT+CEREG?

ERROR
AT+CGREG?

+CGREG: 0,5

OK
AT+CEREG?

+CEREG: 0,5

OK
Network connected

---Starting GPRS TEST---

Connecting to: iot.1nce.net
AT+CIPSHUT

ERROR
AT+SAPBR=3,1,"Contype","GPRS"

ERROR
AT+SAPBR=3,1,"APN","iot.1nce.net"

ERROR
AT+CGDCONT=1,"IP","iot.1nce.net"

OK
AT+CGATT=1

OK
AT+CGACT=1,1

OK
AT+SAPBR=1,1

ERROR
AT+SAPBR=2,1

ERROR

So obviously the modem will reset every now and then but at least a connection is possible.

LilyGO commented 2 years ago

Is it normal for you not to modify the code in the sketch?

jonrot1906 commented 2 years ago

Of course it is normal for me to modify it. But because I couldn't get the device to work, I thought the sketches provided by the module builder would work and be a good starting point. Whatever, I got it to work now by doing the following:

    pinMode(PWR_PIN, OUTPUT);
    digitalWrite(PWR_PIN, LOW);
    delay(1200);
    digitalWrite(PWR_PIN, HIGH);
    delay(300); 
    digitalWrite(PWR_PIN, LOW);

It seems to be important to set PWR_PIN to low again. With this configuration my module won't restart periodically and works just fine. Maybe you can integrate a short command in your example sketches to point this out.

LilyGO commented 2 years ago

The default sketch configuration is: pinMode(PWR_PIN, OUTPUT); digitalWrite(PWR_PIN, HIGH); delay(300); digitalWrite(PWR_PIN, LOW);

Your configuration is : pinMode(PWR_PIN, OUTPUT); digitalWrite(PWR_PIN, LOW); //The part you add delay(1200); //The part you add digitalWrite(PWR_PIN, HIGH); delay(300); digitalWrite(PWR_PIN, LOW);

You mean the default configuration will cause a reboot?Won't your added configuration cause a reboot?

jonrot1906 commented 2 years ago

Sorry that I left this topic uncommented for so long. My personal workaround was to do the following (as already stated above): Turn on:

digitalWrite(PWR_PIN, LOW);
delay(1200);
digitalWrite(PWR_PIN, HIGH);
delay(300);
digitalWrite(PWR_PIN, LOW);
delay(10000);

Turn off:

delay(1500);
digitalWrite(PWR_PIN, LOW);

This works on all my SIM7070G equipped devices (ESP32 + SIM7070G and also my Waveshare SIM7070G Raspberry Pi Hat). With "normal" turn on as provided in your examples, the modem will keep rebooting every 14 seconds or so.

szundi commented 2 years ago

Hello, just FYI: according to the docs, if you keep the PWRKEY pin DOWN for 12.6sec, it resets.

rhr407 commented 2 years ago

I receive no response for HTTP Get request for the http://httpbin.org/get URL. Following is the output using the AT Command Tester from https://m2msupport.net


Checking registration status...

AT+CREG?

+CREG: 2,1,"912","3D73",0

OK
The device is registered in home network.

AT+CGREG?

+CGREG: 2,1,"912","3D73",0,"1"

OK
The device is registered in home network.

Device is registered.. 

Check the network APN...

AT+CGNAPN

+CGNAPN: 0,""

OK
Network did not send APN to the device.
Activate the network bearer...

AT+CNACT=0,1

OK

+APP PDP: 0,ACTIVE
Set up the HTTP URL...

AT+SHCONF="URL","httpbin.org"

OK
Set up the HTTP body length...

AT+SHCONF="BODYLEN",1024

OK
Set up the HTTP header length...

AT+SHCONF="HEADERLEN",350

OK
Initiating HTTP connection...

AT+SHCONN

OK
Get the HTTP connection state...

AT+SHSTATE?

+SHSTATE: 1

OK
HTTP connection is successful...

HTTP get request...

AT+SHREQ="http://httpbin.org/get",1

OK
No reponse received..
Gabriel-Gardin commented 1 year ago

Hello, I was having the same problem, SIM7070 board was reseting in short periods of time, when I chagned my code to turn on the board using: pinMode(PWR_PIN, OUTPUT); digitalWrite(PWR_PIN, HIGH); delay(300); digitalWrite(PWR_PIN, LOW);

then it start working.

Apparently SIM7000G and SIM7070G have different power on GPIO requirements.

deeja commented 11 months ago

Have been looking at this myself. As @Gabriel-Gardin said, changing the PWR_PIN to LOW stops this. The reason is that setting to HIGH sets the inverted value of PWR_KEY on the SIM7070 module to LOW. When held LOW for 12 seconds, the module resets. From the 7070 hardware design manual:

After the PWRKEY continues to pull down more than 12S, the system will automatically reset. Therefore, long-term grounding is not recommended

This is different from the SIM7000 which has a reset pin