Robert Korn
Published © Apache-2.0

GPS Based Boat/ATV Speedometer

This could be the easiest one yet.

BeginnerFull instructions provided2 hours1,165
GPS Based Boat/ATV Speedometer

Things used in this project

Hardware components

Relay (generic)
×1
Ananlog Meter
×1
Resistor 221 ohm
Resistor 221 ohm
Value depends on Meter sensitivity....
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Schematic

Code

GPS_Boat_Speedometer.ino

Arduino
//****************************************************************
//*  Name    : GPS Boat Speedo                                   *
//*  Author  : Robert Joseph Korn                                *
//*  Date    : 12/18/15                                          *
//*  Version : 1.1                                               *
//*  Notes   :                                                   *
//*          :                                                   *
//****************************************************************
#include <SPI.h>
#include <LGPS.h>

gpsSentenceInfoStruct info;

double spd;
String dataString;
int tmp ;
int num ;
int meter = 9;
int alarm = 6;
int limit = 35;

static unsigned char getComma(unsigned char num,const char *str)
{
  unsigned char i,j = 0;
  int len=strlen(str);
  for(i = 0;i < len;i ++)
  {
     if(str[i] == ',')
      j++;
     if(j == num)
      return i + 1; 
  }
  return 0; 
}

static double getDoubleNumber(const char *s)
{
  char buf[10];
  unsigned char i;
  double rev;
  
  i=getComma(1, s);
  i = i - 1;
  strncpy(buf, s, i);
  buf[i] = 0;
  rev=atof(buf);
  return rev; 
}

static double getIntNumber(const char *s)
{
  char buf[10];
  unsigned char i;
  double rev;
  
  i=getComma(1, s);
  i = i - 1;
  strncpy(buf, s, i);
  buf[i] = 0;
  rev=atoi(buf);
  return rev; 
}

void parseGPRMC(const char* GPRMCstr)
{
  if(GPRMCstr[0] == '$')
  {
    tmp = getComma(7, GPRMCstr);
    spd = getDoubleNumber(&GPRMCstr[tmp]);
    tmp = spd * 100 ;
    tmp = map(tmp,0,5000,0,232);
    analogWrite(meter, tmp);
    if(spd > limit)
     {
        digitalWrite(alarm, HIGH);  
     } else { 
        digitalWrite(alarm, LOW);   
     }
  }
}


void setup() {
  pinMode(alarm, OUTPUT);     
  digitalWrite(alarm, LOW);   
  Serial1.begin(4800);
  LGPS.powerOn();
}

void loop() {
  LGPS.getData(&info);
  Serial1.print((char*)info.GPRMC); 
  Serial1.print((char*)&info); 
  parseGPRMC((const char*)info.GPRMC);
  delay(1000);  
}

Credits

Robert Korn

Robert Korn

15 projects • 27 followers
I Made the Internet of Things before people had a name for it.

Comments