Arduino Nano GPS Module

The Arduino Nano GPS Module project enables an Arduino Nano to receive and interpret data from a GPS receiver, allowing you to track location coordinates. This project is valuable for applications such as vehicle tracking, navigation systems, and location-based services.

Components Needed

  • Arduino Nano
  • GPS module (e.g. NEO‑6M)
  • Jumper wires

Circuit Setup

1. Connect GPS module to Arduino Nano:

Connect the RX pin of the GPS module to pin 2 (TX) on the Arduino Nano.

Connect the TX pin of the GPS module to pin 3 (RX) on the Arduino Nano.

Connect VCC to 5V and GND to GND on the Arduino Nano.

Instructions

1. Circuit Setup:

Wire the GPS module to the Arduino Nano according to the circuit setup.

2. Code Upload:

Connect the Arduino Nano to your computer using a USB cable.

Open the Arduino IDE and paste the provided code.

Select the appropriate board (Arduino Nano) and port from the Tools menu.

Upload the code to the Arduino Nano.

3. Testing:

Once the code is uploaded, open the serial monitor.

Observe the latitude and longitude coordinates printed on the serial monitor to track the GPS location.

Applications

Vehicle Tracking: Monitor and track the real‑time location of vehicles for logistics and fleet management.

Navigation Systems: Integrate GPS sensors into navigation devices for accurate positioning and routing.

Location‑Based Services: Develop applications that provide location‑specific information and services based on GPS data.

Notes

Ensure correct wiring and connection between the GPS module and the Arduino Nano.

The GPS module requires a clear view of the sky to receive satellite signals effectively.

Experiment with different GPS modules and antenna configurations for optimal performance and accuracy.

Program: Arduino Nano GPS Tracker with TinyGPS++
#include <SoftwareSerial.h>
#include <TinyGPSPlus.h>
#include <math.h>

// SoftwareSerial: GPS TX → Nano pin 3 (RX), GPS RX → Nano pin 2 (TX)
SoftwareSerial gpsSerial(3, 2);
TinyGPSPlus gps;

void setup() {
  Serial.begin(9600);
  gpsSerial.begin(9600);
  Serial.println("=== ARDUINO NANO GPS TRACKER ===");
  Serial.println("Lat         | Lng         | Sat");
}

void loop() {
  // Read GPS data
  while (gpsSerial.available() > 0) {
    if (gps.encode(gpsSerial.read())) {
      if (gps.location.isValid()) {
        Serial.print("Lat: ");
        Serial.print(gps.location.lat(), 6);
        Serial.print(" | Lng: ");
        Serial.print(gps.location.lng(), 6);
        Serial.print(" | Sat: ");
        Serial.println(gps.satellites.value());
      }
    }
  }
  delay(1000);
}
Program: Professional Gas Detection + Multi-Stage Alarms
#include <math.h>

// Arduino Nano GAS SENSOR - INDUSTRIAL AIR QUALITY MONITOR
// A0=Analog | PPM calc + 3-stage alarms + buzzer + LED

const int gasPin = A0;
const int buzzerPin = 8;
const int ledPin = 13;
float baseline = 0;
float cleanAir = 0;

void setup() {
  Serial.begin(9600);
  pinMode(buzzerPin, OUTPUT);
  pinMode(ledPin, OUTPUT);

  Serial.println("=== GAS SENSOR PROFESSIONAL MONITOR ===");
  Serial.println("Raw  PPM   | Status | Alarm");

  // 30s baseline calibration (clean air)
  calibrateBaseline();
}

void loop() {
  int raw = analogRead(gasPin);
  float ppm = calculatePPM(raw);

  String status = getGasStatus(ppm);
  triggerAlarm(ppm);

  // Live monitoring (no printf)
  Serial.print(raw);
  Serial.print("  ");
  Serial.print(ppm, 1);
  Serial.print(" | ");
  Serial.print(status);
  Serial.print(" | ");
  Serial.println(getAlarmLevel(ppm));

  delay(500);
}

void calibrateBaseline() {
  Serial.println("CALIBRATING BASELINE (30s clean air)...");
  long sum = 0;
  for(int i=0; i<60; i++) {
    sum += analogRead(gasPin);
    delay(500);
  }
  cleanAir = sum / 60.0;
  Serial.print("Clean air baseline: ");
  Serial.println(cleanAir, 1);
}

float calculatePPM(int raw) {
  // Non-linear MQ curve approximation
  float ratio = (float)raw / cleanAir;
  if(ratio < 1.0) return 0;

  // Rs/R0 vs PPM logarithmic curve
  float ppm = pow(10.0, (log10(ratio) - 0.3) / -0.85) * 10.0;
  return constrain(ppm, 0, 10000);
}

String getGasStatus(float ppm) {
  if(ppm < 100) return "CLEAN";
  if(ppm < 500) return "NORMAL";
  if(ppm < 2000) return "WARNING";
  if(ppm < 5000) return "DANGER";
  return "CRITICAL";
}

String getAlarmLevel(float ppm) {
  if(ppm < 1000) return "OFF";
  if(ppm < 3000) return "LOW";
  if(ppm < 7000) return "MEDIUM";
  return "HIGH";
}

void triggerAlarm(float ppm) {
  if(ppm > 1000) {
    digitalWrite(ledPin, HIGH);
    if(ppm > 3000) {
      warningAlarm();
      if(ppm > 7000) criticalAlarm();
    }
  } else {
    digitalWrite(ledPin, LOW);
    noTone(buzzerPin);
  }
}

void warningAlarm() {
  tone(buzzerPin, 1000, 300);
  Serial.println("*** WARNING: Elevated gas levels ***");
}

void criticalAlarm() {
  for(int i=0; i<3; i++) {
    tone(buzzerPin, 2000, 500);
    delay(600);
  }
  Serial.println("*** CRITICAL: GAS LEAK! EVACUATE! ***");
}