Flora GPS

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
NoobIta
 
Posts: 3
Joined: Wed Apr 09, 2014 12:39 pm

Flora GPS

Post by NoobIta »

I need help for a project. The objective is to make a string with the data from gps ($GPGGA) and the data from other sensors and send it to a ground station, to be process in the ground, not by the microcontroller (this way the process can be faster).

I have a code, based on the one in the tutorial page.:

Code: Select all

#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>
Adafruit_GPS GPS(&Serial3);
 
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
// Set to 'true' if you want to debug and listen to the raw GPS sentences
#define GPSECHO false
 
// this keeps track of whether we're using the interrupt
// off by default!
boolean usingInterrupt = false;
 
void setup()  
{
  // connect at 115200 so we can read the GPS fast enough and echo without dropping chars
  // also spit it out
  Serial.begin(115200);
  Serial.println("Adafruit GPS library basic test!");
 
  // 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800
  GPS.begin(9600);
  
  // uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  // uncomment this line to turn on only the "minimum recommended" data
  //GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
  // For parsing data, we don't suggest using anything but either RMC only or RMC+GGA since
  // the parser doesn't care about other sentences at this time
  
  // Set the update rate
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);   // 1 Hz update rate
  // For the parsing code to work nicely and have time to sort thru the data, and
  // print it out we don't suggest using anything higher than 1 Hz
  // Ask for firmware version
}
 
 

void loop()                     // run over and over again
{
  // read data from the GPS in the 'main loop'
  char c = GPS.read();
  // if you want to debug, this is a good time to do it!
  //if (GPSECHO)
      //if (c) Serial.print(c);
  
  // if a sentence is received, we can check the checksum, parse it...
  if (GPS.newNMEAreceived()) {
    // a tricky thing here is if we print the NMEA sentence, or data
    // we end up not listening and catching other sentences! 
    // so be very wary if using OUTPUT_ALLDATA and trytng to print out data   // this also sets the newNMEAreceived() flag to false
    String p = GPS.lastNMEA();
    String gps = p.substring(p.indexOf("$GPGGA"), p.length());
    String sendit = gps + "2002";
    Serial.println(sendit); 
    if (!GPS.parse(GPS.lastNMEA()))   // this also sets the newNMEAreceived() flag to false
      return;  // we can fail to parse a sentence in which case we should just wait for another
  }
}
The problem is that the code writes two times the variable that isn't the one recieving the gps data (in the code i wrote a new variable, sendit that is equal to gps + 2002. The problem is that 2002 is written two times) . Could you help me? Grateful

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Flora GPS

Post by adafruit_support_mike »

The Arduino 'String' class uses the '+' sign to mean string contatenation. "1" + "2" comes out as "12" rather than "3".

NoobIta
 
Posts: 3
Joined: Wed Apr 09, 2014 12:39 pm

Re: Flora GPS

Post by NoobIta »

adafruit_support_mike wrote:The Arduino 'String' class uses the '+' sign to mean string contatenation. "1" + "2" comes out as "12" rather than "3".
Yes, that is the objective. How can i send the $GPGGA and the $GPRMC plus all the data from other sensors in just one string (Something like this: "$GPGGA,$GPRMC,sensor1,sensor2".

Any help would be great.

Grateful

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Flora GPS

Post by adafruit_support_mike »

Ah, I see the issue.

For the sake of troubleshooting, step back a few lines and print the raw NMEA string 'p' just to make sure you're getting what you expect.

NoobIta
 
Posts: 3
Joined: Wed Apr 09, 2014 12:39 pm

Re: Flora GPS

Post by NoobIta »

adafruit_support_mike wrote:Ah, I see the issue.

For the sake of troubleshooting, step back a few lines and print the raw NMEA string 'p' just to make sure you're getting what you expect.
That works ok! The problem is to make only a variable with the $GPGGA and the $GPRMC from the data of the wearable MTK3339. From what i understood from your library, the GPS sends characters and you library compile them into a char*, correct?

How can i, from the library, make a variable with the $GPGGA and $GPRMC (processed in ground, so microcontroller don't be processing too much information)?

Grateful

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Flora GPS

Post by adafruit_support_mike »

The GPS library handles the work of reading sentences from the GPS module, and you can get the most recent sentence with the 'lastNMEA()' method.

If you want to keep the last most recent $GPGGA and $GPRMC sentences so you can combine them, call 'lastNMEA()', check the first few characters to make sure you have the kind of sentence you want, and if so, copy it to another string. When you have both a $GPGGA and a $GPRMC, combine them however you want.

User avatar
Dimperado
 
Posts: 11
Joined: Mon Mar 09, 2015 3:07 pm

Re: Flora GPS

Post by Dimperado »

Hello i'm having a hard time getting used to the GPS library. How could I get the latest Latitude and Longitude update from the FLORA GPS written in a string in order to send it through an SMS via FONA? I already got the FONA to send automatic SMS updates I just need to know how to create a string with both Latitude and Longitude written on it in a way that if I printed such string with say Serial.print(String), it would be read like this: "+23.4667973,-86.8299884" without the quotation marks of course.

Thank you a lot!

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Flora GPS

Post by adafruit_support_mike »

With the Serial.print() interface, it's easiest to break a formatted string into several pieces:

Code: Select all

Serial.print(( latitude >= 0 ) ? "+" : "-" );
Serial.print( latitude );
Serial.print( "," );
Serial.print(( longitude >= 0 ) ? "+" : "-" );
Serial.print( longitude );

User avatar
Dimperado
 
Posts: 11
Joined: Mon Mar 09, 2015 3:07 pm

Re: Flora GPS

Post by Dimperado »

Hello Mike it's been a while and we got the code up and running, now it is a power saving issue that sometimes when i send the Flora GPS to sleep it leaves the red FIX light ON and it consumes 13mAmp that way, when sleeping with the red FIX light OFF it draws only 6mAmp, is there a way to either make it never flash or make it go to sleep only when the red FIX light is OFF? Thanks for your help!

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Flora GPS

Post by adafruit_support_mike »

There's no command to control the fix or the LED. It will probably be easier to disconnect power to the GPS module entirely. A small mosfet or transistor can do that easily.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”