Hi, I just wanna ask about something. Everything is working in our project and nothing was detected error in our codes. But the GSM Module still doesn't send messages to the phone we set the StringNumber to.
Can someone check what is wrong with our programming or if its fine, what to do since it is still not sending messages?
P.S: We are also using the PIR motion sensor in this one.
#include <SoftwareSerial.h>
SoftwareSerial sim(2, 3);
String number = "09661379150";
int motionPin = 2;
int percentValue = 0;
int sensorValue1 = 0;
int sensorValue2 = 0;
int sensorValue3 = 0;
void setup() {
Serial.begin(9600);
delay(5000);
Serial.println("System started...");
sim.begin(9600);
delay(250);
sim.print("AT+CNMI=2,2,0,0,0\r");
delay(1000);
}
void loop() {
readMotion();
delay(300);
}
void thiefMessage()
{
sim.println("AT+CMGF=1");
delay(1000);
sim.println("AT+CMGS=\"+639661379150\"");
delay(1000);
String SMS = "Hi, motion has been detected.";
sim.println(SMS);
delay(100);
sim.println((char)26);
delay(1000);
}
void readMotion()
{sensorValue2 = digitalRead(motionPin);
if (sensorValue2 == 1)
{Serial.println("Hello, motion has been detected.") ;
thiefMessage();
delay(300);}
else if (sensorValue2 == 0);
}
The picture attached is how our project looks like.
