【发布时间】:2018-04-23 17:07:23
【问题描述】:
#include <SoftwareSerial.h>
//SIM800 TX is connected to Arduino D8
#define SIM800_TX_PIN 8
//SIM800 RX is connected to Arduino D7
#define SIM800_RX_PIN 7
//Create software serial object to communicate with SIM800
SoftwareSerial serialSIM800(SIM800_TX_PIN,SIM800_RX_PIN);
void setup() {
//Begin serial comunication with Arduino and Arduino IDE (Serial Monitor)
Serial.begin(9600);
while(!Serial);
//Being serial communication with Arduino and SIM800
serialSIM800.begin(9600);
Serial.println("Setup Complete!");
//serialSIM800.println("AT+CSPN?\r\n");
//serialSIM800.println("AT+EXUNSOL=\"SQ\",1\r\n");
//serialSIM800.println("AT");
//delay(1000);
//Send SMS
Serial.println("Sending Text...");
delay(1000);
serialSIM800.print("AT+CMGF=1\r");
serialSIM800.print("AT+CMGS=\"0781xxxxxxx\"\r");
delay(200);
//Send SMS content
serialSIM800.print("TEST");
serialSIM800.print("\r");
delay(500);
//Send Ctrl+Z / ESC to denote SMS message is complete
serialSIM800.print((char)26);
delay(100);
serialSIM800.println();
delay(500);
Serial.println("SMS Sent!");
delay(500);
}
void loop() {
//Read SIM800 output (if available) and print it in Arduino IDE Serial Monitor
if(serialSIM800.available()){
Serial.write(serialSIM800.read());
}
//Read Arduino IDE Serial Monitor inputs (if available) and send them to SIM800
if(Serial.available()){
serialSIM800.write(Serial.read());
}
}
上面的代码在上传运行时没有产生错误但没有收到短信。
串口模式显示如下;-
设置完成! 发送文本... 短信发送! AT+CMGF=1 AT+CMGS="0781xxxxxxx"
好的 测试
通话就绪
显然,我将文本发送到可用的手机也尝试了国家代码选项。我还没有在网上找到任何有帮助的东西,希望有人能指出我正确的方向。
谢谢
【问题讨论】: