Hi all.
I’m working on this door lock at home where I would want to be able to send an SMS containing a password and have it open the lock if the password is correct.
I really don’t know how to go about this despite going through the forum and other projects on the web.
I have tried out commands and gotten responses using a terminal.
I have also been able to successfully send and receive messages and display them in the serial monitor.
Please I need some help.
I am using an Arduino Uno and the GSM module is a SIM800l.
Also, later in this device, I’d want to be able to reply a message (say a confirmation) to the number that sent the text as opposed to hard-coding the phone number into the program.
This would come later but any help on it will be appreciated.
Here is the code for receiving and displaying SMS.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(3, 2);
void setup()
{
Serial.begin(9600);
mySerial.begin(9600);
Serial.println("Starting...");
delay(1000);
mySerial.println("AT");
pollSms();
mySerial.println("AT+CMGF=1");
pollSms();
mySerial.println("AT+CNMI=1,2,0,0,0");
pollSms();
}
void loop()
{
pollSms();
}
void pollSms()
{
delay(500);
while (Serial.available())
{
mySerial.write(Serial.read());
}
while (mySerial.available())
{
Serial.write(mySerial.read());
}
}
//This is the later feature I'll add
//It's just hanging here for now
/* void reply()
{
Serial.print("AT+CMGS=\"+ZZXXXXXXXXXX\"\r"); //I have replaced the number with these x's
delay(1000);
//The text of the message to be sent.
Serial.print("Command Successful! Door unlocked.");
delay(1000);
Serial.write(0x1A);
delay(1000);
}
*/