DFplayer Mini Mp3 and Arduino based RFID Bike access System
Table of Contents
Description:
DFplayer Mini Mp3 and Arduino based RFID Bike access System- A few days back I uploaded an article about “How to get RFID implant in humans and practical uses with Arduino”, In this tutorial I explained the step by step procedure how to get an RFID implant and then how to use it with Arduino to control a Sports Bike and other electronic gadgets. My friend Chimpo Mcdoodle actually got the RFID implant and sent me all the details. The whole credit goes to my friend.
In this article, I am going to modify my previous bike control system, this time I am going to add voice to Arduino using DFplayer Mini Mp3 Module by the DFrobot, I will be using the same mini MFRC522 RFID module, 4 Channel Bi-Directional Logic Level Converter Shifter 5V-3.3V, and of course a speaker will be added with the DFplayer Mini Mp3 Module.
A few words about the project, before, I am going to explain the electronic components, circuit diagram, and programming; so that you can have a clear idea, what are we actually going to make.
Bike Access Control System Working:
Different voice messages are pre-recorded, you can record your own voice or you can use the Google’s Narrator and select from different voices which best suits your needs. I myself I used the Google’s Narrator and selected the girl’s voice, which feels like a science fiction movie scene. The demonstration video is given at the end of this article. So, different voice messages are stored in the SD card, and played using the DFplayer Mini Mp3 Module.
When the switch is turned ON a voice message is played “Motor cycle engaged, awaiting authorization”, at this point the user swipes his/her RFID card, if an RFID UID is detected which is not registered the voice is played automatically “Access Denied”, it really doesn’t matter how many times you swipes the same card, the same audio message will be played. This is really cool we can use hundreds of prerecorded voice messages and play the one as per the situation.
When a registered RFID card, Tag, or an RFID chip is swiped another voice message is played “Motor Cycle Activated”, and then the user can go ahead and start the bike. Each audio file stored in the SD card has a unique number and any audio file can be played randomly which entirely depends on the programming.
Can we use this in Car access control system?
Of course the same system can be used in cars, door opening systems, lockers, etc. The overall designing remains the same, the only thing you will need to modify is, the number of relays you want to control, the number of audio files you will need to play, etc. The programming can be easily modified without any problem.
Without any further delay, let’s get started!!!
Amazon links:
Arduino Nano USB-C Type (Recommended)
5V to 3.3V Bi-directional Logic Level Converter for Arduino
NExT RFID Chip Implant US based
*Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.
4 Channel Bi-Directional Logic Level Converter:
Why we need the Logic level converter in the first place? Well, the Mini MFRC522 RFID Reader and the DFplayer Mini Mp3 Module need 3.3V. If these modules are directly used with the Arduino, these modules will be destroyed in no time. So, we need a kind of voltage converter that can convert 5V into 3.3V and 3.3V into 5V. For this, I decided to use the 4 Channel Bi-Directional Logic Level Converter.
Above is the low cost and small size 4 Channel Bi-Directional Logic Level Converter Shifter 5V-3.3V for Arduino.
Details:
- Bi-directional logic level converter is a small device that safely steps down 5V signals to 3.3V and steps up 3.3V to 5V at the same time.
- You can successfully set your high and low voltages and step up and down between them safely on the same channel.
- This level converter also works with 2.8V and 1.8V devices.
- Each level converter has the capability of converting 4 pins on the high side to 4 pins on the low side with two inputs and two outputs provided for each side.
- Dimensions: 0.63*0.52inch /16.05*13.33mm(approx)
Mini MFRC522 RFID Reader Module:
As you can see this is the MFRC522 RFID module. The MFRC522 is a highly integrated reader/writer IC for contactless communication at 13.56 MHz. This module has a total of 8 male headers which are clearly labeled as SDA, SCK, MOSI, MISO, IRQ, GND, RST, and 3.3V. As per the datasheet the typical voltage is 3.3V while the maximum voltage is 3.6 volts. This module can be easily powered up using the Nodemcu ESP8266 Wifi Module.
If you take a look at the slightly larger version of the MFR522 RFID Reader you will find that both the RFID modules have got the same pins and in the same order. The only difference is in the size. So the same project can be built using the larger one.
First we started with the very basic setup, by connecting the MFRC522 RFID module with the Arduino Uno this setup is used to read the identity number of the RFID tag, card, or the RFID chip implant.
In Arduino Uno and Arduino Nano the SPI pins are
Pin number 13 is the SCK
Pin number 12 is the MISO
Pin number 11 is the MOSI and
Pin number 10 is the ss.
DFplayer Mini Mp3 Module:
The DFPlayer Mini is a small and low-cost MP3 module player with a simplified output directly to the speaker. The module can be used as a stand-alone module with an attached battery, speaker, and push buttons or used in combination with an Arduino UNO or any other with RX/TX capabilities.
It perfectly integrates hard decoding module, which supports common audio formats such as MP3, WAV, and WMA. Besides, it also supports TF card with FAT16, FAT32 file system. Through a simple serial port, you can play the designated music without any other tedious underlying operations.
DFplayer Mini MP3 Module APPLICATIONS
Car navigation voice broadcast;
Road transport inspectors, toll stations voice prompts;
The railway station, bus safety inspection voice prompts;
Electricity, communications, financial business hall voice prompts;
Vehicle into and out of the channel verify that the voice prompts;
The public security border control channel voice prompts;
Multi-channel voice alarm or equipment operating guide voice;
The electric tourist car safe driving voice notices;
Electromechanical equipment failure alarm;
Fire alarm voice prompts;
The automatic broadcast equipment, regular broadcast.
MP3 Module SPECIFICATION
Supported sampling rates (kHz): 8/11.025/12/16/22.05/24/32/44.1/48
24 -bit DAC output, support for dynamic range 90dB , SNR support 85dB.
Fully supports FAT16 , FAT32 file system, maximum support 32G of the TF card, support 32G of U disk, 64M bytes NORFLASH
A variety of control modes, I/O control mode, serial mode, AD button control mode.
Advertising sound waiting function, the music can be suspended. when advertising is over in the music continue to play.
Audio data sorted by folder, supports up to 100 folders, every folder can hold up to 255 songs
30 level adjustable volume, 6 -level EQ adjustable
DFplayer Mini Mp3 Module Pinout:
The DFplayer Mini Mp3 Module has a total of 16 pins, 8 pins on the Left side and 8 pins on the Right side. While using this Mp3 module, you should know exactly how to use each pin. Wrong connections may lead to the permanent damage of this Mp3 module.
Bike Access Control System Circuit Diagram:
The following circuit diagram explains how to connect the DFplayer Mini Mp3 Module, MFRC522 RFID Reader, Logic Level Converter, 2-channel relay module, and a speaker with Arduino Nano.
The Red and Ground wires going to the Arduino Nano Vin and Ground pins should be connected through a 12V to 5V converter, this way the whole system can be powered up using the Bike 12V battery. All the connections are pretty straight forward. In the programming later I used some other pins, so the circuit connections should be adjust a bit.
The two brown wires are used for the relay module, which is currently not connected. For now my only concern is to play the sound files.
Bike Access Control System with DFplayer Mp3, Arduino Programming:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
//------------------------------------------------------------------------ // // // --------- Library Required -------- // //RC522 Library - https://github.com/miguelbalboa/rfid/archive/master.zip //Dfmini https://github.com/DFRobot/DFRobotDFPlayerMini/archive/master.zip //https://www.electroniclinic.com/ // ------------- Pinouts ------------- // // // Arduino | RC522 -3.3V | 4 Channel | DfminiMP3 // Nano | RFID Reader | Relay Module | Module //------------------------------------------------------------------------ // GND | GND | | // D2 | | | RX // D3 | | | TX // D4 | | IN1 | // D5 | | IN2 | // D6 | | IN3 | // D7 | | IN4 | // D8 | --- | | // D9 | RST | | // D10 | SS | | // D11 | MOSI | | // D12 | MISO | | // D13 | SCK | | // 3.3V | 3.3v | | // GND | | GND | GND // VIN | | VCC | VCC //------------------------------------------------------------------------ #include <SPI.h> #include <MFRC522.h> #define SS_PIN 10 // The SS pin is connected to Pin 10 #define RST_PIN 9 // the RST pin is conected tp pin 9 MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance. int relay1 = 8; //dash - yeliow int relay2 = 7; //ignition - black int playmp3 = 6; // send low for mp3 #include "Arduino.h" #include "SoftwareSerial.h" #include "DFRobotDFPlayerMini.h" // SoftwareSerial mySoftwareSerial(2, 3); // DF Player - RX, TX DFRobotDFPlayerMini myDFPlayer; void printDetail(uint8_t type, int value); void setup() { pinMode(relay1, OUTPUT); // Declaring this Relay as output digitalWrite(relay1, HIGH); // setting it to OFF pinMode(relay2, OUTPUT); //Declaring this Relay as output digitalWrite(relay2, HIGH); // setting it to OFF pinMode(playmp3, OUTPUT); // Declaring the dfplayer as output digitalWrite(playmp3, HIGH); // setting it to OFF // mySoftwareSerial.begin(9600); Serial.begin(115200); // Initiate a serial communication if (!myDFPlayer.begin(mySoftwareSerial)) { //Use softwareSerial to communicate with mp3. Serial.println(F("Unable to begin:")); Serial.println(F("1.Please recheck the connection!")); Serial.println(F("2.Please insert the SD card!")); Serial.println(F("3.Psst...RXTX must be the right way and at 3.3v logic!")); while(true){ delay(0); // Code to compatible with ESP8266 watch dog. } } Serial.println(F("DFPlayer Mini online.")); myDFPlayer.volume(20); //Set volume value. From 0 to 30 myDFPlayer.play(1); //Play the first mp3 SPI.begin(); // Initiate SPI bus mfrc522.PCD_Init(); // Initiate MFRC522 Serial.println("Approximate your UID to the reader..."); Serial.println(); digitalWrite(playmp3, LOW); // play mp3 digitalWrite(playmp3, HIGH); // play mp3 } void loop() { // Awaiting an UID to be Presented if ( ! mfrc522.PICC_IsNewCardPresent()) { return; } // Select one of the cards if ( ! mfrc522.PICC_ReadCardSerial()) { return; } //Display UID on serial monitor Serial.print("UID tag :"); String content= ""; byte letter; for (byte i = 0; i < mfrc522.uid.size; i++) { Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); Serial.print(mfrc522.uid.uidByte[i], HEX); content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ")); content.concat(String(mfrc522.uid.uidByte[i], HEX)); } Serial.println(); Serial.print("Message : "); content.toUpperCase(); if (content.substring(1) == "YOUR-ID-HERE"|| content.substring(1)== "08 61 A0 32 1A 74 80") //change here the UID of the cards to give access, add more with || content.substring(1)== "another ID" { Serial.println("Authorized access Motorcycle Engaged"); myDFPlayer.volume(30); //Set volume value. From 0 to 30 myDFPlayer.play(2); //Play the first mp3 digitalWrite(relay1, LOW); //activates bike, lights up Dash Serial.println("Motorcycle Engaged"); delay(2500);//allows bike time to start up digitalWrite(relay2, LOW);//activates ignition Serial.println("Motorcycle Starting"); delay(2500);//waits 4 seconds for bike to tick over digitalWrite(relay2, HIGH); //deactivates ignition. Serial.println("Deactivate Ignition"); } else { Serial.println(" Access denied"); myDFPlayer.volume(30); //Set volume value. From 0 to 30 myDFPlayer.play(3); //Play the first mp3 delay(3000); } } |
Finally, I uploaded the code, I used one unregistered RFID card, and one registered RFID chip implanted in hand. You can watch the practical demonstration in the video given below.
Watch Video:
Recently, I posted another article, in which we did a lot of new modifications, and we practically controlled a bike. This can be used as the final product. I highly recommend you should take a look.
Very interesting & neat project. Most impressed with the very tidy breadboard wiring!!!