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

Arduino Nano GPS Speed-Triggered Audio Player with DFPlayer Mini

Image of Arduino Nano GPS Speed-Triggered Audio Player with DFPlayer Mini

Circuit Documentation

Summary

This circuit integrates an Arduino Nano, a GPS NEO 6M module, a DFPlayer Mini, and a loudspeaker. The Arduino Nano serves as the central microcontroller, interfacing with the GPS module to receive location data and with the DFPlayer Mini to play audio files based on the speed data received from the GPS module. The loudspeaker is connected to the DFPlayer Mini to output the audio.

Component List

Arduino Nano

  • Description: A small, complete, and breadboard-friendly board based on the ATmega328P.
  • Pins: D1/TX, D0/RX, RESET, GND, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11/MOSI, D12/MISO, VIN, 5V, A7, A6, A5, A4, A3, A2, A1, A0, AREF, 3V3, D13/SCK

GPS NEO 6M

  • Description: A GPS module that provides location data.
  • Pins: VCC, RX, TX, GND

DFPlayer Mini

  • Description: A small and low-cost MP3 module with a simplified output directly to the speaker.
  • Pins: VCC, BUSY, RX, USB -, TX, USB +, DAC_R, K2/ADC_KEY, DAC_L, K1/ADC_KEY, SPK1, IO 2, GND, SPK2, IO 1

Loudspeaker

  • Description: A device that converts electrical signals into sound.
  • Pins: pin1, pin2

Wiring Details

Arduino Nano

  • GND connected to GND of GPS NEO 6M
  • 5V connected to VCC of DFPlayer Mini
  • D2 connected to TX of GPS NEO 6M
  • D3 connected to RX of GPS NEO 6M
  • D4 connected to TX of DFPlayer Mini
  • D5 connected to RX of DFPlayer Mini

GPS NEO 6M

  • GND connected to GND of Arduino Nano
  • TX connected to D2 of Arduino Nano
  • RX connected to D3 of Arduino Nano

DFPlayer Mini

  • VCC connected to 5V of Arduino Nano
  • TX connected to D4 of Arduino Nano
  • RX connected to D5 of Arduino Nano
  • SPK1 connected to pin1 of Loudspeaker
  • SPK2 connected to pin2 of Loudspeaker

Loudspeaker

  • pin1 connected to SPK1 of DFPlayer Mini
  • pin2 connected to SPK2 of DFPlayer Mini

Code Documentation

Arduino Nano Code

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

// GPS module connections
SoftwareSerial gpsSerial(2, 3); // RX, TX
TinyGPSPlus gps;

// DFPlayer Mini connections
SoftwareSerial dfSerial(4, 5); // RX, TX
DFRobotDFPlayerMini dfPlayer;

void setup() {
  Serial.begin(9600);
  gpsSerial.begin(9600);
  dfSerial.begin(9600);

  if (!dfPlayer.begin(dfSerial)) {
    Serial.println("DFPlayer Mini not detected");
    while (true);
  }
  dfPlayer.volume(10); // Set volume to a medium level
}

void loop() {
  while (gpsSerial.available() > 0) {
    gps.encode(gpsSerial.read());
    if (gps.location.isUpdated()) {
      float speed = gps.speed.kmph();
      Serial.print("Speed: ");
      Serial.print(speed);
      Serial.println(" km/h");

      // Play corresponding audio file based on speed
      if (speed < 10) {
        dfPlayer.play(1); // Play file 0001.mp3
      } else if (speed < 20) {
        dfPlayer.play(2); // Play file 0002.mp3
      } else if (speed < 30) {
        dfPlayer.play(3); // Play file 0003.mp3
      } else {
        dfPlayer.play(4); // Play file 0004.mp3
      }
    }
  }
}

This code initializes the GPS and DFPlayer Mini modules, reads the speed from the GPS module, and plays different audio files based on the speed. The audio files are played through the DFPlayer Mini, which is connected to the loudspeaker.