0

如何使用 arduino 和 sim900 模块打开网页我即将使用 gsm sim 900 模块打开网页我尝试使用此代码我不熟悉 AT 命令,因此此代码仅显示为对代码中的代码的响应串行监视器,它没有打开页面,所以请你帮帮我!

     #include <SoftwareSerial.h>
 SoftwareSerial SIM900(2, 3); // configure software serial port
void setup() {
 SIM900.begin(19200);
 SIM900power();  
Serial.begin(19200); 
Serial.print("power up" );
delay(20000); 
   SIM900.println("AT+CSQ"); // Signal quality check
delay(100);
  ShowSerialData();// this code is to show the data from gprs shield, in         order to easily see the process of how the gprs shield submit a http request, and the following is for this purpose too.
  SIM900.println("AT+CGATT?"); //Attach or Detach from GPRS Support
   delay(100);
 ShowSerialData();
 SIM900.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");//setting the SAPBR,       the connection type is using gprs
delay(1000);
ShowSerialData();
SIM900.println("AT+SAPBR=3,1,\"APN\",\"etisalat\"");//setting the APN, Access point name string
delay(4000)
  ShowSerialData();
 SIM900.println("AT+SAPBR=1,1");//setting the SAPBR
 delay(2000);
 ShowSerialData();
 SIM900.println("AT+HTTPINIT"); //init the HTTP request
 delay(2000); 
 ShowSerialData();           SIM900.println("AT+CIPSTART=\"TCP\",\"http://http://www.google.com\",\"80\""); 
  delay(1000);
ShowSerialData();
 SIM900.println("AT+CIPSHUT"); //init the HTTP request
delay(2000); 
ShowSerialData();
SIM900.println("AT+HTTPACTION=0");//submit the request 
delay(10000);//the delay is very important, the delay time is base on the return from the website, if the return datas are very large, the time required longer.
   while(!SIM900.available());
 ShowSerialData();
 SIM900.println("AT+HTTPREAD");// read the data from the website you access
 delay(300);
  ShowSerialData();
 SIM900.println("");
 delay(100);
   }
 void SIM900power()
  // software equivalent of pressing the GSM shield "power" button
  {
 digitalWrite(9, HIGH);
  delay(1000);
  }
  void loop()
     {
     // Serial.println("SubmitHttpRequest - started" );
   //  SubmitHttpRequest();
   // Serial.println("SubmitHttpRequest - finished" );
     }
 void SubmitHttpRequest()
   {
     }
  void ShowSerialData()
{
   while(SIM900.available()!=0)
   Serial.write(char (SIM900.read()));
  }
4

1 回答 1

0

您能否发布您从本次通信中获得的 SERIAL 日志?

这是通过 HTTP 查询的正常设置:

检查网络中是否有注册

AT+CREG?

检查您是否连接到网络

AT+CGATT?

设置承载配置文件1(看看是否设置了有效IP)

AT+SAPBR=3,1,"Contype","GPRS"
AT+SAPBR=3,1,"APN","APNdirection"
AT+SAPBR=3,1,"USER","APNuser"
AT+SAPBR=3,1,"PWD","APNpassword"
AT+SAPBR=2,1
AT+SAPBR=1,1

启动 HTTP

AT+HTTPINIT

选择承载 1

AT+HTTPPARA="CID",1

设置你要请求的网址

AT+HTTPPARA="URL","google.com"

启动 GET 操作

AT+HTTPACTION=0

读完就读

AT+HTTPREAD

终止 HTTP

AT+HTTPTERM
于 2016-06-30T13:55:22.897 回答