#include <SoftwareSerial.h>
SoftwareSerial gps(0,1); // RX, TX Connect GPS TX to pin 3
void setup()
{
Serial.begin(115200); // be sure to check lower right corner info in an open 'serial windows'
gps.begin(9600); // may be 4800, 19200,38400 or 57600
}
void loop()
{
if (gps.available()) Serial.write(gps.read());
}
The pins 0 and 1 are the RX and TX pins of HARDWARE SERIAL!
You cannot use those pins for software serial in addition.
The MEGA board has 4 hardware serials, so you need not to use unreliable SoftWareSerial in any way.
Just connect your GPS module to let's say the RX3 pin on your MEGA, which is pin-15.
RX3 is for receiving on Serial3.
You most likely will not want to send anything to your GPS, so do not connect TX3 as this provides 5V output and I'm not sure if your GPS module is really ready to accept 5V I/O voltage from your Arduino. Look up the datasheet before you connect (when needed)!
So connect GPS-TX to let's say Arduino-RX3 and use:
// Test code for Arduino MEGA and receiving serial data on RX3
void setup()
{
Serial.begin(115200); // be sure to check lower right corner info in an open 'serial windows'
Serial3.begin(9600); // may be 4800, 19200,38400 or 57600
}
void loop()
{
if (Serial3.available()) Serial.write(Serial3.read());
}
The pins 0 and 1 are the RX and TX pins of HARDWARE SERIAL!
You cannot use those pins for software serial in addition.
The MEGA board has 4 hardware serials, so you need not to use unreliable SoftWareSerial in any way.
Just connect your GPS module to let's say the RX3 pin on your MEGA, which is pin-15.
RX3 is for receiving on Serial3.
You most likely will not want to send anything to your GPS, so do not connect TX3 as this provides 5V output and I'm not sure if your GPS module is really ready to accept 5V I/O voltage from your Arduino. Look up the datasheet before you connect (when needed)!
So connect GPS-TX to let's say Arduino-RX3 and use:
// Test code for Arduino MEGA and receiving serial data on RX3
void setup()
{
Serial.begin(115200); // be sure to check lower right corner info in an open 'serial windows'
Serial3.begin(9600); // may be 4800, 19200,38400 or 57600
}
void loop()
{
if (Serial3.available()) Serial.write(Serial3.read());
}
I try to connect the RX pin of the GPS to the RX3 (pin 15) and TX to TX3(pin 16)
But nothing happen in the serial monitor, again.....