robotmotion.gr
In this little article I will present a homemade GSM enabled alarm system. The main idea behind this project was to build an alarm system that will place a phone call each time an intruder is detected within range of the system. The reason I prefer the phone call instead of sending a SMS, is that the phone call is not charged if the other side rejects it, and also there are less chances to miss the notification during the event.
Requirements:
1.Low cost design with surplus components
2.Battery powered (from a 12V 7Ah lead acid)
3.Easy to reprogram it at the field. (reprogram the target phone number, system parameters, etc)
To keep the cost down, I used an old Ericsson T10s mobile phone for its GSM module. I soldered cables on its serial port (pinout was found on the net) and on the battery terminals. Before using it for the project, I made sure that it can be turned on by keeping the ON/OFF button always pressed (soldered) and applying +5V power supply on its battery terminals.
For the controller of the system, I chose the Arduino platform. Instead of allocating one of my arduino boards, I built the minimum required hardware of the arduino platform on a prototyping board. The motion detect sensor can be found in hardware shops as a stand alone gadget. It usually comes with a small speaker and gives an audible sound whenever motion is detected. My sensor was 9v operated, but was working fine with 5v, producing a TTL level compatible waveform on the speaker. After some scoping I noticed that while the motion sensor is idle, the signal on the speaker is logic ‘high’. When an event takes place, there is a series of active low pulses. This piece of information was used to program the event detection in the arduino.
In the figure below you can see the box containing the system.

As you can see, the mobile phone is secured in the box with hot glue. There is access to the SIM card though. The microcontroller used was the ATMEGA328 with Arduino bootloader burned via the ISP connector. You can have a close look of the board below

The board features a small 12v to 5v power supply based on a common 7805 voltage regulator. The microcontroller and 16MHz crystal, an ISP (DIL8) header, and a four pin header for serial connection (Arduino programming and debugging.). There is also a green led which is used to indicate when the GSM modem is ready to place a call, so the system is considered ‘armed’.
There are two cables leaving the main box. One is the power supply and the other goes to the motion sensor module. The motion sensor was relieved from unwanted parts like battery compartment and speaker, and after attaching the power and signal cable, it was promoted to a waterproof design with a lot of hot glue. See images below.
Hot glue was also applied to its sound selection switch, and around the IR lens in order to close every gap of the plastic enclosure.


I will not go into details about the arduino firmware since the project is pretty simple and straight forward. I think the most interesting part of the firmware is the reliable parsing of the GSM modem responses. The serial link between the arduino board and the GSM serial port was established with the NewSoftSerial library. I will just paste a snippet of the code which reads the modem responses.
if(cell.available() > 0)
{
incoming_char=cell.read(); //Get the character from the cellular serial port.
//Serial.print(incoming_char); //debugging. Print the incoming character to the terminal.
buf[index] = incoming_char; //store the character in our buffer
index++; //a pointer for our buffer
//check the last bytes to see if they form the ‘OK’ response
if((buf[index-4]==0x4F)&&(buf[index-3]==0x4B)&&(buf[index-2]==0x0D)&&(buf[index-1]==0x0A)){
//we got the ‘OK’ response from the module
buf[index] = '\0'; //close the string
//debug
//Serial.println("");
//for(i=0;i<index;i++) Serial.println((int)buf[i]);
//Serial.println("");
//Serial.print(buf);
//ends
//check for complete modem response, including the part before the ‘OK’
if(strcmp(buf,"AT+CREG?\r\r\n+CREG: 0,5\r\n\r\nOK\r\n") == 0){
state = INIT_OK;
Serial.println("");
Serial.println("Debug: Module Came online going to INIT_OK");
Serial.println("");
digitalWrite(13,HIGH);
}
else{
state = NO_INIT;
Serial.println("");
Serial.println("Debug: going to NO_INIT again");
Serial.println("");
}
index = 0;
}
}
05/09/2011
GSM motion detect alarm system