0
votes

I have connected a NEO-6M GPS module with an Arduino Uno and established serial communication between the two. The problem is that I only get integers from the GPS and not an NMEA-message as expected.

This seems to stay the same when the led is blinking - and thus established GPS connection - and when it's not blinking.

Has anybody encountered this problem? Any idea what I'm doing wrong? I can't see what I'm missing.

I also read some bad reviews about this module that it is very fragile and can be easily damaged, but I don't know how to check this (except for ordering a new one...)

Hardware Setup

Arduino 5V with NEO VCC
Arduino GND with NEO GND
Arduino Pin 3 (RX) with NEO TX
Arduino Pin 4 (TX) with NEO RX 

Code

#include <TinyGPS.h>
#include <SoftwareSerial.h> 

float lat = 28.5458,lon = 77.1703; // create variable for latitude and longitude object 
SoftwareSerial gpsSerial(3,4);//rx,tx
TinyGPS gps; // create gps object

void setup(){
    Serial.begin(9600); // connect serial
    Serial.println("running setup...");
    Serial.println("waiting for serial port to connect...");
    while (!Serial) {
    Serial.print("."); // wait for serial port to connect. Needed for native USB port only
    }

    Serial.println("starting serial communication gps module...");
    gpsSerial.begin(9600); // connect gps sensor
    Serial.println("setup complete");
}

void loop(){
    while(gpsSerial.available()){ // check for gps data
        Serial.println("gpsSerial is available");
        Serial.println(gpsSerial.read());
    }

    Serial.println("gpsSerial is not available");
    String latitude = String(lat,6);
    String longitude = String(lon,6);
    Serial.println(latitude+";"+longitude);
    delay(1000);
}

Serial Monitor Output

running setup...
waiting for serial port to connect...
starting serial communication gps module...
setup complete
gpsSerial is not available
28.545799;77.170303
gpsSerial is available
36
gpsSerial is available
71
gpsSerial is available
80
gpsSerial is available
82
gpsSerial is available
77
gpsSerial is available
67
gpsSerial is available
44
gpsSerial is available
44

Many thanks in advance!

1
us Serial.write(gpsSerial.read()) or Serial.println((char) gpsSerial.read())Juraj

1 Answers

0
votes

As pointed out by Juraj as comment to the question, I was using the wrong print command.

// Serial.println("gpsSerial is available");
// Serial.write(gpsSerial.read()); 

Serial.print((char) gpsSerial.read());

This results in a proper NMEA message

running setup...
waiting for serial port to connect...
starting serial communication gps module...
setup complete
gpsSerial is not available
28.545799;77.170303
$GPRMC,085416.00,V,,,,,,,080520,,,N*7C
$GPVTG,,,,,,,,,N*30
$GgpsSerial is not available
28.545799;77.170303
$GPRMC,085417.00,V,,,,,,,080520,,,N*7D
$GPVTG,,,,,,,,,N*30

Thanks Juraj!