No response from AT commands on Elecrow Leonardo GPRS GSM IOT Board-V1.2
Hello everyone! I have a problem: every AT command I execute gives me no response (in function sendData Serial1 is always unavailable, so program does not enter in loop that reads response from Serial1). This problem occurs with plugged and unplugged sim card. Lately it worked, but then, after no special manipulations with code or arduino, it makes this problem. Maybe I should update firmware? If yes, how I can update that? (I have found no information on official site of Elecrow)
#define DEBUG 1
#define CHECK Serial.println("✓");
void setup()
{
//GSM.begin(9600);
Serial.begin(9600);
Serial1.begin(9600);
while(!Serial);
// while(!Serial1);
Serial.println(" -- Program start -- ");
Serial.println("Serial initialization... ✓");
Serial.print("Serial1 initialization... ");
while(!Serial1.availableForWrite());
CHECK
Serial.println("AT commands initialization... ");
sendData("AT",2000);
Serial.println("HTTP initialization... ");
sendData("AT+HTTPINIT",2000);
Serial.println("HTTP parameters setting... ");
sendData("AT+HTTPPARA="CID", 1",2000);
sendData("AT+HTTPPARA="URL", "http://www.iforce2d.net/test.php/"",2000);
sendData("AT+HTTPPARA?",2000);
Serial.println(" -- Get start -- ");
sendData("AT+HTTPACTION=0",2000);
sendData("AT+HTTPACTION=0",2000);
sendData("AT+HTTPACTION=0",2000);
}
void loop() {
}
void sendData(String command, const int timeout) //Send command function
{
String response = "";
Serial1.println(command);
long int time = millis();
while( (time+timeout) > millis()){
while(Serial1.available()){
response += (char)Serial1.read();
Serial.println(1);
}
}
if(DEBUG){
Serial.println();
Serial.print(response);
CHECK
Serial.println();
}
}
I have tried to change delay/timeout of sending commands, baud rate and time to wait until Serial1 will be available.