Good evening to all, I ask for help to the people of Arduino because I'm trying something new and I do not know how to do it...
I'm using an Arduino Mega 2560 and the Sim800L module, I found a code that allows me to view the messages I send him on the serial monitor. So far so good, my problem is how to save this word in a variable that I can use later in my code. Let me explain better, I would like to send them like turn on and off and turn on and off a LED, I know that there are examples on the internet but I would like to avoid libraries already made. I want to use the command String Comparison Operators only that I have to save the string received somewhere ...
Attached I put my code and what I read in the serial, I hope I explained well ...
void setup()
{
//Begin serial communication with Arduino and Arduino IDE (Serial Monitor)
Serial.begin(9600);
//Begin serial communication with Arduino and SIM800L
Serial1.begin(9600);
Serial.println("Initializing...");
delay(1000);
Serial1.println("AT"); //Once the handshake test is successful, it will back to OK
updateSerial();
Serial1.println("AT+CMGF=1"); // Configuring TEXT mode
updateSerial();
Serial1.println("AT+CNMI=1,2,0,0,0"); // Decides how newly arrived SMS messages should be handled
updateSerial();
}
void loop()
{
updateSerial();
}
void updateSerial()
{
delay(500);
while (Serial.available())
{
Serial1.write(Serial.read());//Forward what Serial received to Software Serial Port
}
while(Serial1.available())
{
Serial.write(Serial1.read());//Forward what Software Serial received to Serial Port
}
}
Initializing...
AT
OK
AT+CMGF=1
OK
AT+CNMI=1,2,0,0,0
OK
+CMT: "+41762957962","","19/08/07,20:19:36+08"
On