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

Arduino UNO Based GPS Bus Stop Announcement System with DFPlayer and I2C LCD Display

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based GPS Bus Stop Announcement System with DFPlayer and I2C LCD Display

Circuit Documentation

Summary of the Circuit

The circuit described in the provided inputs is a bus stop system that utilizes an Arduino UNO as the central microcontroller. The system is designed to read GPS data from a Neo 6M GPS Module, play audio announcements through a DFPlayer MINI module connected to a Loudspeaker, and display information on an LCD screen 16x2 with I2C interface. The circuit is powered by a 12V 5A Power Supply, and a DC-DC converter is used to step down the voltage to a level suitable for the Arduino and other components.

Component List

Arduino UNO

Neo 6M GPS Module

DFPlayer MINI

POWER SUPPLY 12V 5AMP

LCD screen 16x2 I2C

DC DC converter

Loudspeaker

Wiring Details

Arduino UNO

Neo 6M GPS Module

DFPlayer MINI

POWER SUPPLY 12V 5AMP

LCD screen 16x2 I2C

DC DC converter

Loudspeaker

Documented Code

#include <SoftwareSerial.h>
#include <TinyGPS++.h>
#include <DFRobotDFPlayerMini.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Pin definitions
const int gpsRxPin = 2;
const int gpsTxPin = 3;
const int dfPlayerRxPin = 10;
const int dfPlayerTxPin = 11;

// Create objects for GPS, DFPlayer, and LCD
TinyGPSPlus gps;
SoftwareSerial gpsSerial(gpsRxPin, gpsTxPin);
SoftwareSerial dfPlayerSerial(dfPlayerRxPin, dfPlayerTxPin);
DFRobotDFPlayerMini dfPlayer;
LiquidCrystal_I2C lcd(0x27, 16, 2); // Adjust the I2C address if necessary

void setup() {
  // Initialize serial communication
  Serial.begin(9600);
  gpsSerial.begin(9600);
  dfPlayerSerial.begin(9600);

  // Initialize DFPlayer
  if (!dfPlayer.begin(dfPlayerSerial)) {
    Serial.println("DFPlayer Mini not detected");
    while (true);
  }
  dfPlayer.volume(20); // Set volume level (0-30)

  // Initialize LCD
  lcd.begin();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Bus Stop System");

  // Initialize GPS
  Serial.println("Initializing GPS...");
}

void loop() {
  // Read GPS data
  while (gpsSerial.available() > 0) {
    gps.encode(gpsSerial.read());
  }

  // Check if GPS data is valid
  if (gps.location.isUpdated()) {
    double latitude = gps.location.lat();
    double longitude = gps.location.lng();

    // Display GPS data on LCD
    lcd.setCursor(0, 1);
    lcd.print("Lat: ");
    lcd.print(latitude, 6);
    lcd.setCursor(0, 2);
    lcd.print("Lon: ");
    lcd.print(longitude, 6);

    // Check if the bus is near a specific location (example coordinates)
    if (isNearBusStop(latitude, longitude)) {
      playAnnouncement();
    }
  }
}

bool isNearBusStop(double lat, double lon) {
  // Example bus stop coordinates
  const double busStopLat = 37.7749;
  const double busStopLon = -122.4194;
  const double threshold = 0.001; // Adjust the threshold as needed

  return (abs(lat - busStopLat) < threshold && abs(lon - busStopLon) < threshold);
}

void playAnnouncement() {
  dfPlayer.play(1); // Play the first audio file on the SD card
  delay(10000); // Wait for the announcement to finish
}

This code is responsible for initializing the GPS module, DFPlayer, and LCD screen. It reads GPS data, checks if the bus is near a predefined bus stop, and if so, plays an audio announcement while displaying the latitude and longitude on the LCD screen.