Xinyuan-LilyGO / LilyGO-T-SIM7000G

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

Led STATUS light after modemPowerOff() #150

Closed GalBaToRicS closed 2 years ago

GalBaToRicS commented 2 years ago

Hi. I tried power off Sim7000 with function modemPowerOff(), but I ran into such a problem that the LED goes out for a few seconds and then lights up again. I tried to shutdown the module using the command AT+CPOWD=1 and modem.sleepEnable(false) modem.poweroff(), but it produces the same result. I tested the code on two boards. If i delet modem.init() led the LED doesn't even go out.

#define SerialMon Serial
#define SerialAT Serial1
#define delay_ms 500

//#define TINY_GSM_MODEM_SIM7000
#define TINY_GSM_MODEM_SIM7000SSL
#define TINY_GSM_RX_BUFFER 1024 // Set RX buffer to 1Kb

#include <TinyGsmClient.h>
#include <PubSubClient.h>

#ifdef DUMP_AT_COMMANDS
#include <StreamDebugger.h>
StreamDebugger debugger(SerialAT, SerialMon);
TinyGsm modem(debugger);
#else
TinyGsm modem(SerialAT);
#endif

#define UART_BAUD           9600
#define PIN_DTR             25
#define PIN_TX              27
#define PIN_RX              26
#define PWR_PIN             4
#define LED_PIN             12

void modemPowerOn()
{
  pinMode(PWR_PIN, OUTPUT);
  digitalWrite(PWR_PIN, LOW);
  delay(1000);    //Datasheet Ton mintues = 1S
  digitalWrite(PWR_PIN, HIGH);
  Serial.println("Power on");
}

void modemPowerOff()
{
  pinMode(PWR_PIN, OUTPUT);
  digitalWrite(PWR_PIN, LOW);
  delay(1500);    //Datasheet Ton mintues = 1.2S
  digitalWrite(PWR_PIN, HIGH);
  Serial.println("Power off");
}

void modemRestart()
{
  modemPowerOff();
  delay(1000);
  modemPowerOn();
}

void setup() {
  SerialMon.begin(115200);
  delay(10);
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, HIGH);
  modemPowerOn();
  delay(10000);
  SerialAT.begin(UART_BAUD, SERIAL_8N1, PIN_RX, PIN_TX);
  Serial.println("========INIT========");
  if (!modem.init()) {
    modemRestart();
    delay(2000);
    Serial.println("Failed to restart modem, attempting to continue without restarting");
    //return;
  }
  delay(2000);
  /*String res;
  for (int8_t i = 0; i < 100; i++) //timeout 100 x 100ms = 10sec
  {
    if (modem.testAT())
    { Serial.println("Wait time:");
      Serial.println(i);
      break;
    }
    delay(100);
  }
  res = "";
  modem.sendAT("");
  modem.waitResponse(10000L, res);
  Serial.println(res);
  res = "";
  modem.sendAT("+CPOWD=1");
  modem.waitResponse(10000L, res);
  Serial.println(res);*/
  modemPowerOff();
}

void loop() {
}
GalBaToRicS commented 2 years ago

I found decision in #146