Lounge - i want to get latitude and longitude from micro controller

Asked By balaji mogadali on 16-Oct-11 04:59 AM
hi frds

i am doing vechicle tracking system where i want to get latitude and longitude from a micro controller which attached to a vechicle . using these values i had to lay a path on googleMap to track where vechicle is existing. pls help
smr replied to balaji mogadali on 24-Oct-11 06:08 AM

Here is a function that I wrote to get the Latitude and Longitude for a given address using the Google API.  It's quite simple.

You build the URL along with the query string parameters, make a request to Google's API, when the response comes back you process the results.

The parameters that you send to Google's API are:

key - the App key you got from Google when you signed up for the service.

output - the format of your results.  For ease and size, I choose cvs.

q - the address you are looking for.

try this

using System.Net;
private void GetLatAndLongGoogle(string address, string city, string state,
                string zip, ref string inLat, ref string inLong)
       * Pass in the paramters: address, city, state, zip
       * The Longitude and Latitude will be passed back out through: inLat, inLong
       * (don't forget to pass these last two as "ref")
      /* appID is the API Key you get from Google */
      string appID = "YOUrKraZYKey1w";
      /* Here we build the URL with the query string parameters*/
      StringBuilder url = new StringBuilder("http://maps.google.com/maps/geo?");
      /*Create HttpWebRequest object*/
      HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(url.ToString());
      myReq.Credentials = CredentialCache.DefaultCredentials;
        HttpWebResponse response = (HttpWebResponse)myReq.GetResponse();
        Stream receiveStream = response.GetResponseStream();
        StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
        string httpString = readStream.ReadToEnd();
        if (httpString.StartsWith(@"200,"))
          string[] AddressArray = httpString.Split(',');
          inLat = AddressArray[2];
          inLong = AddressArray[3];
          inLat = "0.0";
          inLong = "0.0";
      catch (Exception e)
        inLat = "0.0";
        inLong = "0.0";
    private string CleanForURL(string inStr)
      inStr = inStr.Replace(@"&", "");
      inStr = inStr.Replace(@"/", "");
      inStr = inStr.Replace(@"\", "");
      inStr = inStr.Replace(@"?", "");
      return inStr;
Here is a sample of how you would call the function:
int myAddressKey = 1234;
      string myAddress = "401 Main St";
      string myCity = "Huntington Beach";
      string myState = "CA";
      string myZip = "92648";
      string myLatitude = "";
      string myLongitude = "";
      GetLatAndLongGoogle(myAddress, myCity, myState, myZip,
      ref myLatitude, ref myLongitude);
      MyProcedureThatUpdatesDBWithLatAndLong(myAddressKey, myLatitude, myLongitude);

smr replied to balaji mogadali on 24-Oct-11 06:11 AM

In this Project it is proposed to design an embedded system which is used for tracking and positioning of any vehicle by using Global Positioning System (GPS) and Global system for mobile communication (GSM).

A GSM modem is used to send the position (Latitude and Longitude) of the vehicle from a remote place. The GPS modem will continuously give the data i.e. the latitude and longitude indicating the position of the vehicle.

Block Diagram:

Circuit Diagram:

Operating procedure:

To store a Number into the kit
  1. Place a jumper at the pin no 32 “Store Number” as shown in the circuit diagram
  2. Switch on the kit
  3. Wait until you see “Waiting for Call” on the LCD display
  4. Now call from the mobile number from which you need to store the number
  5. Wait until you see “Number stored..” on the LCD
  6. Now remove the Jumper.

Normal Operation
  1. Switch on the kit and wait until you see the Latitude and longitude on the display.
  2. Now give a call from any mobile
  3. The kit will send the location and UTC time to the number stored in its memory.
  4. For emergency the user can press the Button to send the Location to the number stored.
  5. For photos of this project check this link
follow  http://www.8051projects.info/content/projects/7-vehicle-tracking-system-using-gps-gsm-modem.html