Go Down

Topic: Arduino Mega 2560, four NMEA device and TinyGPS++ library (Read 2253 times) previous topic - next topic

CrazyIgels

Hello All.
In my new project - autopilot for fishing boat i want to use this hardware configuration:

1. GPS sensor with NMEA interface
2. Boat Speed sensor (Pito tube) with NMEA interface
3. Compass with NMEA interface
4. secondary GPS sensor with NMEA 

And all sensors interfacing to Arduino MEGA 2560 through level conversion (MAX485) circuits.

On ATMega 2560 i have four hardware UART - Serial0 -Serial3.

It's possible to use TinyGPS++ library for working with more that one serial input channel and for decoding more that one NMEA data stream?

Any sample of code please if possible.


Thanks All!
PS Sorry my bad English

michinyon

For two gps devices,  you would have to create two copies of the gps parser object,  and feed the data from the serial input separately into each object.

I don't think tinygps will read other devices,  you would have to modify it to read other devices.  It is only designed to read the gps data strings.   

If they have the same basic string format,  modifying it would not be too difficult if you have the necessary skill.

CrazyIgels

TinyGPS++ can read any NMEA string - this library have special method for this. you can see it http://arduiniana.org/libraries/tinygpsplus/ in Custom NMEA Sentence Extraction section.

But i don't understand cleary how i can use four serial channel for four device. Each device on each channel separately....

 

GPSJay

I have 2 NMEA GPS running on the Mega 2560 and using TinyGPS++. Basically you create seperate serial streams.

Serial monitor on serial, GPS A on serial1 and GPS B  on serial2.

Declare for each GPS for example:

TinyGPSCustom pdopA(gpsA, "GPGSA", 15); // $GPGSA sentence, 15th element PDOP from GPS A
TinyGPSCustom pdopB(gpsB, "GPGSA", 15); // $GPGSA sentence, 15th element PDOP from GPS B
.
.
.
Then print the result:

Serial.print(pdopA.value()); Serial.print(F("  ")); //print GPS A pdop
Serial.print(pdopB.value()); Serial.print(F("  ")); //print GPS B pdop

Hope this brief overview helps !


CrazyIgels

How you declare  GpsA, and gpsB  objects? And how establish a link GpsA=serial1, gpsB=serial2 ?

michinyon

Get yourself an elementary book on how to program using C/C++.   

GPSJay

Try following the example "kitchen sink" in the TinyGPS++ library. Replace the software serial SS instances with your hardware UART channel, e.g. serial1.

The block of code for that serial1 routine will be the same for a second UART channel, e.g. serial2, and then serial3. Try keep BAUD rate low.

Go Up