First,
If I use the TinyGPS code rather than nmea.h, both the gps and the LSM303DLH work and work fine.
I have another reason to prefer to use the nmea.h routines which would be more difficult implementing with TinyGPS.
Machine is Arduino Uno, using Arduino 1.0, Skylab SKM53, and DFrobotics LCD shield.
routine in this code prints lat/lon to lcd. It doesn’t work if I add the LSM303 code. It fails as soon as I add
LSM303 compass;
I suspect that i may have run out of the top of the buffer, or created some other problem that has nothing to do with the accelerometer and if you think that’s the case, just say so, and I’ll try to puzzle out my code problems on my own.
As i said, the 303DLH works fine with TinyGPS in the same hardware setup.
// works!! with $GPGGA sentences directly connected to
// Skylab gps, but not if "LSM303 Compass" entry is added jaf 1/16/12
#include <nmea.h>
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
#include <Wire.h>
#include <LSM303.h>
SoftwareSerial gpsin(2, 3);
NMEA gps(ALL); // GPS data connection to all sentence types
// select the pins used on the LCD panel
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
LSM303 compass; //this single entry kills output 1/16/12 jaf
void setup() {
Wire.begin();
gpsin.begin(9600);
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print(F("GPS & HEADING"));
delay(5000);
}
String boola;
String _latdeg;
String _latmin;
String _londeg;
String _lonmin;
void loop() {
if (gpsin.available() > 0 ) {
// read incoming character from GPS and feed it to NMEA type object
if (gps.decode(gpsin.read())) {
// full sentence received
if (strncmp(gps.sentence(),"$GPGGA", 6) == 0) {
boola=(gps.sentence());
_latdeg = (boola.substring(18,20));
_latmin = (boola.substring(20,27));
_londeg = (boola.substring(31,33));
_lonmin = (boola.substring(33,40));
lcd.clear();
lcd.setCursor (0,0);
lcd.print (F("Lat: "));
lcd.print (_latdeg);
lcd.print (F(" "));
lcd.print (_latmin);
lcd.setCursor (0,1);
lcd.print (F("Lon: "));
lcd.print (_londeg);
lcd.print (F(" "));
lcd.print (_lonmin);
}
}
}
}
If you think I need to learn how to code, it’s ok to tell me. I tend to work from ignorance and prevail by persistence.
john