Amal Mathew
Published © GPL3+

Arduino + GPS Module - Destination Notifier

How much time do we waste in traffic jams? I made an Arduino-powered destination notifier to utilize this time in a productive way.

BeginnerFull instructions provided1 hour45,664
Arduino + GPS Module - Destination Notifier

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
GPS Module (Generic)
NEO-6M GPS Module
×1
LED (generic)
LED (generic)
×1
Dual H-Bridge motor drivers L293D
Texas Instruments Dual H-Bridge motor drivers L293D
×1
Solar Cockroach Vibrating Disc Motor
Brown Dog Gadgets Solar Cockroach Vibrating Disc Motor
×1
SparkFun Snappable Protoboard
SparkFun Snappable Protoboard
×1
9V battery (generic)
9V battery (generic)
×1
9V to Barrel Jack Connector
9V to Barrel Jack Connector
×1
A Box
Something to enclose the project in.
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Wire Stripper

Story

Read more

Schematics

read_lat_lng_l3VSL54w0k.fzz

destination_notifier_led_c7qaqTImXg.fzz

destination_notifier_motor_fGc8OV6Y0w.fzz

Code

Read_Lat_Lng.ino

Arduino
 
#include <TinyGPS++.h>
#include <SoftwareSerial.h>

static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

void setup(){
  Serial.begin(9600);
  ss.begin(GPSBaud);
}

void loop(){
  // This sketch displays information every time a new sentence is correctly encoded.
  while (ss.available() > 0){
    gps.encode(ss.read());
    if (gps.location.isUpdated()){
      Serial.print("Latitude= "); 
      Serial.print(gps.location.lat(), 6);
      Serial.print(" Longitude= "); 
      Serial.println(gps.location.lng(), 6);
    }
  }
}

Destination_notifier_LED.ino

Arduino
#include <TinyGPS++.h>
#include <SoftwareSerial.h>

static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

// For stats that happen every 5 seconds
unsigned long last = 0UL;


int ledPin = 13;


void setup()
{
  Serial.begin(115200);
  ss.begin(GPSBaud);

pinMode(ledPin, OUTPUT);
}

void loop()
{
  // Dispatch incoming characters
  while (ss.available() > 0)
    gps.encode(ss.read());

  if (gps.location.isUpdated())
  {
    
    Serial.print(F("  Lat="));
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(" Long="));
    Serial.println(gps.location.lng(), 6);
  }



  else if (millis() - last > 5000)
  {
    Serial.println();
    if (gps.location.isValid())
    {

      // replace 'Dest_LAT' and 'Dest_LON' values basedon your location  
      // you can find Latitude and Longitude from Read_Lat_Lng.ino  
      static const double Dest_LAT = 18.786254, Dest_LON = 73.880798;
      double distanceToDest =
        TinyGPSPlus::distanceBetween(
          gps.location.lat(),
          gps.location.lng(),
          Dest_LAT, 
          Dest_LON);
      

      Serial.print(F("Distance to Destination ="));
      Serial.print(distanceToDest/1000, 6);       // *Prints distance to destination 
      
      if(distanceToDest/1000 < 0.050000)   //Here when distanceToDest/1000 is less than  0.050000  LED turns on . So change *distance to destination as per your requirement. 
      {
        digitalWrite(ledPin, HIGH);
      }
      else
      {
        digitalWrite(ledPin, LOW);
      }
    }

   

    if (gps.charsProcessed() < 10)
      Serial.println(F("WARNING: No GPS data.  Check wiring."));

    last = millis();
    Serial.println();
  }
}

Destination_notifier_motor.ino

Arduino
#include <TinyGPS++.h>
#include <SoftwareSerial.h>

static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

// For stats that happen every 5 seconds
unsigned long last = 0UL;


int motorpin1=6;
int motorpin2=7;


void setup()
{
  Serial.begin(115200);
  ss.begin(GPSBaud);

pinMode(motorpin1,OUTPUT);
pinMode(motorpin2,OUTPUT);
  
}

void loop()
{
  // Dispatch incoming characters
  while (ss.available() > 0)
    gps.encode(ss.read());

  if (gps.location.isUpdated())
  {
    
    Serial.print(F("  Lat="));
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(" Long="));
    Serial.println(gps.location.lng(), 6);
  }



  else if (millis() - last > 5000)
  {
    Serial.println();
    if (gps.location.isValid())
    {

      // replace 'Dest_LAT' and 'Dest_LON' values basedon your location  
      // you can find Latitude and Longitude from Read_Lat_Lng.ino  
      static const double Dest_LAT = 18.786254, Dest_LON = 73.880798;
      double distanceToDest =
        TinyGPSPlus::distanceBetween(
          gps.location.lat(),
          gps.location.lng(),
          Dest_LAT, 
          Dest_LON);
      

      Serial.print(F("Distance to Destination ="));
      Serial.print(distanceToDest/1000, 6);       // *Prints distance to destination 
      
      if(distanceToDest/1000 < 0.050000)   //Here when distanceToDest/1000 is less than  0.050000  LED turns on . So change *distance to destination as per your requirement. 
      {
        
  digitalWrite(motorpin1,LOW);
  digitalWrite(motorpin2,HIGH);
      }
      else
      {
       digitalWrite(motorpin1,HIGH);
       digitalWrite(motorpin2,HIGH); 
      }
    }

   

    if (gps.charsProcessed() < 10)
      Serial.println(F("WARNING: No GPS data.  Check wiring."));

    last = millis();
    Serial.println();
  }
}

Credits

Amal Mathew

Amal Mathew

24 projects • 79 followers
Maker | Not much to boast about – just a human, open-source believer. Simple as that.

Comments