I'm having trouble saving an SMS message to a variable. The idea is to send an SMS with a command and later use a conditional operator to activate or deactivate a relay.
But I can not save the SMS message. Whenever I try to save it, it assumes the value of:
" ÿ "
.
I'm using a sim900 GSM module with Arduino.
Here is the code I'm trying to use:
#include <SoftwareSerial.h>
SoftwareSerial cell(2,3);
void setup()
{
cell.begin(19200);
cell.println("AT+CMGF=1");
delay(200);
cell.println("AT+CNMI=3,2,0,0");
delay(200);
}
void loop()
{
if(cell.available() >0) // se o shild resceber uma msg
{
delay(10);
msg=cell.read(); // salve ela na variavel msg
Serial.println(msg);// mostra o valor do "msg" NESSE ponto ela esta valendo ÿ
if (msg=='a') // se o primeiro caracter for "a"
{
delay(10);
msg=cell.read();
if (msg=='0') // se o segundo caracter for "0"
{
delay(10);
msg=cell.read();
if (msg=='e') // se o terceiro caracter for "e"
{
}
}
}
}
}
When I print the message on the serial, its value is ÿ
, why this?
I researched and found that before telling Arduino to store the SMS, we have to tell him to "listen" to the serial that receives the message and this is related to:
gsm.listen();
But I did not understand the relationship very well.