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.
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.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.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.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.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.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.pin1
connected to the SPK1 of the DFPlayer MINI.pin2
connected to the SPK2 of the DFPlayer MINI.#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.