我的目的是使用GSM SIM800L 核心板和 Arduino UNO 发送短信。这是代码
#include <SoftwareSerial.h>
//Create a software serial object to communicate with SIM800L
SoftwareSerial mySerial(3, 2); //SIM800L Tx & Rx is connected to Arduino #3 & #2
void setup()
{
//Begin serial communication with Arduino and Arduino IDE (Serial Monitor)
Serial.begin(115200);
//Begin serial communication with Arduino and SIM800L
mySerial.begin(115200);
Serial.println("Initializing...");
delay(1000);
mySerial.println("AT"); //Once the handshake test is successful, it will back to OK
updateSerial();
mySerial.println("AT+CMGF=1"); // Configuring TEXT mode
updateSerial();
mySerial.println("AT+CMGS=\"+ZZxxxxxxxxx\"");//change ZZ with country code and xxxxxxxxxxx with phone number to sms
updateSerial();
mySerial.print("TEST"); //text content
updateSerial();
mySerial.write(26);
}
void loop()
{
}
void updateSerial()
{
delay(500);
while (Serial.available())
{
mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port
}
while(mySerial.available())
{
Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
}
}
这是串行监视器输出
22:31:19.430 -> Initializing...
但是,当我运行代码时,我的手机收到了短信,但在串口监视器中看不到任何 AT 命令。它只输出 "Initializing..."。所有的连接和波特率都可以,检查了一千次。已将 2A、4.4v 电源连接到 GSM 核心板并缩短电线,并确保没有坏焊点。GSM 模块红色 LED 每 3 秒闪烁一次。再一次,我收到短信到我的手机。所以这意味着问题出在 Arduino 串行监视器或代码上,而不是硬件上。我需要查看 AT 命令,因为我需要通过串行监视器输入更多命令,我尝试输入并单击发送,但它没有显示任何内容。您能提供的任何帮助将不胜感激。