Go Down

Topic: Problem:Interfacing the MediaTek MT3329 V2.0 with Uno without GPS Shield (Read 240 times) previous topic - next topic

chughtai538

Hi

So I am trying to interface the MT3329 V2 with my Arduino uno for a fixed wing autopilot project. I have been using the following code to test the module:

Code: [Select]
#include <SoftwareSerial.h>
SoftwareSerial GPS(2,3); // configure software serial port -
 
void setup()
{
  GPS.begin(9600);
  Serial.begin(9600);
}
void loop()
{
  byte a;
    if (GPS.available() > 0 )
  {
    a = GPS.read(); // get the byte of data from the GPS
    Serial.write(a);
  }
}


This is the code from the tronixstuff website:
http://tronixstuff.com/2014/01/15/tutorial-arduino-mediatek-3329-gps/

This is my pin configuration, I am not using any sort of shield:

MT33229 --> Uno
Tx --> Pin 2
Rx --> Pin 3
5v --> 5V
GND -->GND

I am getting a bunch of gibberish text in my serial window. I have experimented with different baud rates but that doesn't help either. I only test the sensor after I get a GPS fix(solid blue led).

I would really appreciate any help on this, I have been lurking these threads for the past 3 days but none of the info provided solves my issue.

I am attaching a picture of my gps module:

knut_ny

Connections are correct.
Serial.begin(115200);
Try all baudrates 4800..57600 (u can skip 19200)

Ny

chughtai538

Connections are correct.
Serial.begin(115200);
Try all baudrates 4800..57600 (u can skip 19200)


Thanks for the reply. So I am assuming I keep Serial.begin(115200) fixed and span the baud rates in the gps.begin() option. I have done that but I am still getting gibberish in the serial window for every baud rate. Any idea what is going on?

/dev

I don't think it makes any difference, but I've always seen the Serial.begin first.  Also, print out a message so you know the Serial Monitor is running at the correct baud rate:

Code: [Select]
void setup()
{
  Serial.begin(9600);
  GPS.begin(9600);

  Serial.println( F("Starting...") );
}

You know there's a baud rate choice in the Serial Monitor window, right?  It should match whatever you put in Serial.begin.  If you get gibberish instead of "Starting...", then maybe your wires are too long, or not making good contact. 

This device does have a binary mode.  If the startup message comes out ok, then you get gibberish, the GPS device might be in binary mode, not NMEA mode.

Cheers,
/dev

chughtai538

I don't think it makes any difference, but I've always seen the Serial.begin first.  Also, print out a message so you know the Serial Monitor is running at the correct baud rate:

Code: [Select]
void setup()
{
  Serial.begin(9600);
  GPS.begin(9600);

  Serial.println( F("Starting...") );
}

You know there's a baud rate choice in the Serial Monitor window, right?  It should match whatever you put in Serial.begin.  If you get gibberish instead of "Starting...", then maybe your wires are too long, or not making good contact.  

This device does have a binary mode.  If the startup message comes out ok, then you get gibberish, the GPS device might be in binary mode, not NMEA mode.

Cheers,
/dev
So I checked the device with your code and the startup message is coming out ok but still no luck with the GPS output. So how do change from binary mode to NMEA mode?

This is the output i get in the serial window when serial is at 115200 and gps is 57600

Quote
££„£;Ü„£G\$„#8ãDÄG„X ££#GddäG$##£G DG„G\¤„$X ¤œD$ £8ã#$„#8㣣ߣÀÀG[¤$¤GþStarting...
˜äX {¤X@¸$GœÀG`Ä#œÀ Ž˜vgœÇ$Ä£G<ã$„#$'ÀäÇçgxñÀ$äG\[$'Ä#<¸$Çž-g8¸„G<ØÄ£<¸¤$'»dG<¼ŒŽ˜-¸G@;Û¤‡Gä„£8ã##£#cÄ£G¼Dcpa¤ ƒ¤ œGœÄ£G<ãlœÄ#<ÀäGÄ##Ä£

knut_ny

If that 'rubbish' appears in bursts, one pr second, if comes from the GPS.
That indicates that connections (mostly) OK
All reason to believe that GPS sends ASCII.

If it is freerunning, without pause (when USB serial is at 115200) that indicates bad connections.

I'd rewire. Use other pins (eg 4,5)  softw...beg..(4,5);  Pin 4 connects to GPS tx
Ny

/dev

So how do change from binary mode to NMEA mode?
According to the protocol spec, if you do this:

Code: [Select]
GPS.print( F("$PGCMD,16,1,1,1,1,1*6B\r\n") );
...it will start sending NMEA sentences GPRMC, GPVTG, GPGSA, GPGSV, and GPGGA at 1-second intervals.

If you do this:

Code: [Select]
GPS.print( F("$PGCMD,16,0,0,0,0,0*6A\r\n") );
...it will be in binary mode.  According to Note 2, anyway.

Before you do that, though, have you tried GPS.begin( 115200 )?  The spec says the default is 9600, but you can also choose 4800/9600/38400/57600/115200.  A developer on DIYDrones reports that the default baud rate is 38400, not 9600.

knut_ny makes a good point: if the gibberish is a constant stream, the pins are bad or the  connection wires are noisy.  If the gibberish comes out in 1-second bursts, with pauses in between, it is probably the baud rate or binary mode.

Cheers,
/dev

DHeart

Hi!
I'm having the same problem!
I've modified the sketch to run at 38400 following a tip from this thread and, almost, solved my problem.
Code: [Select]

void setup()  
{
    
  // connect at 115200 so we can read the GPS fast enough and echo without dropping chars
  // also spit it out
  Serial.begin(115200);
  Serial.println("Adafruit GPS library basic test!");

  // 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800
  GPS.begin(9600);
  
  // uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  // uncomment this line to turn on only the "minimum recommended" data
  //GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
  // For parsing data, we don't suggest using anything but either RMC only or RMC+GGA since
  // the parser doesn't care about other sentences at this time
  
  // Set the update rate
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);   // 1 Hz update rate
  // For the parsing code to work nicely and have time to sort thru the data, and
  // print it out we don't suggest using anything higher than 1 Hz


I've, also, changed the update rate to 1Hz and the type of output RMC.
I've tried various combinations of baud rates, and this is the only one that works best.
As you can see, I'm using a sketch and libraries from Adafruit and the Mediatek MT3329 GPS and adapter, showed in the pictures.



I get this output!

Code: [Select]

Time: 21:41:36.0
Date: 29/7/2015
Fix: 1 quality: 0
Location: 3711.8979N, 724.9903W
Location (in degrees, works with Google Maps): 37.1983, -7.4165
Speed (knots): 0.00
Angle: 0.00
Altitude: 0.00
Satellites: 0
$GPRMC,214137.000,A,3711.8979,N,00724.9903,W,0.00,0.00,290715,,,A*7F
$GPRMC,214138.000,A,3711/8979,N,00724.9903,W,0.00,0.00,290715,,,A*70

Time: 21:41:38.0
Date: 29/7/2015
Fix: 1 quality: 0
Location: 3711.8979N, 724.9903W
Location (in degrees, works with Google Maps): 37.1983, -7.4165
Speed (knots): 0.00
Angle: 0.00
Altitude: 0.00
Satellites: 0
$GPRMC,214139.000,A-3711.8979,N,00"¢rÊÊ‚šbº±0.00,0.08,290715,,,A*71
$GPRMC,214140.0˜0,A,3711.8979,N,00724.9903,W,0.00,0.00,29071š,,,A*7F

 

I've tried to send new commands to the GPS, but the sketch doesn't work. I'm assuming that is related to the libraries not having all the commands for the GPS.

Can anyone give me a hint?

Go Up