0

how to open a webpage using arduino and sim900 module I am about to open a webpage using gsm sim 900 module I tried using this code I am not familiar with the AT commands so this code is only show ok as a response to the code in the serial monitor and it doesn't open the page so can you help me please!

     #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()));
  }
nemo nemo
  • 11
  • 5

1 Answers1

0

Can you please post the SERIAL log you get from this communication?

This is the normal set-up to query via HTTP:

Check if there is registration in the network

AT+CREG?

Check if you are attached to the network

AT+CGATT?

Set the bearer profile 1 (take a look if it sets a valid 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

Start HTTP

AT+HTTPINIT

Select bearer 1

AT+HTTPPARA="CID",1

Set the URL you want to request

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

Start the GET action

AT+HTTPACTION=0

Read once it has finished

AT+HTTPREAD

Terminate HTTP

AT+HTTPTERM
Federico
  • 55
  • 1
  • 7