Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO-Based GPS and Environmental Monitoring System

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based GPS and Environmental Monitoring System

Circuit Documentation

Summary

This circuit integrates an Arduino UNO microcontroller with a GPS NEO 6M module, an MQ-2 gas sensor, and a DHT22 temperature and humidity sensor. The Arduino UNO serves as the central controller, reading data from the sensors and the GPS module, and processing this data for further use.

Component List

  1. Arduino UNO

    • Description: A microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. GPS NEO 6M

    • Description: A GPS module used for obtaining geographical coordinates.
    • Pins: VCC, RX, TX, GND
  3. MQ-2

    • Description: A gas sensor used for detecting various gases including LPG, i-butane, propane, methane, alcohol, Hydrogen, and smoke.
    • Pins: GND, VCC, ANALOG, Digital
  4. DHT22

    • Description: A temperature and humidity sensor.
    • Pins: +, Out, -

Wiring Details

Arduino UNO

GPS NEO 6M

MQ-2

DHT22

Code Documentation

Code Overview

The provided code initializes the GPS module and reads data from it. The data is then processed to extract the geographical coordinates, which are displayed on the Serial Monitor.

Code Listing

#include <SoftwareSerial.h>
#include <TinyGPS++.h>

// GPS NEO 6M connections
#define GPS_RX 2
#define GPS_TX 3

SoftwareSerial gpsSerial(GPS_RX, GPS_TX);
TinyGPSPlus gps;

void setup() {
  Serial.begin(9600);  // Start serial communication for debugging
  gpsSerial.begin(9600);  // Start GPS communication

  Serial.println("GPS Test Started...");
}

void loop() {
  // Read data from GPS module
  while (gpsSerial.available()) {
    char c = gpsSerial.read();
    Serial.write(c);  // Print raw GPS data to Serial Monitor

    gps.encode(c);  // Feed data to the TinyGPS++ library

    // If a valid GPS fix is available, display the coordinates
    if (gps.location.isUpdated()) {
      displayGPSData();  // Display current GPS data (lat/lng)
    }
  }

  // Optional: Delay to avoid flooding the serial monitor with too many updates
  delay(1000);  
}

void displayGPSData() {
  // Only display if the GPS location is valid
  if (gps.location.isValid()) {
    float latitude = gps.location.lat();
    float longitude = gps.location.lng();
    Serial.print("Latitude: ");
    Serial.print(latitude, 6);  // Print latitude with 6 decimal places
    Serial.print(" Longitude: ");
    Serial.println(longitude, 6);  // Print longitude with 6 decimal places
  } else {
    Serial.println("GPS signal not available.");
  }
}

Code Explanation