GPRS connection on Sim900a gsm module does not receive any data on GET request


Above is the GSM module I am using with Arduino Uno.

I am trying to establish a GPRS connection and retrieve a web page. This is a test application. In future, I want to post sensor data feed to adafruit.io.
I am able to get an IP address, establish a GPRS connection but sending HTTP GET request does not give me ANYTHING. The serial monitor only says OK.
I tried running code with delay as well as AT commands on serial monitor. I get same result.

/*
  GPRS   
 */

void setup()
{
  Serial.begin(9600);  //Baud rate of the GSM/GPRS Module 
  Serial.flush(); 
  
  Serial.print("\r");
  delay(1000);                  
  
  Serial.print("AT\r");    
  delay(1000);
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println(""); 


  Serial.flush(); 
  Serial.print("AT+CMEE\r");    //checks if GPRS is attached? n=1 if attached
  delay(1000);
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println("");  
  delay(3000); 
  
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println("");  
  delay(3000); 


  
  Serial.flush(); 
  Serial.print("AT+CGMR\r");    //checks if GPRS is attached? n=1 if attached
  delay(1000);
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println("");  
  delay(3000); 

  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println("");  
  delay(3000); 



  Serial.flush(); 
  Serial.print("AT+CGATT?\r");    //checks if GPRS is attached? n=1 if attached
  delay(1000);
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println("");  
  delay(3000); 
  
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println("");  
  delay(3000); 



  Serial.flush(); 
  Serial.print("AT+CSQ=?\r");    
  delay(1000);
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println(""); 
  delay(3000); 
  
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println("");  
  delay(3000); 
  
  Serial.flush(); 




  Serial.flush(); 
  // Set the connection type to GPRS
  Serial.print("AT+SAPBR=3,1,\"Contype\",\"GPRS\"\r"); 
  delay(1000); 
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println(""); 
  delay(3000); 
  
  Serial.flush(); 
  
  // set the APN 
  Serial.print("AT+SAPBR=3,1,\"APN\",\"airtelgprs.com\"\r"); 
  delay(1000); 
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println(""); 
  delay(3000); 

  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println("");  
  delay(3000); 

  Serial.flush(); 

  // Enable the GPRS 
  Serial.print("AT+SAPBR=1,1\r"); 
  delay(1000); 
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println(""); 
  delay(3000); 
  
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println("");  
  delay(3000); 

  Serial.flush(); 

  // Query if the connection is setup properly, if we get back a IP address then we can proceed 
  Serial.print("AT+SAPBR=2,1\r"); 
  delay(1000); 
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println(""); 



  // set up HTTP connection 
  // inititalize 
  Serial.print("AT+HTTPINIT\r"); 
  delay(1000); 
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println(""); 
  delay(3000); 
  
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println("");  
  delay(3000); 


  Serial.print("AT+HTTPSSL=1\r"); 
  delay(1000); 
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println(""); 
  delay(3000); 

  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println("");  
  delay(3000); 


  // Start by setting up the HTTP bearer profile identifier 
  Serial.print("AT+HTTPPARA=\"CID\",1\r"); 
  delay(1000); 
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println(""); 
  delay(3000); 

  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println("");  
  delay(3000); 



  // Set the url  to the address of the webpage you want to access
  //Serial.print("AT+HTTPPARA=\"URL\",\"https://io.adafruit.com/api/v2/philonidhi2000/feeds/\r"); 
  Serial.print("AT+HTTPPARA=\"URL\",\"https://io.adafruit.com/\r"); 
  delay(1000); 
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println(""); 
  delay(3000); 

  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println("");  
  delay(3000); 



  //Start the HTTP GET session, by giving this command 
  Serial.print("AT+HTTPACTION=0\r"); 
  delay(1000); 
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println(""); 
  delay(3000); 

  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println("");  
  delay(3000); 



  //Read the received data 
  Serial.print("AT+HTTPREAD\r"); 
  delay(1000); 
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println(""); 
  delay(3000); 
  
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println("");  
  delay(4000); 

  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println("");  
  delay(5000); 

  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println("");  
  delay(4000); 
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println("");  
  delay(5000); 
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println("");  
  delay(5000); 


  // Terminate HTTP connection 
  Serial.print("AT+HTTPTERM\r"); 
  delay(1000); 
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println(""); 
  delay(3000); 

}

void loop()
{

  
  while(Serial.available()>0) { 
    Serial.print((char)Serial.read()); 
  }
  Serial.println("");  
  delay(4000); 
  Serial.flush(); 
  
}

Output: attachment - it was too long to be pasted here

Sorry for the long output trail. I copied as it was, and omitted the repetitive junk output after this.

Please suggest what I am doing wrong. Thanks in advance

GPRS output.txt (2.09 KB)

  Serial.begin(9600);  //Baud rate of the GSM/GPRS Module
  Serial.flush();

Clearly, you haven't a clue what flush() does. You should NOT use functions that you do not understand.

  Serial.print("\r");
  delay(1000);

Why is it necessary to stuff your head in the sand for a full second? If you are communicating with a device, for ANY reason, read the damned response and move on when you have one (or one does not arrive in a reasonable time, like one second).

  while(Serial.available()>0) {
    Serial.print((char)Serial.read());
  }

It looks like you are using Serial to talk to the GPRS AND to talk to the PC. That will NOT work. Why are you sending AT command AND other crap to the modem?