Hello. I am new to GSM as well as writing code. I created a similar project using two Uno boards+RF modules+PIR sensor to activate an LED & buzzer when the PIR sensor detected motion. Now I'm trying to create a similar project using a Uno+GSM shield+PIR sensor to send a text message to my phone when motion is detected by the sensor. I successfully sent and received texts between the board and phone via serial monitor, so I know the shield is working properly. But the code that I am using is not working:
#include <GSM.h>
#include <SIM900.h>
#include <sms.h>
#include <SoftwareSerial.h>
SoftwareSerial GPRS(7, 8); // RX, TX pins
void setup() {
pinMode(5, INPUT); // Our PIR sensor
Serial.begin(9600); // Open serial connection at baud rate of 9600
}
void loop(){
if (digitalRead(5) == HIGH){ // PIR sensor detects motion
digitalWrite(13, HIGH); // Turn LED on.
Serial.println("AT"); // Sends AT command to wake up gsm shield
delay(500);
Serial.println("AT+CMGF=1"); // Puts gsm shield into SMS mode
delay(1000); // Wait a second
Serial.println("AT+CMGS=\"+1xxxxxxxxxx\""); // YOUR NUMBER HERE; Creates new message to number
delay(1000);
Serial.print("Motion Detected."); // Message contents
delay(1000);
Serial.write(byte(26)); // (signals end of message)
delay(1000);
Serial.println("AT+CMSS=1"); // Sends message at index of 1
digitalWrite(13, LOW); // Turn LED off
delay(250);
digitalWrite(13, HIGH); // Turn LED on.
delay(10000); // Give the gsm shield time to send the SMS
Serial.println("AT+CMGD=1"); // Deletes message at index of 1
digitalWrite(13, LOW); // Turn LED off.
delay(250);
}
}
When the sensor detects motion, the green transmit light on the shield does not flash indicating that it is transmitting the text. The board is powered by the A/C adaptor. Am I using/missing the correct libraries? Wrong pins? Wrong AT commands? Or is my code completely wrong? I have tried for four days trying to figure this out but GSM is new to me, and any help would be appreciated. Thanks in advance.