Interruption NEO6M

Hello, I am doing a project that detects accidents by accelerometers and gives the location every 15 seconds.
As it is necessary to read all the time the value of the accelerometer I would like to use the neo6m through interruptions. But I can not get any valid reading of longitude and latitude when i use interruptions.
Does anyone have any idea?
Thank you very much.

Given the lack of information supplied, details of the project, the Arduino used, the GPS used, the connections used, then no I dont have any idea.

What information do you need srnet?

Maybe we could start with your code?

Okay I use NEO-6M GPS, Arduino Uno and rn i have the RX of the GPS connected to pin 2 and TX to 3.

I tried with diferrent codes. The last one:
<

#include <TinyGPS++.h>

// NEO-6M GPS module connections
#define RX_PIN 4
#define TX_PIN 3

// Create an instance of the TinyGPS++ library
TinyGPSPlus gps;

// Define the interruption pin and its handler function
#define INT_PIN 2 //TX_GPS
volatile bool interruption = false;
void handleInterruption() {
interruption = true;
}

void setup() {
// Open serial communication with a baud rate of 9600
Serial.begin(9600);

// Configure the NEO-6M GPS module serial connection
Serial1.begin(9600, SERIAL_8N1, RX_PIN, TX_PIN);

// Configure the interruption pin
pinMode(INT_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(INT_PIN), handleInterruption, RISING);
}

void loop() {
// Check if a new GPS data is available
if (interruption) {
interruption = false;

// Read and process the GPS data
while (Serial1.available()) {
  gps.encode(Serial1.read());
}

// Check if the GPS data is valid
if (gps.location.isValid()) {
  // Print the longitude and latitude values
  Serial.print("Longitude: ");
  Serial.println(gps.location.lng(), 6);
  Serial.print("Latitude: ");
  Serial.println(gps.location.lat(), 6);
}

}
}

Posts #5 and #6 quote different pin connections ?

Yes sorry you are right.

Do you see a problem?

Yes sorry you are right rn i hace the connections like the code, and i change the SERIAL_8N1.

And still not working

Do you have GND connected between the Arduino and GPS ?

Yes

Show us a photo of the setup.

The thing is that the NEO-6M gps is working without interruptions, but when i use interruptions it doesnt

That does not make sense ?

'rn i hace the connections like the code'

?

During my professional time the company, designing and building ware house fork lifters, had started developing an "impact detector", and it turned out not doing what the customers wanted. Pure head on collisions were not interesting but more soft ones like a driver cutting a corner and bending the legs of the ware house shelves.

Which accelerometer are You using? Datasheet?

The NEO6-M is a 3.3 volt logic device. It looks like You use a 5 volt Mega. In that case use a 3.3/5 volt level converter for the Mega Tx.

THIS IS THE RIGHT CODE:

#include <SoftwareSerial.h>

SoftwareSerial gpsSerial(2, 3); // RX, TX

void setup()
{
Serial.begin(115200);
gpsSerial.begin(9600);

attachInterrupt(digitalPinToInterrupt(4), gpsDataHandler, RISING);
}

void loop()
{
// Do nothing here, the GPS interrupt will handle the GPS data
}

void gpsDataHandler()
{
if (gpsSerial.available() > 0)
{
String gpsData = gpsSerial.readStringUntil('\n');
if (gpsData.startsWith("$GPGGA"))
{
int commaIndex1 = gpsData.indexOf(",");
int commaIndex2 = gpsData.indexOf(",", commaIndex1 + 1);
int commaIndex3 = gpsData.indexOf(",", commaIndex2 + 1);
int commaIndex4 = gpsData.indexOf(",", commaIndex3 + 1);
int commaIndex5 = gpsData.indexOf(",", commaIndex4 + 1);
int commaIndex6 = gpsData.indexOf(",", commaIndex5 + 1);
int commaIndex7 = gpsData.indexOf(",", commaIndex6 + 1);

  if (commaIndex7 > commaIndex6 + 1)
  {
    String latitude = gpsData.substring(commaIndex2 + 1, commaIndex3);
    String longitude = gpsData.substring(commaIndex4 + 1, commaIndex5);

    Serial.print("Latitude: ");
    Serial.println(latitude);
    Serial.print("Longitude: ");
    Serial.println(longitude);
  }
}

}
}