Sending a message with the GPRS Shield v1.4

In my high school engineering class, my group and I are designing a product that will send a text message to the user’s phone when a smoke detector goes off. Here is how it works: Two sides of a resistor in the smoke detector are connected to ports A1 and A2 on the Arduino. Once the difference between the two values coming into the ports is less than -75 or greater than 75, the Arduino will turn on the GPRS shield, and have it send a message to a specified number. The device is meant to stand alone. As such, the AT commands are written into Arduino IDE, not sent through serial terminal software. To this point, I have not been successful in doing this. I would like to know what it is I am doing wrong. The code is based off sample code found in the GPRS Shield v1.0 wiki. It also includes code to smooth the values coming into the Arduino. Here is the code:

[code]#include <SoftwareSerial.h>

SoftwareSerial GPRS(7, 8);
unsigned char buffer[64]; // buffer array for data recieve over serial port
int count=0; // counter for buffer array
int analogPin1 = 1; // potentiometer wiper (middle terminal) connected to analog pin 3
// outside leads to ground and +5V
int val1 = 0; // variable to store the value read

int analogPin2 = 2; // potentiometer wiper (middle terminal) connected to analog pin 3
// outside leads to ground and +5V
int val2 = 0;

int val = 0;
const int numReadings = 10;

int readings[numReadings]; // the readings from the analog input
int index = 0; // the index of the current reading
int total = 0; // the running total
int average = 0; // the average

void setup()
{
pinMode(9, OUTPUT);
GPRS.begin(19200); // the GPRS baud rate
Serial.begin(19200); // the Serial port of Arduino baud rate.
}

//Serial Relay - Arduino will patch a
//serial link between the computer and the GPRS Shield
//at 19200 bps 8-N-1
//Computer is connected to Hardware UART
//GPRS Shield is connected to the Software UART

void loop()
{
val1 = analogRead(analogPin2); // read the input pin
val2 = analogRead(analogPin1);
val = val2-val1;
// subtract the last reading:
total= total - readings[index];
// read from the sensor:
readings[index] = val;
// add the reading to the total:
total= total + readings[index];
// advance to the next position in the array:
index = index + 1;

// if we’re at the end of the array…
if (index >= numReadings)
// …wrap around to the beginning:
index = 0;

// calculate the average:
average = total / numReadings;
// send it to the computer as ASCII digits

if (val>=75 || val<=-75)
{
digitalWrite(9, HIGH);
delay(250);
Serial.println(“AT+CMGF=1”); //Because we want to send the SMS in text mode
//delay(100);
Serial.println("AT + CMGS = “12055422784"”);//send sms message, be careful need to add a country code before the cellphone number
//delay(100);
Serial.println(“Your house is on fire!”);//the content of the message
//delay(100);
Serial.write(0x1A);
//delay(100);

}

if (val<75 || val>-75)
{
digitalWrite(9, LOW);
}

if (Serial.available()) // if data is available on hardwareserial port ==> data is comming from PC or notebook
GPRS.write(Serial.read()); // write it to the GPRS shield

if (GPRS.available()) // if date is comming from softwareserial port ==> data is comming from gprs shield
{
while(GPRS.available()) // reading data into char array
{
buffer[count++]=GPRS.read(); // writing data into array
if(count == 64)break;
}
Serial.write(buffer,count); // if no data transmission ends, write buffer to hardware serial port
clearBufferArray(); // call clearBufferArray function to clear the storaged data from the array
count = 0; // set counter of while loop to zero
}

}

void clearBufferArray() // function to clear buffer array
{
for (int i=0; i<count;i++)
{ buffer[i]=NULL;} // clear all index of array with command NULL
}[/code]

Hi Athopay,
Have you soldered the jumper pad named JP?
If this jumper not be soldered, you can not start GPRS shield via digital PIN 9.
I noticed your code, in line 64, start/stop GPRS shield is a high pluse throught PIN9, not a still high/low signal. I suggest you delay 1000ms then set pin 9 to low.
Another suggestions is you should delay at least 5 seconds or more to wait the module make a stable connected to the network then begin to sent a message.
In line 66, the AT command should be sent via sofe serial port but Serial.print (this is hard serial port)
see below:

 GPRS.println("AT+CMGF=1");    //Because we want to send the SMS in text mode
 delay(100);
 GPRS.println("AT + CMGS = \"12055422784\"");//send sms message, be careful need to add a country code before the cellphone number
 delay(100);
 GPRS.println("Your house is on fire!");//the content of the message
 delay(100);
 GPRS.println((char)26);
 delay(100);
 GPRS.println();