Simple GPS Programming

The GPS module that I have is Ublox GPS Neo 6M. I did program it and I managed to pull some data out from the GPS. However I was monitoring the GPS with polling method and now I plan to monitor the GPS with interrupt method with using serialEvent().

The board that I used is Arduino Mega and it has 4 serial ports and GPS is connected to serial port 3.

Here is the code:

void setup()
  //Serial 3 Is For GPS


void loop() 



//void serialEvent()
//  Serial3.write(;
//void serial3Event()
//  Serial.write(;

With polling method inside the loop(), I could read the packet from GPS module itself and it is able to feed me with coordinates when I connect the COM to Ublox U-Center. However when the method is interrupt method, there is no any response from the board. Can anyone point out what is the problem of it? Is it because interrupt is triggered when it is inside an interrupt?

now I plan to monitor the GPS with interrupt method with using serialEvent().

The serialEvent() function is NOT an interrupt handler. It is a lame replacement for

  if(Serial.available() > 0)

at the top or bottpm of loop().

Since serialEvent() is NOT interrupt driven, none of your questions about interrupts make sense.

Like PaulS said, serialEvent is lame. It used to be an interrupt handler, but not any more.

True interrupt-style GPS parsing can be seen in the NeoGPS example program, NMEA_isr.ino. It also requires NeoHWSerial. Be sure to read the notes about NeoHWSerial, because your code has to use NeoSerial and NeoSerial3 instead of Serial and Serial3, everywhere.

There are other advantages to NeoGPS, too. It’s smaller, faster, more accurate and more reliable than all other libraries. It can be configured to parse only the fields and sentences that you really use in your sketch. NeoGPS is available from the link above, or from the Arduino IDE Library Manager, under the menu Sketch → Include Library → Manage Libraries.