0

I am trying to get my arduino uno to display the altitude from a GPS module, without any other data. I am still learning the code, but I've run into a problem where I can't seem to find what command is used to pull the altitude from the GPS string. I know it is pulling the data successfully, as I ran the example code from http://learn.parallax.com/kickstart/28500 and it read the first bit of the string, though I moved onto trying to get the altitude before getting it to scroll the whole string. I am using a basic 16x2 LCD display, and the display I have working fine.

The end goal of this project is a GPS/gyroscope altimeter that can record to an SD card and record temperature, and deploy a parachute at apogee (15,000ft) and a larger parachute at 1,000ft.

Here is the code I am using for the altitude, I've marked the section I can't figure out. (probably just missing a term, or I might have really messed something up)

Any help would be appreciated, have a great day.

#include <SoftwareSerial.h>
#include "./TinyGPS.h"                 // Special version for 1.0
#include <LiquidCrystal.h>

TinyGPS gps;
SoftwareSerial nss(0, 255);            // Yellow wire to pin 6
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void gpsdump(TinyGPS &gps);
bool feedgps();

void setup() {
// set up the LCD's number of columns and rows: 
lcd.begin(16, 2);
// initialize the serial communications:
Serial.begin(9600);
Serial.begin(115200);
nss.begin(4800);
lcd.print("Reading GPS");
lcd.write(254); // move cursor to beginning of first line
lcd.write(128);

lcd.write("                "); // clear display
lcd.write("                ");
}

void loop() {
bool newdata = false;
unsigned long start = millis();
while (millis() - start < 5000) {  // Update every 5 seconds
if (feedgps())
newdata = true;
}
gpsdump(gps);
}

// Get and process GPS data
void gpsdump(TinyGPS &gps) {

// problem area
float falt, flat, flon;
unsigned long age;
gps.f_get_position(&flat, &flon);
inline long altitude (return _altitude);
long _altitude
;lcd.print(_altitude, 4);
}//end problem area

// Feed data as it becomes available 
bool feedgps() {
while (nss.available()) {
if (gps.encode(nss.read()))
return true;
}
return false;
}
user2688631
  • 1
  • 1
  • 1

1 Answers1

0

lcd.print(x,4) prints base-4. Did you want that, or do you want ordinary base-10 (decimal)?

Secondly, where do you expect _altitude to come from? It's uninitialized. There's also an uninitialized falt, and a weird inline long altitude line which doesn't mean anything.

You might be better of learning C++ first, in a desktop environment. Debugging an embedded device is a lot harder, and you're still producing quite a few bugs.

MSalters
  • 173,980
  • 10
  • 155
  • 350
  • I was modifying the info used to pull longitude and latitude, and they had x,4 after them. is ,10 means base ten i would much rather use that. in the tinygps.h library i found the "inline long altitude" bit, and while trying to figure out how to pull the altitude, I moved it over. how would I initialize "altitude" and associate it with the value from the GPS string? I'm hoping to learn C++ soon, and I'm really sorry that a bunch of my mistakes are simple. Is there a place you would recommend to learn the basics? – user2688631 Aug 17 '13 at 16:35
  • Okay, here is what I don't get. How is falt uninitialized, but flan and flon are? Where are those values coming from? – user2688631 Aug 19 '13 at 03:43
  • @user2688631: You're probably in over your head. `gps.f_get_position(&flat, &flon);` initializes the two (presumably from the GPS string). For C++ basics, we have a [book list](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) – MSalters Aug 19 '13 at 06:51