Arduino Sim900,无回声,但发送了短信 [英] Arduino Sim900 with no echo but SMS was sent out

查看:123
本文介绍了Arduino Sim900,无回声,但发送了短信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚得到一个新的Sim900并连接到Arduino Uno.我使用下面的代码向自己发送了文本.我在单元格上收到了文本,但在串行监视器上没有收到任何回声(即确定").我尝试过交换RX/TX引脚和不同的波特率,但没有成功.

I just got a new Sim900 and connected to an Arduino Uno. I used the code below to send a text to myself. I received the text on my cell, but I did not receive any echo on my serial monitor (ie. "OK"). I have tried swapping the RX/TX pins and different baud rates with no success.

void setup()
{
  Serial.begin(9600);  //Baud rate of the GSM/GPRS Module 
  Serial.println("");
  delay(2000);                  
  Serial.println("AT+CMGF=1");    
  delay(1000);
  Serial.println("AT+CMGS=\"+120########\"");    //Number to which you want to send the sms
  delay(1000);
  Serial.print("This is a test.");   //The text of the message to be sent
  delay(1000);
  Serial.write(0x1A); // send CTRL - z to end message
  Serial.write(0x0D); // Carriage Return
  Serial.write(0x0A); // Line Feed
  delay(5000); 
 }

void loop()
{
}

推荐答案

正如@hlovdal所说,在消息之间使用延迟是一个坏主意.您必须等待每个命令的答案并根据答案采取措施(或因为超时).

As @hlovdal says, using delay between messages is a bad idea. You have to wait the answer of each command and take actions depending on the answer (or because a timeout).

假设这就是您的全部代码,那么您将跳过读取串行端口的部分.就像执行serial.write一样,您必须使用serial.read来获取传入的字符.也许这是原因,因为您什么都没收到.

Assuming that that's all your code, you're are skipping the part of reading the serial port. Just like you do serial.write, you have to use serial.read to get the incoming characters. Maybe this is the reason because you're not receiving anything.

最后,Arduino UNO有一个UART端口,因此,如果要使用串行监视器进行调试,则必须使用SoftwareSerial与SIM900进行通信.

Finally, Arduino UNO's got one UART port, so if you want to have a serial monitor for debugging, you'll have to use SoftwareSerial to communicate with the SIM900.

这篇关于Arduino Sim900,无回声,但发送了短信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆