arduino - Arduino + SIM800A 消息被截断
问题描述
我正在使用 Arduino 和 SIM800A。我的目标是将 SIM800A 收到的短信保存到一个字符串变量中以备后用。然而令我惊讶的是,消息总是被切断,我不知道为什么。
我发送到 SIM 卡:
This is a test message
串行监视器仅显示:
+CMT: "+XXXXXXXXXX","","21/02/20,01:52:40+28"
This is a tes
下面是代码
#include <SoftwareSerial.h>
// Configure software serial port
SoftwareSerial Sim(2, 3);
// Variable to store text message
char incomingMessage;
String textMessage;
void setup() {
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
// Initializing serial commmunication
Serial.begin(9600);
Sim.begin(9600);
delay(100);
while (!Sim.available()) {
Sim.println("AT");
delay(200);
Serial.println("Connecting...");
}
Serial.println("Connected!");
Sim.println("AT+CMGF=1"); //Set SMS to Text Mode
delay(200);
// Sim.println("AT+CMGL=\"ALL\"");
// delay(500);
Sim.println("AT+CNMI=1,2,0,0,0"); //Procedure to handle newly arrived messages(command name in text: new message indications to TE)
delay(1000);
Sim.read();
//Sim.println("AT+CMGL=\"REC UNREAD\""); // Read Unread Messages
}
void loop() {
if (Sim.available()>0) {
delay(200);
// Serial Buffer
while (Sim.available()>0) {
incomingMessage = Sim.read();
textMessage += incomingMessage;
}
delay(500);
Serial.println(textMessage);
textMessage = "";
}
}
解决方案
推荐阅读
- selenium-webdriver - 如何允许边缘网络浏览中的麦克风/摄像头起诉硒
- batch-file - 无法找出导致此批处理脚本错误的原因
- sql - 根据表中的记录删除查询结果
- java - 如何为函数中的注释参数编写模拟
- javascript - Python Web Scraping:与日历交互
- javascript - 设置 JavaScript 自定义对象的真实值
- coldfusion - ColdFusion 中自动交易电子邮件模板的存储位置
- java - 将 TemporalTableFunction 注册为函数时出现编译器错误
- python - 如果值是列表中的最后一个,则忽略函数
- angular - 如果表单验证失败,如何使用 animate css 类向输入字段添加动画