gps + gsm+ vibration sensor and arduino.

M doing a project on vehicle accident alert notification… So I am using a vibrtion sensor… So when the value is greater than what is set in the program i.e in this case 50000.
So after it is greater than 50000 than the gps will get location… Which than via Gsm sim900a will send a SMS to the number in the program.

I don’t want to use GSM library. So m using serial communication pins.

I have used the following code but I don’t recieve any message… the serial monitor shows only sensor output. And no coordinates are recieved by arduino, hence no message.

The Code:

#include<Softwareserial.h>
#include <Tinygps.h>
long lat,lon;//Create variable for latitude and longitude object SoftwareSerial gpsSerial(4, 5);//create gps sensor connection TinyGPS gps;//create GPS object 
int EP=9; 
void setup()
{ 
pinMode(EP, INPUT); 
Serial.begin(9600); 
Serial.print("\r"); 
delay(1000);
gpsSerial.begin(9600); 
}

void loop() 
{ 
while(gpsSerial.available()) 
{ 
if(gps.encode(gpsSerial.read()))//encode gps data
{
gps.get_position(&lat,&lon);//get latitude and longitude Serial.print("Position:"); 
Serial.print("lat:"); 
Serial.print(lat); 
Serial.print(""); 
Serial.print("lon:"); 
Serial.println(lon); } 
}

long measurement= TP_init(); 
delay(50); 
Serial.print("measurment= "); 
Serial.println(measurement); 

if(measurement> 50000) 
{ 
SendTextMessage(); 
} 
else { Serial.print("AT\r");
} 
}

long TP_init() 
{ 
delay(10); 
long measurement=pulseIn (EP, HIGH); 
return measurement; 
}

void SendTextMessage()
{ 
Serial.print("AT+CMGF=1\r");
delay(1000); 
Serial.print("AT+CMGS=\"+9**********\"\r"); 
delay(1000); 
Serial.print("Accident Detected At Location:"&lat,&lon); delay(1000); 
Serial.write(0x1A); 
delay(1000); 
}

Please do help me guys… Thank you

You have to be outside, with a clear view of the sky, for the GPS to work.

Please edit your post and add code tags (</> button).

Or it may take quite a while to lock into GPS signals. In my living room, I have seen it take 10, 15 minutes to acquire satellites thru 2 front windows partially blocked by fir trees.

In a car, it should be quicker.

It acquires the signal.. My module has a blinking LED which blinks when it locks the signal.
But still I cant get it.. While I use the module only with arduino.. I get the coordinates.. But when try to combine with Gsm the module doesn't show me coordinates on serial monitor.

Does this line really look like this in your sketch?

long lat,lon;//Create variable for latitude and longitude object SoftwareSerial gpsSerial(4, 5);//create gps sensor connection

Or is it really two lines?

long lat,lon;//Create variable for latitude and longitude object
SoftwareSerial gpsSerial(4, 5);//create gps sensor connection

Do lat, lon need to be unsigned long?

I can use float.
And those are 2 seperate lines.
If u can help me write the code than it will be a great help.
I've been stuck on it for 2 days. I can't figure out a way
Please do write a code r modify my code.
And I don't want to use GSM library.. Coz I am good with serial communication pins.

Post links to the GPS and GSM modules you are using.

I used a SIM908 module from www.dfrobot.com and also wrote my own interface for it.
I needed to check that it initialized okay, that it found the network ok, and that it reported good GPS info back to parse up into a text message to send out.

Your code looks to me like not a lot of that kind of stuff is happening. The SIM908 for example took 8-10 seconds before it would respond to an AT+ kind of command with an OK reply so you could start sending status request commands.

Gps module: http://www.instructables.com/id/Arduino-Ublox-GPS/

Gsm module: https://researchdesignlab.com/wireless/gsm-sim-900.html

But when try to combine with Gsm the module doesn't show me coordinates on serial monitor.

Since you don't see the data you want to see, we don't get to see the code, either. Well, good luck fixing it.

Guys I have added code tags.. Please tell me what changes I should do. M really stuck on this.

Guys I have added code tags.

But, you have NOT fixed the issues that have already been pointed out. Fix them, and post your code again in a new reply. Do NOT change the code in the first post.