2014-02-05 40 views
1

我有Arduino Leonardo和Seeedstudio GPRS Shield v2.0。他們兩人都無縫工作。 上主要GPRS以下教程屏蔽link here,我已經成功地編譯下面的代碼的Arduino:Seeedstudio SIM900 Arduino GPRS盾V2.0不回覆終端的迴應

//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」。我的問題是:

a。有什麼我錯過了嗎?我想得到回覆寫入終端。

灣我想提出http請求,有人有經驗如何做?我的意思是這GPRS打開網站blablablabla.com/cs/blabla.php?name=blabla這是

THX前

+0

當你說「ATD + + 1XXXXXX」工作時,「工作」是什麼意思?你看到了什麼結果? –

+0

@SList我沒有看到任何迴應,我知道它工作,因爲我從arduino盾 – wrez

回答

0

可能是您的SIM900是「禁止結果代碼」模式。在此模式下,它不會發送結果代碼,如「OK」。

嘗試發送一個「ATQ0」命令讓它發送結果代碼。 (查看AT命令手冊中的ATQ命令)。

+0

打電話它不起作用。我試着發送ATQ0並沒有得到任何結果。 – wrez

0

我決不是這方面的專家,但... 在任何時候我都看不到一行會打印或顯示數據。

例子:

假設你建立像一個變量:int inByte=0之初

喜歡你buffer[count++]BufferArray(),這我有點陌生

,那麼你可以通過檢索數據使用

Serial.println(inByte); 

GPRS.println(inByte); 

這將在您的COM端口窗口中顯示此信息

所以....? 像

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

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

這兩者將編譯BTW

0

例子7針與萊昂納多不工作。用10針(需要連接導線代替跳線)工作正常。