GPS Bee with Seeeduino Stalker v3

wireless communication and related Bees.

Moderators: lily.li, violet, jessie

viswa
Staff
Staff
Posts: 168
Joined: Tue Jan 25, 2011 11:16 am
Are you a staff member of seeedstudio?: no
Which products/projects are your favorite?: Seeeduino Film,Motion Frame,UartSbee

Re: GPS Bee with Seeeduino Stalker v3

Post by viswa » Fri Oct 09, 2015 3:00 pm

Please try this example. We used the Serial() interface i.e H/W UART to access GPSBee:

Code: Select all

//Code based on examples of TinyGPS++ library.
#include <SPI.h>
#include <SD.h>
#include <TinyGPS++.h>
TinyGPSPlus gps;

static const uint32_t GPSBaud = 9600;
const int chipSelect = 10;


void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(GPSBaud);


  // Check if SD card can be intialized.
  if (!SD.begin(10))  //Chipselect is on pin 10
  {
  return;
  }


}

void loop()
{

  // This sketch displays information every time a new sentence is correctly encoded.
  while (Serial.available() > 0)
  if (gps.encode(Serial.read()))
  displayInfo();



}

void displayInfo() 
{
  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  File dataFile = SD.open("datalog.txt", FILE_WRITE);

  // if the file is available, write to it:
  if (gps.location.isValid())
  {
  if (dataFile) 
    {
      dataFile.println(gps.location.lat(), 6);
      dataFile.println(gps.location.lng(), 6);
      dataFile.close();
    }
  }
  else 
  {
   
    dataFile.println("Invalid");;
    dataFile.close();
  }

}

Post Reply