Sim, claro. Obrigada pela ajuda.
Ele encaixa sobre o Arduino mas tirei as duas perninhas do TX e RX e liguei elas por fio no 16 e 17.
Ele envia certinho mensagem para o celular. Mas o shield não está enviando a resposta dos comandos para o Arduino, o buffer da porta permanece vazio o tempo todo. Coloquei para imprimir todas as portas para saber em qual ela responde.
void setup()
{
Serial.begin(9600); //set the baud rate
Serial2.begin(115200); //set the baud rate
Serial3.begin(115200); //set the baud rate
Serial1.begin(115200); //set the baud rate
digitalWrite(5,HIGH);//Output GSM Timing
delay(1000);
digitalWrite(5,LOW);
delay(1500);
digitalWrite(3,LOW);//Output GSM Timing
delay(1500);
digitalWrite(4,HIGH);
delay(1500);
}
void loop()
{
uint8_t answer=0;
Serial3.print(“AT\r\n”); //Send AT command
delay(200);
Serial.println(Serial3.available());
Serial.println(Serial2.available());
Serial.println(Serial1.available());
Serial.println(Serial.available());
Serial.println("\n\n");
Serial.println(Serial.read());
Serial.println(Serial1.read());
Serial.println(Serial2.read());
Serial.println(Serial3.read());
Serial.println(“Comecando…”);
answer = sendATcommand(“AT”, “OK”, 5000);
while(answer == 0){
//Send AT every five(cymk0) seconds and wait for the answer
answer = sendATcommand(“AT”, “OK”, 5000);
Serial.println(answer);
}
delay(5000);
Serial3.println(“AT+CMGF=1”);
delay(2000);
Serial3.println(“AT+CMGS=”"");//Change the receiver phone number
delay(1000);
Serial3.println(“Me avisa se receber essa msg baaa”);//the message you want to send
delay(1000);
Serial3.write(26);
Serial.println(“Me avisa se receber essa msg baaa”);//the message you want to send
}
int8_t sendATcommand(char* ATcommand, char* expected_answer1, unsigned int timeout){
uint8_t x=0, answer=0;
char response1[100];
char response2[100];
char response3[100];
unsigned long previous;
memset(response1, ‘\0’, 100); // Initialize the string
memset(response2, ‘\0’, 100);
memset(response3, ‘\0’, 100);
delay(100);
while( Serial1.available() > 0) Serial1.read(); // Clean the input buffer
while( Serial2.available() > 0) Serial2.read();
while( Serial3.available() > 0) Serial3.read();
Serial2.println(ATcommand); // Send the AT command
Serial3.println(“AT”);
Serial.println(“mandei o comando”);
Serial.println(Serial3.available());
Serial.println(Serial2.available());
Serial.println(Serial1.available());
Serial.println(Serial.available());
x = 0;
previous = millis();
// this loop waits for the answer
do {
//Serial.println(Serial3.available());
if(Serial1.available() != 0){
response1 = Serial1.read();
//Serial.println(response);
x++;
// check if the desired answer is in the response of the module
if (strstr(response1, expected_answer1) != NULL)
{
answer = 1;
}
}
if(Serial2.available() != 0){
response2 = Serial2.read();
//Serial.println(response);
x++;
// check if the desired answer is in the response of the module
if (strstr(response2, expected_answer1) != NULL)
{
answer = 1;
}
}
if(Serial3.available() != 0){
response3 = Serial3.read();
x++;
// check if the desired answer is in the response of the module
if (strstr(response3, expected_answer1) != NULL)
{
answer = 1;
}
}
// Waits for the asnwer with time out
} while((answer == 0) && ((millis() - previous) < timeout));
Serial.println(response1);
Serial.println(response2);
Serial.println(response3);
return answer;
}