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

Arduino Nano GPS Speed-Triggered Audio Player with DFPlayer Mini

View and Edit Project In Cirkit DesignerImage 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

GPS NEO 6M

DFPlayer Mini

Loudspeaker

Wiring Details

Arduino Nano

GPS NEO 6M

DFPlayer Mini

Loudspeaker

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.