Welcome to AAC.I am trying to get the current location from A9G board connected to Arduino. I am not getting the longitude and latitude. The code i tried. (I was not able to paste the code. So, i have pasted it as image).
View attachment 316941
GPSRD:? The NMEA message itself looks like:$GNGGA,000840.261,2236.3719,N,11350.4081,E,0,0,,153.2,M,-3.2,M,,*4F$GNGGA at the front is unique and on the same line, guaranteed. But even more problematic is that Serial.read() returns only one byte! You need to use Serial.readString() or possibly Serial.readStringUntil() using * as the terminator. It appears this will work given the message.Serial.flush() to clear the buffer for the next message.#include <SoftwareSerial.h>
// Define software serial communication pins
const int gpsRxPin = 7;
const int gpsTxPin = 8;
// Create software serial object
SoftwareSerial gpsSerial(gpsRxPin, gpsTxPin);
void setup() {
// Initialize serial communication for debugging (optional)
Serial.begin(9600);
// Begin communication with GPS module at 9600 baud
gpsSerial.begin(9600);
delay(1000);
}
void loop() {
// Check for available data from GPS module
gpsSerial.println("AT");
delay(1000);
if (gpsSerial.available()) {
String response = gpsSerial.readStringUntil('\n');
Serial.println("Response: " + response);
if (response.indexOf("OK") != -1) {
Serial.println("AT command successful!");
} else {
Serial.println("AT command failed!");
}
} else {
Serial.println("No response from GPS module!");
}
delay(1000);
}
$GNGGA,000840.261,2236.3719,N,11350.4081,E,0,0,,153.2,M,-3.2,M,,*4F