使用GSM模块SIM900A无法发送短信

SMS can't be sent using GSM module SIM900A

我正在尝试使用 GSM SIM900A 发送短信。但是那里没有编译错误和其他干扰。

代码执行正确,但短信没有发送到代码中提到的号码。


#include <TinyGPS.h>
#include <SoftwareSerial.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);
SoftwareSerial SIM900A(7, 8);

void setup()
{

  Serial.begin(9600);
  SIM900A.begin(9600);
  pinMode(6, INPUT);
}

void loop()
{

  bool state = digitalRead(6);
  if (state == HIGH)    
  {





    SIM900A.println("AT+CMGF=1");
    delay(1000);
    SIM900A.println("AT+CMGS=\"+8801679388394\"\r");
    delay(1000);

    SIM900A.println("Alert I need help....Asheesh ,Battalion No. 1233456 ");
    SIM900A.println((char)26);

    delay(10000);

  }
  else {


    delay(2000);


  }


}


我不明白这里出了什么问题。谁能告诉我有什么问题吗?

首先检查您的SIM900A是否已经正确初始化。您还需要检查 GSM 模块是否检测到 SIM 卡。通常这由板载 LED 指示,每 3 秒 闪烁一次。 以下代码是向用户发送短信。

void sendSMS()
{
   SIM900A.println("AT+CMGF=1");
   delay(1000);

   SIM900A.println("AT+CMGS=\"+8801679388394\"\r");
   delay(1000); 

   SIM900A.print("Hello");
   delay(1000);

   SIM900A.println((char)26);     // sends ctrl+z end of message 
   delay(5000);
}

在尝试此代码之前,请检查您是否已使用 AT+COPS? 连接到网络。打开串行监视器后,确保选择了“Both NL & CR”选项!

GSM SIM900A 仅支持 2G SIM card.At首先确保您使用的是 2G SIM。