HTTP GET with Arduino serial and SIM900 module. Help Please!

Thread Starter

kyotee89

Joined Sep 11, 2019
3
Hi,
Thanks for taking the time to read my post and help me out hopefully : )

I'm trying to send data from my Arduino with a SIM900 module to a http address .php file which will put the data from the http address into a database.
I think my problem is how i'm sending and receiving the serial communication, when i send/receive a long line it gets cut short in the serial monitor. I'm not sure if i'm sending the command short or receiving a short echo in the serial monitor

Here is the function i'm using to read/write to the SIM:

Code:
void printSerialData() {  //send/read the SIM Module
  while(myGsm.available()) { 
  if (myGsm.available()) {
     delay(100);
    String c = myGsm.readString();
       Serial.println(c);
    }
  }
  while (Serial.available()) {
      myGsm.write(Serial.read());
      delay(100);
      }
}
And the code im using to send the commands. It runs once when the board is first turned on.


Code:
void httpConnect() {
 
    myGsm.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\""); // Set Connection to GPRS context
    delay(1000);
    Serial.println(" setting connection type");
    printSerialData();
    myGsm.println("AT+SAPBR=3,1,\"APN\",\"WWW.vodafone.net.nz\""); // Open a GPRS context
    delay(3000);
    printSerialData();
    myGsm.println("AT+SAPBR=1,1"); // Open a GPRS context
    delay(2000);
    printSerialData();
    myGsm.println("AT+SAPBR=2,1");  // To query the GPRS context, check connection status
    delay(1000);
    printSerialData();
    
    myGsm.println("AT+HTTPINIT");                  // Initialize HTTP
    delay(5000);
    printSerialData();
    myGsm.println("AT+HTTPPARA=\"CID\",1");    // End the PARA
    delay(5000);
    printSerialData();
    myGsm.print("AT+HTTPPARA=\"URL\",\"http://nordickindustries.epizy.com/send.php?sen1=5\""); // Send PARA command, set url to send data
    delay(500);
    delay(2000);
    printSerialData();
    delay(2000);
    printSerialData();
    myGsm.println("");   // close url
    Serial.println("");
    delay(5000);
    printSerialData();
    delay(5000);
    myGsm.println("AT+HTTPACTION=0"); //send GET command
    delay(5000);
    printSerialData();
        delay(5000);
    printSerialData();
        delay(5000);
    printSerialData();
    myGsm.println("AT+HTTPREAD");
            delay(5000);
    printSerialData();
        delay(5000);
    printSerialData();
    myGsm.println("AT+HTTPTERM");
    delay(2000);
    printSerialData();     

}
And a screenshot of the serial monitor:

Any help appreciated!!
serialPrintError.png
 
Top