【发布时间】: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