Xinyuan-LilyGO / LilyGO-T-SIM7000G

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

Modem will not power off #251

Open nravanelli opened 1 year ago

nravanelli commented 1 year ago

I have been attempting to power down the modem using the commands provided, and methods presented in various issues here, but have not had success.

my setup runs this function to start the modem:

  pinMode(MODEM_PWKEY, OUTPUT);
  digitalWrite(MODEM_PWKEY, HIGH);
  // Starting the machine requires at least 1 second of low level, and with a level conversion, the levels are opposite
  delay(1000);
  digitalWrite(MODEM_PWKEY, LOW);

and then I initially turn the modem on:

  digitalWrite(MODEM_PWKEY, HIGH);
  delay(10);
  digitalWrite(MODEM_PWKEY, LOW);
  delay(1010);  //Ton 1sec
  digitalWrite(MODEM_PWKEY, HIGH);
  delay(4510);  //Ton uart 4.5sec but seems to need ~7sec after hard (button) reset
  SerialAT.begin(115200, SERIAL_8N1, MODEM_TX, MODEM_RX);
  modem.setBaud(115200);
  modem.begin();

and then I turn off modem

  modem.sendAT("+CPOWD=1");
    if (modem.waitResponse(10000L) != 1) {
        Serial.println("+CPOWD=1");
    }
  modem.poweroff();
  digitalWrite(MODEM_PWKEY, HIGH);
  delay(6000);//Ensure that SIM7000 is powered off after a long delay

But, after a couple seconds of running my modem off function, the modem turns back on (the network leds flash).

Is there a foolproof solution to turning the modem off and still run code on the ESP32?

felmue commented 1 year ago

Hello @nravanelli

from the schematic I see there is an NPN transistor used for the PWR_KEY which means the levels are inverted.

So to turn on the modem GPIO4 should be driven LOW/HIGH/LOW which after the transistor is HIGH/LOW/HIGH.

And since, after sending the AT command to turn off, you set MODEM_PWKEY to HIGH this actually makes the modem turning on again. Which is what you see.

So when you use LOW/HIGH/LOW to turn the modem on, GPIO4 is already correctly set to LOW and the modem should turn off after sending the AT command.

BTW: this comment (from your post) actually tries to tell you that the PWR_KEY line is inverted. (opposite = inverted)

// Starting the machine requires at least 1 second of low level, and with a level conversion, the levels are opposite

Thanks Felix

nravanelli commented 12 months ago

@felmue Thanks Felix, I solved based on your comment. Is there a way to turn off the modem at the start, without having to turn it on first?

felmue commented 12 months ago

Hello @nravanelli

not sure I understand your question? If you do not turn it on via PWR_KEY it should stay turned off, even if you apply power to it.

Thanks Felix

fgnievinski commented 3 days ago

just a heads-up: the reset pin also has inverted levels.