element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum GPS receiver project
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 13 replies
  • Subscribers 402 subscribers
  • Views 1321 views
  • Users 0 members are here
Related

GPS receiver project

Former Member
Former Member over 12 years ago

Hello everyone,

 

I am looking to make a GPS receiver for a project. It is part of a project to assist the visually impaired get around easier on campus. The application of the receiver would be to tell the user how far he/she is from a building. I would also like to include audio feedback to let the user know the name of the particular building he/she is close to. I have looked into different GPS modules.   Working with an Arduino board is what I prefer to use with the module. What modules are recommended? Should I make a logger or live tracking? How should I go about including audio feedback? I mainly need some places to start in order to begin. Thanks for the advice in advance.

  • Sign in to reply
  • Cancel
Parents
  • Former Member
    0 Former Member over 12 years ago

    Hello everyone,

     

    I have some major updates. The GPS works now with no problems. The receiver is apart of my senior design project. The LCD display displays the lattitude and longitude live. We used Google maps to find the coordinates around the engineering building to test it out. A piezo is being used for audible feedback; and it works fine. Now, we would like the LCD to display the number of fixed satellites in and out of range. Also, in conjunction with the piezo to make an annoying sound when the satellites are out of range then a normal tone within range. A GPS is most accurate when four satellites are in range. The code is below, I apologize for the lack of comments.

     

    #include <TinyGPS.h>

    #include <LiquidCrystal.h>

     

     

    TinyGPS gps;

    LiquidCrystal lcd(52, 50, 28, 26, 24, 22);

     

     

    static void gpsdump(TinyGPS &gps);

    static bool feedgps();

    static void print_float(float val, float invalid, int len, int prec);

    static void print_int(unsigned long val, unsigned long invalid, int len);

    static void print_date(TinyGPS &gps);

    static void print_str(const char *str, int len);

     

     

     

     

     

     

    void setup()

    {

     

      lcd.begin(16, 2);

      lcd.print("LON");

      lcd.setCursor(0, 1);

      lcd.print("LAT");

     

      Serial.begin(115200);

      Serial3.begin(57600);

     

      Serial.println();

      Serial.println("Latitude Longitude");

      Serial.println("(deg)    (deg)    ");

      Serial.println("------------------");

    }

     

     

    void loop()

    {

    float flat, flon;

      gps.f_get_position(&flat, &flon);

     

     

      bool newdata = false;

      unsigned long start = millis();

     

      // Every second we print an update

      while (millis() - start < 1000)

      {

        if (feedgps())

          newdata = true;

      }

     

      gpsdump(gps);

     

      if (flat<=41.940719 && flat>= 41.93923 && flon>=-88.763013 && flon<=-88.761898)

    {

      tone (9,261, 50);

      lcd.print("Engr Bldg");

    }

     

     

      lcd.setCursor(4,1);

      lcd.print(flat,5);

     

      lcd.setCursor(4,0);

      lcd.print(flon,5);

    }

     

     

    static void gpsdump(TinyGPS &gps)

    {

      float flat, flon;

      unsigned long age, date, time, chars = 0;

      unsigned short sentences = 0, failed = 0;

      static const float LONDON_LAT = 51.508131, LONDON_LON = -0.128002;

     

     

      gps.f_get_position(&flat, &flon, &age);

      print_float(flat, TinyGPS::GPS_INVALID_F_ANGLE, 9, 5);

      print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 10, 5);

     

     

      gps.stats(&chars, &sentences, &failed);

      print_int(chars, 0xFFFFFFFF, 6);

      Serial.println();

     

     

     

    }

     

     

     

     

    static void print_int(unsigned long val, unsigned long invalid, int len)

    {

      char sz[32];

      if (val == invalid)

        strcpy(sz, "*******");

      else

        sprintf(sz, "%ld", val);

      sz[len] = 0;

      for (int i=strlen(sz); i<len; ++i)

        sz[i] = ' ';

      if (len > 0)

        sz[len-1] = ' ';

      Serial.print(sz);

      feedgps();

    }

     

     

    static void print_float(float val, float invalid, int len, int prec)

    {

      char sz[32];

      if (val == invalid)

      {

        strcpy(sz, "*******");

        sz[len] = 0;

            if (len > 0)

              sz[len-1] = ' ';

        for (int i=7; i<len; ++i)

            sz[i] = ' ';

        Serial.print(sz);

      }

      else

      {

        Serial.print(val, prec);

        int vi = abs((int)val);

        int flen = prec + (val < 0.0 ? 2 : 1);

        flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;

        for (int i=flen; i<len; ++i)

          Serial.print(" ");

      }

      feedgps();

    }

     

     

    static void print_date(TinyGPS &gps)

    {

      int year;

      byte month, day, hour, minute, second, hundredths;

      unsigned long age;

      gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);

      if (age == TinyGPS::GPS_INVALID_AGE)

        Serial.print("*******    *******    ");

      else

      {

        char sz[32];

        sprintf(sz, "%02d/%02d/%02d %02d:%02d:%02d   ",

            month, day, year, hour, minute, second);

        Serial.print(sz);

      }

      print_int(age, TinyGPS::GPS_INVALID_AGE, 5);

      feedgps();

    }

     

     

    static void print_str(const char *str, int len)

    {

      int slen = strlen(str);

      for (int i=0; i<len; ++i)

        Serial.print(i<slen ? str[i] : ' ');

      feedgps();

    }

     

     

    static bool feedgps()

    {

      while (Serial3.available())

      {

        if (gps.encode(Serial3.read()))

          return true;

      }

      return false;

    }

     

     

     

    I added this line of code in the void loop and I compiled. But, it doesn't print the correct information.

     

    int satellites = gps.satellites();

      if( satellites > 3)

        {

          Serial.print("number of satellies");Serial.println( gps.satellites() );

        }

      else

        {

        Serial.println ("nothing");

        }

     

     

    Before that I searched for code that specifically printed the number of satellites

    http://www.roguerobotics.com/wikidocs/code/arduino_tinygps_satellite_count_mod

     

    #include <NewSoftSerial.h>

    #include <TinyGPS.h>

     

    TinyGPS gps;

    NewSoftSerial nss(2, 3);

     

    void setup()

    {

      Serial.begin(115200);

      nss.begin(4800);

     

      Serial.println("TinyGPS Satellite Count Mod Test");

      Serial.println();

    }

     

    void loop()

    {

      if (nss.available())

      {

        if (gps.encode(nss.read()))

        {

          Serial.print("Satellites in view: ");

          Serial.println(gps.satsinview(), DEC);

     

          if (gps.fixtype() == TinyGPS::GPS_FIX_NO_FIX)

          {

            Serial.print("No fix.");

          }

          else

          {

            // we have a fix (could be GPS_FIX_2D or GPS_FIX_3D)

            Serial.print("Fix type: ");

            if (gps.fixtype() == TinyGPS::GPS_FIX_2D)

              Serial.println("2D");

            else

              Serial.println("3D");

     

            Serial.print("Satellites used: ");

            Serial.println(gps.satsused(), DEC);

     

            // You can do the rest of your coding here - e.g. gpsdump()

          }

        }

      }

    }

     

    I tested out the above code but, 'satsused' and 'satsinview' were not recognized.

     

    Any suggestions?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • Former Member
    0 Former Member over 12 years ago

    Hello everyone,

     

    I have some major updates. The GPS works now with no problems. The receiver is apart of my senior design project. The LCD display displays the lattitude and longitude live. We used Google maps to find the coordinates around the engineering building to test it out. A piezo is being used for audible feedback; and it works fine. Now, we would like the LCD to display the number of fixed satellites in and out of range. Also, in conjunction with the piezo to make an annoying sound when the satellites are out of range then a normal tone within range. A GPS is most accurate when four satellites are in range. The code is below, I apologize for the lack of comments.

     

    #include <TinyGPS.h>

    #include <LiquidCrystal.h>

     

     

    TinyGPS gps;

    LiquidCrystal lcd(52, 50, 28, 26, 24, 22);

     

     

    static void gpsdump(TinyGPS &gps);

    static bool feedgps();

    static void print_float(float val, float invalid, int len, int prec);

    static void print_int(unsigned long val, unsigned long invalid, int len);

    static void print_date(TinyGPS &gps);

    static void print_str(const char *str, int len);

     

     

     

     

     

     

    void setup()

    {

     

      lcd.begin(16, 2);

      lcd.print("LON");

      lcd.setCursor(0, 1);

      lcd.print("LAT");

     

      Serial.begin(115200);

      Serial3.begin(57600);

     

      Serial.println();

      Serial.println("Latitude Longitude");

      Serial.println("(deg)    (deg)    ");

      Serial.println("------------------");

    }

     

     

    void loop()

    {

    float flat, flon;

      gps.f_get_position(&flat, &flon);

     

     

      bool newdata = false;

      unsigned long start = millis();

     

      // Every second we print an update

      while (millis() - start < 1000)

      {

        if (feedgps())

          newdata = true;

      }

     

      gpsdump(gps);

     

      if (flat<=41.940719 && flat>= 41.93923 && flon>=-88.763013 && flon<=-88.761898)

    {

      tone (9,261, 50);

      lcd.print("Engr Bldg");

    }

     

     

      lcd.setCursor(4,1);

      lcd.print(flat,5);

     

      lcd.setCursor(4,0);

      lcd.print(flon,5);

    }

     

     

    static void gpsdump(TinyGPS &gps)

    {

      float flat, flon;

      unsigned long age, date, time, chars = 0;

      unsigned short sentences = 0, failed = 0;

      static const float LONDON_LAT = 51.508131, LONDON_LON = -0.128002;

     

     

      gps.f_get_position(&flat, &flon, &age);

      print_float(flat, TinyGPS::GPS_INVALID_F_ANGLE, 9, 5);

      print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 10, 5);

     

     

      gps.stats(&chars, &sentences, &failed);

      print_int(chars, 0xFFFFFFFF, 6);

      Serial.println();

     

     

     

    }

     

     

     

     

    static void print_int(unsigned long val, unsigned long invalid, int len)

    {

      char sz[32];

      if (val == invalid)

        strcpy(sz, "*******");

      else

        sprintf(sz, "%ld", val);

      sz[len] = 0;

      for (int i=strlen(sz); i<len; ++i)

        sz[i] = ' ';

      if (len > 0)

        sz[len-1] = ' ';

      Serial.print(sz);

      feedgps();

    }

     

     

    static void print_float(float val, float invalid, int len, int prec)

    {

      char sz[32];

      if (val == invalid)

      {

        strcpy(sz, "*******");

        sz[len] = 0;

            if (len > 0)

              sz[len-1] = ' ';

        for (int i=7; i<len; ++i)

            sz[i] = ' ';

        Serial.print(sz);

      }

      else

      {

        Serial.print(val, prec);

        int vi = abs((int)val);

        int flen = prec + (val < 0.0 ? 2 : 1);

        flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;

        for (int i=flen; i<len; ++i)

          Serial.print(" ");

      }

      feedgps();

    }

     

     

    static void print_date(TinyGPS &gps)

    {

      int year;

      byte month, day, hour, minute, second, hundredths;

      unsigned long age;

      gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);

      if (age == TinyGPS::GPS_INVALID_AGE)

        Serial.print("*******    *******    ");

      else

      {

        char sz[32];

        sprintf(sz, "%02d/%02d/%02d %02d:%02d:%02d   ",

            month, day, year, hour, minute, second);

        Serial.print(sz);

      }

      print_int(age, TinyGPS::GPS_INVALID_AGE, 5);

      feedgps();

    }

     

     

    static void print_str(const char *str, int len)

    {

      int slen = strlen(str);

      for (int i=0; i<len; ++i)

        Serial.print(i<slen ? str[i] : ' ');

      feedgps();

    }

     

     

    static bool feedgps()

    {

      while (Serial3.available())

      {

        if (gps.encode(Serial3.read()))

          return true;

      }

      return false;

    }

     

     

     

    I added this line of code in the void loop and I compiled. But, it doesn't print the correct information.

     

    int satellites = gps.satellites();

      if( satellites > 3)

        {

          Serial.print("number of satellies");Serial.println( gps.satellites() );

        }

      else

        {

        Serial.println ("nothing");

        }

     

     

    Before that I searched for code that specifically printed the number of satellites

    http://www.roguerobotics.com/wikidocs/code/arduino_tinygps_satellite_count_mod

     

    #include <NewSoftSerial.h>

    #include <TinyGPS.h>

     

    TinyGPS gps;

    NewSoftSerial nss(2, 3);

     

    void setup()

    {

      Serial.begin(115200);

      nss.begin(4800);

     

      Serial.println("TinyGPS Satellite Count Mod Test");

      Serial.println();

    }

     

    void loop()

    {

      if (nss.available())

      {

        if (gps.encode(nss.read()))

        {

          Serial.print("Satellites in view: ");

          Serial.println(gps.satsinview(), DEC);

     

          if (gps.fixtype() == TinyGPS::GPS_FIX_NO_FIX)

          {

            Serial.print("No fix.");

          }

          else

          {

            // we have a fix (could be GPS_FIX_2D or GPS_FIX_3D)

            Serial.print("Fix type: ");

            if (gps.fixtype() == TinyGPS::GPS_FIX_2D)

              Serial.println("2D");

            else

              Serial.println("3D");

     

            Serial.print("Satellites used: ");

            Serial.println(gps.satsused(), DEC);

     

            // You can do the rest of your coding here - e.g. gpsdump()

          }

        }

      }

    }

     

    I tested out the above code but, 'satsused' and 'satsinview' were not recognized.

     

    Any suggestions?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube