Read NMEA strings over serial port with MT3329 and Arduino Mega 2560
i trying read nmea strings otput mt3329 gps mediatek. code have written of strings output , rest first character in string.
example:
there supposed other strings titles of gpgga , gpgsa part of string output 'g'.
i using arduino mega , connecting gps serial1. have left en pin on gps unconnected since i'm not sure does.
here code:
i think wrong in code. maybe hardware. i'm not sure.
thanks suggestions!
example:
code: [select]
returned gps datagps buffer: gprmc,001027.035,v,,,,,0.00,0.00,060180,,,n*40
end
getting gps data
unlocked
locked
returned gps datagps buffer: g
end
getting gps data
unlocked
locked
returned gps datagps buffer: gpgsv,1,1,00*79
there supposed other strings titles of gpgga , gpgsa part of string output 'g'.
i using arduino mega , connecting gps serial1. have left en pin on gps unconnected since i'm not sure does.
here code:
code: [select]
// arduino mega 2560 r3
#include <string.h>
#define dbg(str) serial.print(str)
#define portgps serial1
long int timergps = 0;
int returnedgps = 0;
int lockedgps = 1;
char buffgps[50];
int igps = 0;
void setup(){
serial.begin(9600); // arduino computer
dbg("debug port 0 initialized\n");
portgps.begin(38400); // mt3328 arduino
dbg("peripheral port initialized\n");
}
#define timeout 5000
void loop(){
returnedgps = 0;
timergps = millis();
dbg("getting gps data\n");
while((millis() - timergps < timeout) && !returnedgps){
getgps();
}
if(!returnedgps){
dbg("gps timed out!\n");
}else dbg("returned gps data");
dbg("gps buffer: ");
dbg(buffgps);
dbg("\nend\n");
}
void getgps(){
int inbyte;
if(portgps.available()){
inbyte = portgps.read();
}
if(lockedgps){
if(inbyte == 36) {
dbg("unlocked\n");
lockedgps = 0;
igps = 0;
}
}
else{
if(inbyte == 10){
dbg("locked\n");
lockedgps = 1;
returnedgps = 1;
}
else buffgps[igps] = inbyte;
igps++;
}
}
i think wrong in code. maybe hardware. i'm not sure.
thanks suggestions!
i suggest use tinygps12 library mikal hart... it's whole lot easier parsing gps data on own. works me..
i suggest find out en pin might important
i suggest find out en pin might important
Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > Read NMEA strings over serial port with MT3329 and Arduino Mega 2560
arduino
Comments
Post a Comment