MTK GPS using NewSoftSerial.h

 

I am trying to get an Arduino Nano (which is just a small Arduino with an ATMega328 like other Arduinos) to read the serial data coming out of a DIY Drones "MediaTek MT3329 GPS 10Hz + Adapter Basic."

 

The library for the GPS is designed to be used on the Serial1 of an Arduino Mega or on the Serial port of other Arduinos (that only have the single Serial UART).

 

I am using an Arduino Nano, which has a single Serial port. However, I use the one Serial port for uploading my software to the Arduino and, at runtime, for printing data through the USB port to my computer so that I can see what the program is doing. I assume this is the case for everyone else also.

 

I don't understand how I could then connect the GPS to the same Serial port and expect it to work. It seems like it would conflict. I assume there's something I don't know. If you know how to do this, or the idea behind it, please let me know.

 

Thinking that I can't use the single Serial port, I've been trying to use NewSoftSerial.h to define a software-base serial port. I've used this method before on other projects. And on this project, I'm already using NewSoftSerial to define a software-base serial port read data from my xBee. So, I was thinking I could use the same method to read data in through a software-defined serial port for the GPS, but unfortunately the GPS libraries are designed to work only on Serial (general Arduinos) and Serial1 (Mega). I've hacked around in the.h and .cpp files of the libraries and I can sort of see what it's doing, but my Arduino-C skills are not strong enough to modify the .h and .cpp to support NewSoftSerial. Does anyone know how use NewSoftSerial or any non-Mega-Arduino with this GPS?

 

I wish I could just use an Arduino Mega for this project, which would solve all my problems, but I need the Nano's small form factor. Or perhaps I could figure out a way to do a Vulcan-brain-swap of Jordi Munoz's brain into my head for the evening to solve this. :)

 

Your assistance is appreciated.

 

 

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Robert,

     

    I'm the NewSoftSerial guy, and I do just what you're describing all the time--read GPS data through a "soft" serial port so that I can keep the "real" one available for debugging and other tasks.

     

    I recommend you take a look at my sample "Reverse Geocache" code to show how such a thing can be done: http://arduiniana.org/projects/the-reverse-geo-cache-puzzle/building/.

     

    Mikal Hart

    Building a Puzzle Box | Arduiniana
  • I've adapted the current AP_GPS libraries to work with Serial2 and Serial3 on Arduino Mega; that wasn't hard. They do use FastSerial and BetterStream which would hinder change to a software serial.

    The guts of what you need is:

    - send initialisation string to the GPS serial port

    - read characters from the serial port

    - parse the characters to interpret them

     You can parse MediaTek binary messages using code from the GP_GPS_MTK or similar library.  Or, you can parse NMEA strings using a function from AP_GPS_NMEA (which has some origins in TinyGPS), or from TinyGPS as linked above, which actually uses NewSoftSerial.

  • Have a read through this web site
    http://arduiniana.org/libraries/tinygps/
    This is the guy that created one of the best nmea gps libraries and soft serial for arduino
    Should be some clues in there
    TinyGPS | Arduiniana
This reply was deleted.

Activity