The NEO-6M is the GPS module in vehicle trackers, drone projects and school “where am I” builds. It streams NMEA text at 9600 baud; the TinyGPSPlus library turns that into latitude, longitude and time.
On the Nano the module’s TX goes to D4, read with SoftwareSerial. The GPS RX is optional; if you wire it, use a divider because the module is 3.3 V logic. The sketch prints a line every two seconds, including Indian Standard Time.
Wiring
| Arduino Nano | NEO-6M GPS module (GY-NEO6MV2) | Wire | Notes |
|---|---|---|---|
| 5V | VCC | red | The module has its own 3.3 V regulator. |
| D3 | RX | yellow | Via 1 kΩ / 2 kΩ divider — Optional — only needed to send configuration commands. |
| D4 | TX | green | GPS TX (3.3 V) into SoftwareSerial RX — read fine by the Nano. |
| GND | GND | black |
3.3–5 V (on-board 3.3 V regulator) part, 5 V board. The module’s TX is a 3.3 V signal, which every board reads fine. Its RX pin is 3.3 V logic: from a 5 V Arduino TX, add a 1 kΩ / 2 kΩ divider. You only need RX if your sketch sends configuration commands.
Board quirks
- The Nano’s hardware serial (RX0/TX1) is taken by USB, so the GPS uses SoftwareSerial at 9600 baud. Don’t print long lines while NMEA arrives, or SoftwareSerial loses characters.
- First fix (cold start) takes 30 s to several minutes, and only with sky in view. Indoors you will usually see “no fix”.
- The blue LED on the module blinks once a second when it has a fix; steady or off means still searching.
- GPS time is UTC; the sketch adds 5 h 30 min for IST. The date also changes at 05:30 IST, which the simple sketch ignores.
- The coin cell (or super-cap) on the module keeps almanac data so the next fix is faster. If it is flat, every start is a cold start.
Code
// NEO-6M GPS on an Arduino Nano via SoftwareSerial, printing position, satellites and IST time.
// GPS TX → D4 (Nano RX), GPS RX ← D3 through a 1 kΩ / 2 kΩ divider, VCC → 5V, GND → GND.
#include <SoftwareSerial.h>
#include <TinyGPSPlus.h>
SoftwareSerial gpsSerial(4, 3); // RX, TX
TinyGPSPlus gps;
void setup() {
Serial.begin(115200);
gpsSerial.begin(9600); // NEO-6M default
Serial.println(F("Waiting for a fix - take the antenna outdoors or near a window"));
}
void printIst() {
if (!gps.time.isValid()) return;
int minutes = gps.time.hour() * 60 + gps.time.minute() + 330; // UTC + 5:30
minutes %= 1440;
char buf[12];
snprintf(buf, sizeof(buf), "%02d:%02d:%02d", minutes / 60, minutes % 60, gps.time.second());
Serial.print(F(" IST "));
Serial.print(buf);
}
void loop() {
while (gpsSerial.available()) gps.encode(gpsSerial.read());
static unsigned long last = 0;
if (millis() - last < 2000) return;
last = millis();
if (gps.charsProcessed() < 10) {
Serial.println(F("No data from GPS - check TX -> D4 and 9600 baud"));
return;
}
Serial.print(F("Sats: "));
Serial.print(gps.satellites.isValid() ? (int)gps.satellites.value() : 0);
if (gps.location.isValid()) {
Serial.print(F(" Lat: "));
Serial.print(gps.location.lat(), 6);
Serial.print(F(" Lng: "));
Serial.print(gps.location.lng(), 6);
} else {
Serial.print(F(" (no fix yet)"));
}
printIst();
Serial.println();
}// NEO-6M GPS on an Arduino Nano via SoftwareSerial, printing position, satellites and IST time.
// GPS TX → D4 (Nano RX), GPS RX ← D3 through a 1 kΩ / 2 kΩ divider, VCC → 5V, GND → GND.
#include <SoftwareSerial.h>
#include <TinyGPSPlus.h>
SoftwareSerial gpsSerial(4, 3); // RX, TX
TinyGPSPlus gps;
void setup() {
Serial.begin(115200);
gpsSerial.begin(9600); // NEO-6M default
Serial.println(F("Waiting for a fix - take the antenna outdoors or near a window"));
}
void printIst() {
if (!gps.time.isValid()) return;
int minutes = gps.time.hour() * 60 + gps.time.minute() + 330; // UTC + 5:30
minutes %= 1440;
char buf[12];
snprintf(buf, sizeof(buf), "%02d:%02d:%02d", minutes / 60, minutes % 60, gps.time.second());
Serial.print(F(" IST "));
Serial.print(buf);
}
void loop() {
while (gpsSerial.available()) gps.encode(gpsSerial.read());
static unsigned long last = 0;
if (millis() - last < 2000) return;
last = millis();
if (gps.charsProcessed() < 10) {
Serial.println(F("No data from GPS - check TX -> D4 and 9600 baud"));
return;
}
Serial.print(F("Sats: "));
Serial.print(gps.satellites.isValid() ? (int)gps.satellites.value() : 0);
if (gps.location.isValid()) {
Serial.print(F(" Lat: "));
Serial.print(gps.location.lat(), 6);
Serial.print(F(" Lng: "));
Serial.print(gps.location.lng(), 6);
} else {
Serial.print(F(" (no fix yet)"));
}
printIst();
Serial.println();
}Library: TinyGPSPlus (Mikal Hart) — compiled with TinyGPSPlus 1.0.3.
Expected serial output
Waiting for a fix - take the antenna outdoors or near a window
Sats: 0 (no fix yet) IST 14:31:05
Sats: 7 Lat: 12.971599 Lng: 77.594566 IST 14:33:19Waiting for a fix - take the antenna outdoors or near a window Sats: 0 (no fix yet) IST 14:31:05 Sats: 7 Lat: 12.971599 Lng: 77.594566 IST 14:33:19