Getting GPS data from NEO 6 M GPS sensor

Hi everyone
I am new to Arduino and am using MEGA to get data from NEO-6M (hobbyking). I connected my GPS module to PORT 1 and am trying to read serial data. I am getting junk values. Here is my code:

void setup()
{
Serial.begin(38400);
Serial1.begin(38400);
}

void loop()
{
if (Serial1.available() > 0)
{
char data_read=Serial1.read();
Serial.print(data_read);
}

}

Please help me out :slight_smile:

Chandra

Junk values could be a baud rate mismatch. Do you have the serial monitor set to 38400? Are you sure that the GPS defaults to (or is set to) that rate?

Hi Wildbill
I have set the serial monitor to 38400 and have tried all the available baud rates (keeping the serial and serial1 baud rates same). The default value is given as 38400 for factory setting. Link: http://www.hobbyking.com/hobbyking/store/__31135__neo_6m_gps_module.html

Please help me out :slight_smile:

Thanks again

Chandra

The serial and serial1 rates don't have to be the same - indeed it's better if Serial is running faster than the GPS on Serial1 - less chance of overflow.

What does this "junk" data look like?

Hi wildbill
The data looks like the one attached in the image. I am now using this code with softwareserial.

#include “SoftwareSerial.h”

SoftwareSerial mySerial(10, 11); // RX, TX

void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(115200);

Serial.println(“uBlox Neo 6M”);

// set the data rate for the SoftwareSerial port
mySerial.begin(38400);

}

void loop() // run over and over
{
if (mySerial.available())
Serial.write(mySerial.read());

}

Thanks once again

Chandra

You need to determine what rate the gps is trying to send serial data to the arduino. The default speed will be in the device datasheet, it is unlikely to be 38000, more likely 9600.

Once you have the device working, then it is usually possible to send a command to it, to change the serial speed. But, you need to start with the default speed it uses when it powers on.

The site he got that GPS from clearly states it would be in default mode at 38.400.
The datasheet of the unit however tells that default is 9600 (as suggested by others).

I have one of those GPS modules and it communicates at 9600 baud.

Hi, it seems you use mega 2560
For GPS data it comes with NMEA sentences, you can use TinyGPS++ library to capture the certain data you are interested in :slight_smile:
Here goes the link to download the library together with introduction: TinyGPS++ | Arduiniana
Hope you'll soon have FUN with your GPS module :wink:
Plus since NEO 6 gives a goddamn 26s as cold start, just be patient until it gets the data like latitude & longitude