Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

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

Image 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

  • Microcontroller board based on the ATmega328P
  • It has digital I/O pins, analog input pins, and various power pins.
  • Used as the main controller for interfacing with the GPS module, DFPlayer MINI, and LCD screen.

Neo 6M GPS Module

  • A GPS receiver module that provides location data.
  • Communicates with the Arduino via serial TX and RX pins.

DFPlayer MINI

  • A compact audio player module that can play files from a microSD card.
  • Interfaces with the Arduino through serial communication for playing audio announcements.

POWER SUPPLY 12V 5AMP

  • Provides the necessary power to the circuit.
  • Outputs 12V-24V DC from a 220V AC input.

LCD screen 16x2 I2C

  • An alphanumeric liquid crystal display with 16 characters by 2 lines.
  • Uses I2C communication to display data from the Arduino.

DC DC converter

  • Steps down the voltage from the power supply to a lower voltage suitable for the Arduino and other components.

Loudspeaker

  • An audio output device connected to the DFPlayer MINI to play sound.

Wiring Details

Arduino UNO

  • 5V pin connected to the VCC pins of the LCD screen, Neo 6M GPS Module, and DFPlayer MINI.
  • GND pin connected to the GND pins of the LCD screen, Neo 6M GPS Module, DFPlayer MINI, and the GND OUT of the DC DC converter.
  • Vin pin connected to the +VCC OUT of the DC DC converter.
  • A4 (SDA) pin connected to the SDA pin of the LCD screen.
  • A5 (SCL) pin connected to the SCL pin of the LCD screen.
  • D11 pin connected to the TX pin of the DFPlayer MINI.
  • D10 pin connected to the RX pin of the DFPlayer MINI.
  • D3 pin connected to the RX pin of the Neo 6M GPS Module.
  • D2 pin connected to the TX pin of the Neo 6M GPS Module.

Neo 6M GPS Module

  • VCC pin connected to the 5V output from the Arduino.
  • GND pin connected to the common ground.
  • TX pin connected to the D2 pin of the Arduino.
  • RX pin connected to the D3 pin of the Arduino.

DFPlayer MINI

  • VCC pin connected to the 5V output from the Arduino.
  • GND pin connected to the common ground.
  • TX pin connected to the D11 pin of the Arduino.
  • RX pin connected to the D10 pin of the Arduino.
  • SPK1 and SPK2 pins connected to the pin1 and pin2 of the Loudspeaker, respectively.

POWER SUPPLY 12V 5AMP

  • GND (DC) pin connected to the GND IN of the DC DC converter.
  • 12V-24V Output (DC) pin connected to the +VCC IN of the DC DC converter.

LCD screen 16x2 I2C

  • VCC pin connected to the 5V output from the Arduino.
  • GND pin connected to the common ground.
  • SDA pin connected to the A4 pin of the Arduino.
  • SCL pin connected to the A5 pin of the Arduino.

DC DC converter

  • GND IN pin connected to the GND (DC) of the POWER SUPPLY.
  • +VCC IN pin connected to the 12V-24V Output (DC) of the POWER SUPPLY.
  • GND OUT pin connected to the common ground.
  • +VCC OUT pin connected to the Vin pin of the Arduino.

Loudspeaker

  • pin1 connected to the SPK1 of the DFPlayer MINI.
  • pin2 connected to the SPK2 of the DFPlayer MINI.

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.