Xinyuan-LilyGO / LilyGO-T-SIM7000G

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

Read SIM7000G Power status from ESP32 #229

Open markjandrews opened 1 year ago

markjandrews commented 1 year ago

Currently SIM7000G pin 66 (STATUS) only drives an LED. Is there any potential to get this pin able to drive an input on the ESP32 so we can test whether the the SIM7000G has power. At the moment there is no way to actually know, through software, the power status of the SIM7000G an so signaling the "toggle" power button could be either turning the SIM7000G on or off as it can get out of sync.

A similar feature of pin 52 (NETLIGHT) would also be useful to know as as a simple way of checking the network connection

DevinCarpenter commented 1 year ago

Getting the power status of the SIM7000G is frustrating for me too. I use the AT command to see if the modem responds. If it responds - then I know it has power, otherwise I toggle the power.

That solution has worked reliably for me.

shanedoolane commented 9 months ago

@DevinCarpenter @markjandrews did you good way to determine if power is on but modem is in a frozen/unresponsive state? If the modem doesn't respond to AT, it could be:

  1. Stuck
  2. Off

If in state 1, we want to power cycle it. State 2 maybe we try the same?

// Turn off
pinMode(MODEM_PWKEY, OUTPUT);
digitalWrite(MODEM_PWKEY, LOW);
delay(1500); // Datasheet T_on mintues = 1.25S Lilygo
digitalWrite(MODEM_PWKEY, HIGH);
// Turn back on
pinMode(MODEM_PWKEY, OUTPUT);
digitalWrite(MODEM_PWKEY, HIGH); // https://github.com/Xinyuan-LilyGO/LilyGO-T-SIM7000G/blob/196c3aef13fe7b31b5a00fa97dbd9bb959f56bd5/examples/Arduino_TinyGSM/AllFunctions/AllFunctions.ino#L74C1-L74C1
delay(1000);                     
digitalWrite(MODEM_PWKEY, LOW);

// check AT
modem.testAT

// graceful shutdown
modem.sendAT("+CPOWD=1")
DevinCarpenter commented 6 months ago

@shanedoolane as far as finding a way that works - I toggle the power if there is no response. This has worked well for me, generally sending out a number of AT commands works to test for responsiveness.