I'm completely new to Arduino, so please forgive me if something I ask here sounds stupid. So I have this Arduino UNO & Arduino compatible GSM-GPRS-GPS Simcomm SIM808 module that I'm working with. I want it to communicate with a Web server, but I can't even get it to start.
Following is my Arduino code:
#include<SoftwareSerial.h>
SoftwareSerial mySerial(2,3);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
mySerial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("Starting GSM...");
mySerial.println("AT");
Serial.println(getResponse());
mySerial.println("AT+CSTT=\"TATA.DOCOMO.INTERNET\",\"\",\"\"");
Serial.println(getResponse());
mySerial.println("AT+CIFSR");
Serial.println(getResponse());
}
String getResponse(){
while(!mySerial.available()>0);
return mySerial.readString();
}
And this is what I'm getting:
Starting GSM...
AT
OK
AT+CSTT="TATA.DGCOMO.INTERNET","",""
ERROR
ÿ
AT+CIFSR
ERROR
Starting GSM...
AT
OK
AT+CSTT="TATA.DOCOMO.INTERNET","",""
ERROR
AT+CIFSR
ERROR
Starting GSM...
AT
OK
AT+CSTT="TATA.DOCOMO.INTERNET","",""
ERROR
AT+CIFSR
ERROR
ÿÿÿÿ
Starting GSM...
AT
OK
ÿ
AT+CSTT="TATA.DOCOMO.INTERNET","",""
ERROR
AT+CIFSR
ERROR
I have no clue why it's happening & why I'm getting those ÿÿ
in the result.
while(!mySerial.available()>0)
will never work reliably; it is doomed to fail on you sooner or later. You must change to parse the response from the modem on a strict line by line basis. If the modem only sends you half a line you should block until the complete line is received. See this answer for details. – hlovdalAT+CMEE=2
, although be aware that sometimes they are not that accurately describing the core problem and must be taken with a grain of salt. – hlovdal