0

I am using the trying to get data from the Neo-6M GPS module with an Arduino mega, but, the condition 'While (gpsSerial.available()> 0' is being met. I believe this means the no bytes are being transferred from the module to the serial port but I'm not sure why. The light on the Neo-6M was blinking which means it getting a lock but not giving out the data.

#include <SoftwareSerial.h>
// Choose two Arduino pins to use for software serial
int RXPin = 19;
int TXPin = 18;
//Default baud of NEO-6M is 9600
int GPSBaud = 9600;
// Create a software serial port called "gpsSerial"
SoftwareSerial gpsSerial(RXPin, TXPin);
void setup()
{
 // Start the Arduino hardware serial port at 9600 baud
 Serial.begin(9600);
 // Start the software serial port at the GPS's default baud
 gpsSerial.begin(GPSBaud);
 Serial.write("123");
}
void loop()
{
 // Displays information when new sentence is available.
 while (gpsSerial.available() > 0)
 Serial.write(gpsSerial.read());
}

I had it working on an Uno by connecting to pins 2,3 rather then 18 and 19. I have also tried swapping the 18 and 19 pins over but still noting.

Thanks for the help

EDIT: I have the RX and TX plugged into the mega at pins 1 and 2, however, it will only print GPS information when the reset button is pressed or held down

asked Mar 11, 2019 at 17:39

1 Answer 1

0

Not all pins on the Mega support software serial, have a read below:

https://www.arduino.cc/en/Reference/SoftwareSerial

Pins 18 / 19 are actually hardware serial pins so should not need the use of software serial.

Edit, should have noted to use hardware pins 18 / 19 you would use the constructor Serial1.begin(9600)

answered Mar 12, 2019 at 3:29

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.