Te estaba por sugerir algo pero veo que ya lo implementas.
Todo me hace pensar que sms.flush no estan funcionando como piensas.
Investigo y respondo con mas criterio.
Muchas gracias amigo
Pero esa parte de código ya la tengo implementada... Sólo que ya no la pegue jeje me estoy guiando con el ejemplo de GSM recibe mensajes que se encuentra en el IDE de arduino primero tenia problemas porque deseaba hacer comparaciones con el texto del mensaje pero no podía comparar la cadena, realice una agregación para poder guardar el valor que recibe C en un String llamado txtMsgs y ahora que estoy realizando pruebas me doy cuenta que cuando mandas cualquier cadena si te muestra en consola que tu mensaje no es valido pero cuando mandas la cadena correcta que en este caso es "abrir" hace lo que debe de hacer pero le sigue llegando el mensaje infinidad de veces.... Te mando el código completo
Gracias
#include <GSM.h>
//#include <Servo.h>
// PIN Number for the SIM
#define PINNUMBER ""
// initialize the library instances
GSM gsmAccess;
GSM_SMS sms;
// Array to hold the number a SMS is retreived from
char senderNumber[20];
int pinLed1 = 10;
int pinLed2 = 9;
int pausa = 30000;
String txtMsgs = "";
//Servo servoMain;
void setup()
{
// initialize serial communications and wait for port to open:
Serial.begin(9600);
pinMode(pinLed1, OUTPUT);
pinMode(pinLed2, OUTPUT);
//servoMain.attach(13);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("SMS Messages Receiver");
// connection state
boolean notConnected = true;
// Start GSM connection
while(notConnected)
{
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
notConnected = false;
else
{
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("GSM initialized");
Serial.println("Waiting for messages");
}
void loop()
{
char c;
// If there are any SMSs available()
if (sms.available())
{
Serial.println("Message received from:");
// Get remote number
sms.remoteNumber(senderNumber, 20);
Serial.println(senderNumber);
// An example of message disposal
// Any messages starting with # should be discarded
if(sms.peek()=='#')
{
Serial.println("Discarded SMS");
sms.flush();
}
// Read message bytes and print them
while(c=sms.read())
txtMsgs += c;
Serial.print(txtMsgs);
if(txtMsgs == "abrir"){
digitalWrite(pinLed1,HIGH);
digitalWrite(pinLed2,LOW);
// servoMain.write(180);
delay(pausa);
digitalWrite(pinLed1,LOW);
digitalWrite(pinLed2,HIGH);
//servoMain.write(0);
delay(2000);
digitalWrite(pinLed2,LOW);
char txtMsg[200] = "Llave cerrada";
Serial.println("SENDING");
Serial.println();
Serial.println("Message:");
Serial.println(txtMsg);
sms.beginSMS(senderNumber);
sms.print(txtMsg);
sms.endSMS();
Serial.println("\nCOMPLETE!\n");
Serial.println("\nEND OF MESSAGE");
// Delete message from modem memory
sms.flush();
Serial.println("MESSAGE DELETED");
}
else
{
Serial.println("mensaje no valido");
// Delete message from modem memory
sms.flush();
Serial.println("MESSAGE DELETED");
}
txtMsgs = "";
}
delay(1000);
}