Tuesday, March 22, 2011

Late update

So yes its been a long time and a lot has transpired for this project. From flipping to a Netduino Plus to flipping back to Arduino to wanting to go back to the Netduino again LOL. Both have their own advantages and disadvantages. The only problem Im having with the Netduino is on the SDA/SCL lines where my barometer is supposed to plug into. When I wire into these pins I get no data or erratic data and when I wire the same sensor to the Arduino I get perfect data every time. I'm waiting on a logic analyzer to arrive to properly test these pins and hopefully diagnose what is going on.

In the interim I have been working on a NMEA parser for the Arduino Uno as well bringing in both GPS and Pitch/Roll data on the Uno. Using the NewSoftSerial driver (http://arduiniana.org/libraries/newsoftserial/) I am able to bring both sensors in and view the data. Next on my task list is to log the data to an OpenLog microSD data logger. (http://www.sparkfun.com/products/9530)

Here is the code I am using to parse out the NMEA strings. It works perfectly and is able to parse multiple NMEA messages on the same port. So now if I need to I can pull out data from a NMEA string like say the Altitude and use that somewhere else in my code.

int incomingByte = 0;      // for incoming serial data
int index = 0;
int count,i = 0;
String GPSStrings[20];
String field;
String message;
void setup() {
  Serial.begin(57600);        // opens serial port, sets data rate to 9600 bps
  message = String("");
  field = String("");
}

void loop() {

  // wait for data to be present on com port.
  if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();
    message.concat(char(incomingByte)); //append char to message
   


    if(incomingByte == '\n'){  //if newline is found
      Serial.write("NMEA Message: ");
      Serial.print(message);// print message


      if(message.indexOf(",") != -1){ //if a comma is in message:
       
        do{
          index = message.indexOf(","); //find first comma
          GPSStrings[i] = message.substring(0,index); //grab data to first comma
          message = message.substring(index+1); //toss data to first comma       
                   
          Serial.println(GPSStrings[i]);
         
        }
        while(index != -1); //while there is still a comma
        i++;
      } 
     
      else
        Serial.print(message);//if there was no comma to begin with just print the message.
       
      message = String(""); //wipe out message for next line 
    }
  }
}

No comments:

Post a Comment