【问题标题】:Seeedstudio SIM900 Arduino GPRS Shield V2.0 does not reply response to terminalSeeedstudio SIM900 Arduino GPRS Shield V2.0 不回复终端响应
【发布时间】:2014-02-05 14:51:07
【问题描述】:

我有 Arduino Leonardo 和 Seeedstudio GPRS Shield v2.0。他们俩都无缝地工作。 按照主 gprs shield link here 的教程,我已成功将以下代码编译到 arduino:

//Serial Relay - Arduino will patch a 
//serial link between the computer and the GPRS Shield
//at 19200 bps 8-N-1
//Computer is connected to Hardware UART
//GPRS Shield is connected to the Software UART 


#include <SoftwareSerial.h>


SoftwareSerial GPRS(7, 8);
unsigned char buffer[64]; // buffer array for data recieve over serial port
int count=0;              // counter for buffer array 
void setup()
{
  GPRS.begin(19200);      // the GPRS baud rate   
  Serial.begin(19200);    // the Serial port of Arduino baud rate.

}

void loop()
{
  if (GPRS.available())            // if date is comming from softwareserial port ==> data is comming from gprs shield
   {
    while(GPRS.available())        // reading data into char array 
    {
      buffer[count++]=GPRS.read(); // writing data into array
      if(count == 64)break;
  }
    Serial.write(buffer,count);    // if no data transmission ends, write buffer to hardware serial port
    clearBufferArray();            // call clearBufferArray function to clear the storaged data from the array
    count = 0;                     // set counter of while loop to zero
  }
  if (Serial.available())          // if data is available on hardwareserial port ==> data is comming from PC or notebook
    GPRS.write(Serial.read());     // write it to the GPRS shield
 }
void clearBufferArray()            // function to clear buffer array
{
  for (int i=0; i<count;i++)
     { buffer[i]=NULL;}            // clear all index of array with command NULL
}

上面的代码将来自串口的 AT 命令作为输入并将其传递给 gprs 模块。所以,我可以输入类似“ATD + +1XXXXXXXX”的代码来呼叫号码,并且它起作用了。问题是我无法从 gprs 模块序列中得到响应,之后它只是空白。我读到对串行终端的响应应该是:“OK”。我的问题是:

一个。有什么我错过的吗?我想将响应写入终端。

b.我想发出http请求,有人有经验怎么做吗?我的意思是这个 gprs 开放网站 blablablabla.com/cs/blabla.php?name=blabla

感谢之前

【问题讨论】:

  • 当您说“ATD + +1XXXXXX”有效时,您所说的“有效”是什么意思?你看到了什么结果?
  • @SList 我没有看到任何回应,我知道它有效,因为我接到了来自 arduino shield 的电话

标签: serial-port arduino at-command gprs arduino-ide


【解决方案1】:

您的 SIM900 可能处于“抑制结果代码”模式。在这种模式下,它根本不会发送诸如“OK”之类的结果代码。

尝试向其发送“ATQ0”命令以使其传输结果代码。 (查看 AT 命令手册中的 ATQ 命令)。

【讨论】:

  • 它不起作用。我尝试发送 ATQ0 并没有得到任何结果,同样的结果。
【解决方案2】:

我绝不是这方面的专家,但是... 在任何时候我都看不到可以打印或显示数据的行。

例子:

假设您在开头建立了类似变量:int inByte=0

喜欢你的buffer[count++]BufferArray(),我有点不熟悉

然后您可以使用

检索数据
Serial.println(inByte); 

GPRS.println(inByte);

这将在您的 COM 端口窗口中显示此信息

所以....? 像

Serial.println(buffer[count++]);

GPRS.println(buffer[count++]); 

两者都会编译 BTW

【讨论】:

    【解决方案3】:

    Leonardo 的 7 针示例不起作用。使用 10 针(需要连接电线而不是跳线)工作正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多