Hello everyone. Arduino beginner here.
I got the basic's down but when it get's to the more advanced stuff, i get stuck, cause i never studied code,
so i don't really know how it work's or why it sometimes does not. Everything i know about it is from the arduino tutorial's I've been watching.
Anyway, here is the problem I'm facing:
I hooked up a GSM module up to my arduino. And it work's fine, i can make calls, send / receive messages and so on.
However i can't make the arduino do something when it receives a certain sms.
And that mainly comes from the fact that i don't know how to make the arduino understand when it received a certain String.
Meaning:
Using this code that i found on the internet:
#include <SoftwareSerial.h>
//Create software serial object to communicate with SIM800L
SoftwareSerial mySerial(7, 8); //SIM800L Tx & Rx is connected to Arduino #7 & #8
void setup()
{
//Begin serial communication with Arduino and Arduino IDE (Serial Monitor)
Serial.begin(9600);
//Begin serial communication with Arduino and SIM800L
mySerial.begin(9600);
Serial.println("Initializing...");
delay(1000);
mySerial.println("AT"); //Once the handshake test is successful, it will back to OK
updateSerial();
mySerial.println("AT+CMGF=1"); // Configuring TEXT mode
updateSerial();
mySerial.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())
{
mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port
}
while(mySerial.available())
{
Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
}
}
when the GSM module receives an SMS that says "ON".
The serial monitor basically writes it out like this:
+CMT: "+zzxxxxxxxxxx","","20/04/16,20:25:43+08"
ON
The +zzxxxxxxxxxx is my number, but thats irelevant.
Question is, how do i make the arduino understand that it recieved the word "ON" based on that Serial.read.
Or to rephrase my question, how do i make the arduino check to see if the Serial.read contains the word
"ON".
Also I am not looking for a piece of code that i can copy>paste into my sketch, i want to understand the code. So if you have an idea, please post the code with //comment's so i can understand what it actually does.
Thank you for all your replies in advance ! ![]()