TTGO ESP32 + GSM 800l - Read SMS - TinyGSM

933 views Asked by At

on my code i can send an sms to my target number but i don't know how to read or receive sms from target number

the tinyGSM library doesn't have the read member function and i don't know how to use AT commands


void setup() {
  // Set console baud rate
  SerialMon.begin(115200);

  // Keep power when running from battery
  Wire.begin(I2C_SDA, I2C_SCL);
  bool isOk = setPowerBoostKeepOn(1);
  SerialMon.println(String("IP5306 KeepOn ") + (isOk ? "OK" : "FAIL"));

  // Set modem reset, enable, power pins
  pinMode(MODEM_PWKEY, OUTPUT);
  pinMode(MODEM_RST, OUTPUT);
  pinMode(MODEM_POWER_ON, OUTPUT);
  digitalWrite(MODEM_PWKEY, LOW);
  digitalWrite(MODEM_RST, HIGH);
  digitalWrite(MODEM_POWER_ON, HIGH);

  // Set GSM module baud rate and UART pins
  SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX);
  delay(3000);

  // Restart SIM800 module, it takes quite some time
  // To skip it, call init() instead of restart()
  SerialMon.println("Initializing modem...");
  modem.restart();
  // use modem.init() if you don't need the complete restart

  // Unlock your SIM card with a PIN if needed
  if (strlen(simPIN) && modem.getSimStatus() != 3 ) {
    modem.simUnlock(simPIN);
  }

  // To send an SMS, call modem.sendSMS(SMS_TARGET, smsMessage)
  String smsMessage = "Hello from ESP32!";
  /*if(modem.sendSMS(SMS_TARGET, smsMessage))
  {
    SerialMon.println(smsMessage);
  }
  else{
    SerialMon.println("SMS failed to send");
  }*/

  SerialAT.println("AT"); //Once the handshake test is successful, it will back to OK
  SerialAT.println("AT+CMGF=1"); // Configuring TEXT mode
  SerialAT.println("AT+CNMI=1,2,0,0,0"); // Decides how newly arrived SMS messages should be handled
}

void loop() 
{
  //readSMS(1);  
 //delay(1);
}
0

There are 0 answers