GPS/GPRS/GSM Module V3.0 part of my project.

Hello everyone
Soon there will be IT competition where i want to show my device. It will be with functions for SMS control, GPS real time information sent via SMS, PIR motion sensor,3 axis accelerometer and relay. The idea is that this device will start and take information when something happens like, activated from PIR sensor or moved and detected by accelerometer. Then will send SMS with coordinates and the reason why its activated. That if arduino didn't receive any command, after time e.g 10 minutes will launched relay.
I have this stuff:
Arduino Uno
GPS/GPRS/GSM Module V3.0
PIR motion sensor
AC Adaptor 9V - 800mA 7.2VA
I tried this program code:
Code: Select all// Product name: GPS/GPRS/GSM Module V3.0 // # Product SKU : TEL0051 // # Version : 1.2 // # Description: // # The sketch for driving the gps mode via the Arduino board // # Steps: // # 1. Turn the S1 switch to the Prog(right side) // # 2. Turn the S2 switch to the Arduino side(left side) // # 3. Set the UART select switch to middle one. // # 4. Upload the sketch to the Arduino board // # 5. Turn the S1 switch to the comm(left side) // # 6. RST the board // # If you get 'inf' values, go outdoors and wait until it is connected. // # wiki link- http://www.dfrobot.com/wiki/index.php/GPS/GPRS/GSM_Module_V3.0_(SKU:TEL0051) double Datatransfer(char *data_buf,char num)//convert the data to the float type { //*data_buf?the data array double temp=0.0; //the number of the right of a decimal point unsigned char i,j; if(data_buf[0]=='-') { i=1; //process the data array while(data_buf[i]!='.') temp=temp*10+(data_buf[i++]-0x30); for(j=0;j<num;j++) temp=temp*10+(data_buf[++i]-0x30); //convert the int type to the float type for(j=0;j<num;j++) temp=temp/10; //convert to the negative numbe temp=0-temp; } else//for the positive number { i=0; while(data_buf[i]!='.') temp=temp*10+(data_buf[i++]-0x30); for(j=0;j<num;j++) temp=temp*10+(data_buf[++i]-0x30); for(j=0;j<num;j++) temp=temp/10 ; } return temp; } char ID()//Match the ID commands { char i=0; char value[6]={ '$','G','P','G','G','A' };//match the gps protocol char val[6]={ '0','0','0','0','0','0' }; while(1) { if(Serial.available()) { val[i] = Serial.read();//get the data from the serial interface if(val[i]==value[i]) //Match the protocol { i++; if(i==6) { i=0; return 1;//break out after get the command } } else i=0; } } } void comma(char num)//get ',' { char val; char count=0;//count the number of ',' while(1) { if(Serial.available()) { val = Serial.read(); if(val==',') count++; } if(count==num)//if the command is right, run return return; } } void UTC()//get the UTC data -- the time { char i; char time[9]={ '0','0','0','0','0','0','0','0','0' }; double t=0.0; if( ID())//check ID { comma(1);//remove 1 ',' //get the datas after headers while(1) { if(Serial.available()) { time[i] = Serial.read(); i++; } if(i==9) { i=0; t=Datatransfer(time,2);//convert data t=t-30000.00;//convert to the chinese time GMT+8 Time zone long time=t; int h=time/10000; int m=(time/100)%100; int s=time%100; // if(h>=24) //UTC+ // { // h-=24; // } if (h<0) //UTC- { h+=24; } Serial.print(h); Serial.print("h"); Serial.print(m); Serial.print("m"); Serial.print(s); Serial.println("s"); //Serial.println(t);//Print data return; } } } } void latitude()//get latitude { char i; char lat[10]={ '0','0','0','0','0','0','0','0','0','0' }; if( ID()) { comma(2); while(1) { if(Serial.available()) { lat[i] = Serial.read(); i++; } if(i==10) { i=0; Serial.println(Datatransfer(lat,5)/100.0,7);//print latitude return; } } } } void lat_dir()//get dimensions { char i=0,val; if( ID()) { comma(3); while(1) { if(Serial.available()) { val = Serial.read(); Serial.write(val); Serial.println(); i++; } if(i==1) { i=0; return; } } } } void longitude()//get longitude { char i; char lon[11]={ '0','0','0','0','0','0','0','0','0','0','0' }; if( ID()) { comma(4); while(1) { if(Serial.available()) { lon[i] = Serial.read(); i++; } if(i==11) { i=0; Serial.println(Datatransfer(lon,5)/100.0,7); return; } } } } void lon_dir()//get direction data { char i=0,val; if( ID()) { comma(5); while(1) { if(Serial.available()) { val = Serial.read(); Serial.write(val); //Serial.println(val,BYTE); Serial.println(); i++; } if(i==1) { i=0; return; } } } } void altitude()//get altitude data { char i,flag=0; char alt[8]={ '0','0','0','0','0','0','0','0' }; if( ID()) { comma(9); while(1) { if(Serial.available()) { alt[i] = Serial.read(); if(alt[i]==',') flag=1; else i++; } if(flag) { i=0; Serial.println(Datatransfer(alt,1),1);//print altitude data return; } } } } void setup() { pinMode(3,OUTPUT);//The default digital driver pins for the GSM and GPS mode pinMode(4,OUTPUT); pinMode(5,OUTPUT); digitalWrite(5,HIGH); delay(1500); digitalWrite(5,LOW); digitalWrite(3,LOW);//Enable GSM mode digitalWrite(4,HIGH);//Disable GPS mode delay(2000); Serial.begin(9600); delay(5000);//GPS ready Serial.println("AT"); delay(2000); //turn on GPS power supply Serial.println("AT+CGPSPWR=1"); delay(1000); //reset GPS in autonomy mode Serial.println("AT+CGPSRST=1"); delay(1000); digitalWrite(4,LOW);//Enable GPS mode digitalWrite(3,HIGH);//Disable GSM mode delay(2000); Serial.println("$GPGGA statement information: "); } void loop() { while(1) { Serial.print("UTC:"); UTC(); Serial.print("Lat:"); latitude(); Serial.print("Dir:"); lat_dir(); Serial.print("Lon:"); longitude(); Serial.print("Dir:"); lon_dir(); Serial.print("Alt:"); altitude(); Serial.println(' '); Serial.println(' '); } }
but when i open Serial Monitor i receive only:
"AT"
"AT+CGPSPWR=1"
"AT+CGPSRST=1"
"$GPGGA statement information: "
"UTC:"
and thats it, nothing more. I know that GPS must be outdoor but i don't get 'inf' values. So I am new to developing with Arduino, and stuff like this so if someone can direct me to specifically useful information about that i want to make I will be really glad:)
With risk to not accomplish my project, i will start to work on it with your help and support

Aim 1: SMS Control on all components connected to the arduino.
Task 1: Activate PIR sensor and Piezo
Task 2: Activate microphone to record on SD module
Problem 1:
How to fit this code:
int pirPin = 2; //digital 2
int pinSpeaker = 10;
void setup(){
Serial.begin(9600);
pinMode(pirPin, INPUT);
pinMode(pinSpeaker, OUTPUT);
}
void loop(){
int pirVal = digitalRead(pirPin);
if(pirVal == LOW){ //was motion detected
Serial.println("Motion Detected");
playTone(300, 160);
delay(2000);
}
}
void playTone(long duration, int freq) {
duration *= 1000;
int period = (1.0 / freq) * 1000000;
long elapsed_time = 0;
while (elapsed_time < duration) {
digitalWrite(pinSpeaker,HIGH);
delayMicroseconds(period / 2);
digitalWrite(pinSpeaker, LOW);
delayMicroseconds(period / 2);
elapsed_time += (period);
}
}
// Product name: GPS/GPRS/GSM Module V3.0
// # Product SKU : TEL0051
// # Description:
// # The sketch for controling the GSM/GPRS/GPS module via SMS.
// # Steps:
// # 1. Turn the S1 switch to the Prog(right side)
// # 2. Turn the S2 switch to the USB side(left side)
// # 3. Set the UART select switch to middle one.
// # 4. Upload the sketch to the Arduino board(Make sure turn off other Serial monitor )
// # 5. Turn the S1 switch to the comm(left side)
// # 6. Turn the S2 switch to the Arduino(right side)
// # 7. RST the board until the START led is on(make sure you have >6V power supply)
// # 8. Plug the long side of LED into pin 13 and short side into GND
// # 9. Start sending "LH" and "LL" to your board to turn LED on and off.
/*
* created: 2013-11-14
* by: Grey
* Version: 0.3
* Attention: if you send the wrong SMS command to the module, just need to press RST.
* This version can't watch the module status via the serial monitor, it only display the Arduino command.
* If you want to watch the status,use the SoftwareSerial or the board with another serial port plese.
*/
byte gsmDriverPin[3] = {
3,4,5};//The default digital driver pins for the GSM and GPS mode
//If you want to change the digital driver pins
//or you have a conflict with D3~D5 on Arduino board,
//you can remove the J10~J12 jumpers to reconnect other driver pins for the module!
int ledpin = 13;
char inchar;
void setup()
{
//Init the driver pins for GSM function
for(int i = 0 ; i < 3; i++){
pinMode(gsmDriverPin[i],OUTPUT);
}
pinMode(ledpin,OUTPUT);
Serial.begin(9600); //set the baud rate
digitalWrite(5,HIGH); //Output GSM Timing
delay(1500);
digitalWrite(5,LOW);
digitalWrite(3,LOW); //Enable the GSM mode
digitalWrite(4,HIGH); //Disable the GPS mode
delay(2000);
delay(5000); //call ready
delay(5000);
Serial.println("AT+CMGD=1,4"); //Delete all SMS in box
}
void loop()
{
if(Serial.available()>0)
{
inchar=Serial.read();
if(inchar=='T')
{
delay(10);
inchar=Serial.read();
if (inchar=='I') //When the GSM module get the message, it will display the sign '+CMTI "SM", 1' in the serial port
{
delay(10);
Serial.println("AT+CMGR=1"); //When Arduino read the sign, send the "read" AT command to the module
delay(10);
}
}
else if (inchar=='L')
{
delay(10);
inchar=Serial.read();
if (inchar=='H') //Thw SMS("LH") was display in the Serial port, and Arduino has recognize it.
{
delay(10);
digitalWrite(ledpin,HIGH); //Turn on led
delay(50);
Serial.println("AT+CMGD=1,4"); //Delete all message
delay(500);
}
if (inchar=='L') //Thw SMS("LH") was display in the Serial port, and Arduino has recognize it.
{
delay(10);
digitalWrite(ledpin,LOW); //Turn off led
delay(50);
Serial.println("AT+CMGD=1,4"); //Delete all message
delay(500);
}
}
}
}
http://img.td-imgs.com/images/42/45/254 ... 254245.jpg
https://www.sparkfun.com/products/8635? ... n=TopRight
Am using this power supply:
http://i.ebayimg.com/00/s/NzY4WDEwMjQ=/ ... h/$_35.JPG
Arduino Uno
GPS/GPRS/GSM Module V3.0
P.S. Sorry if this post is stupid and am asking elementary things
I will be glad and realy happy if you help to one newbie



The switches will set its working mode, it is very necessary.
If you have a SD module, you could try to record this data in the SD card. SD module will use SPI interface.(I am not sure). Do you have an LCD? with a LCD you could display it on the screen


I will try it outdoor but i have simple question.
When i do all the things when in plug in to PC, after that when i try it outdoor with extra power supply, should i do something else like: change S1 switch , S2 or ect.
And if i dont have to do anything special , just like i did it but outdoor , how could i see the coordinates and the data after i comes back in home ?
And one last question i have SD module could i connect it to arduino and GPS/GSM module to take the information?

You are right, the GPS signal indoor is very weak, so it is better to test outside.
Generally, it is better to select a position close window, or just outside.
If you have an extra long antenna, you could try to replace the board one. It should be better.
