JQ8400 MP3 Player Arduino Library
A simple library to control a JQ8400 MP3 Player Module from an Arduino.
|
Simple to use Arduino library to interface to JQ8400 (JQ8400-FL, JQ8400-TF) Mp3 Player Modules
Table of Contents
JQ8400-TF | JQ8400-FL |
---|---|
The JQ8400_Serial library can be configured to talk through any "Serial" port, including "SoftwareSerial", anything that is a Stream.
Most commonly you will use a SoftwareSerial with typical "AVR" based Arduinos that only have one hardware seral port. For Arduino's (and related, like ESP32) that have more than one hardware serial port you will typically want to use one of those instead of SoftwareSerial.
The most important consideration is that if your Arduino is 5 volt, you will want to put a 1k resistor on the RX pin of the JQ8400 and the Arduino's appropriate TX pin you are using.
Below are some examples to help you.
This is the typical setup where you have an Arduino Uno or Nano etc which only has one "Hardware" serial port and you use that to upload and communicate to the Arduino yourself, therefore we use a SoftwareSerial connection to communicate between the Arduino and the JQ8400 Module.
JQ8400 Module | Arduino |
---|---|
RX | through a 1K Resistor then to pin 9 |
TX | pin 8 |
GND (any of) | GND |
VCC (any of) | VCC |
JQ8400 Module | Arduino |
---|---|
RX | pin 9 |
TX | pin 8 |
GND (any of) | GND |
VCC (any of) | VCC |
You can use pins other than 9 and 8 if you wish, simply set them in your code, which looks something like this...
#include <SoftwareSerial.h> SoftwareSerial mySerial(8,9); #include <JQ8400_Serial.h> JQ8400_Serial mp3(mySerial); void setup() { mySerial.begin(9600); // We must talk to the JQ8400 at 9600 mp3.reset(); // Reset the device (optional, recommended) } void loop() { // You should do more interesting stuff than just this... mp3.next(); while(mp3.busy()); // Wait until finished. }
This is a typical setup where your Arduino environment has more than one "Serial", and you want to use one of those to communicate to the JQ8400, leaving the normal "Serial" free for uploading, communication to the Arduino etc...
JQ8400 Module | Arduino |
---|---|
RX | through a 1K Resistor then to appropriate TX pin |
TX | RX pin |
GND (any of) | GND |
VCC (any of) | VCC |
JQ8400 Module | Arduino |
---|---|
RX | appropriate TX pin |
TX | appropriate RX pin |
GND (any of) | GND |
VCC (any of) | VCC |
JQ8400 Module | ESP32 |
---|---|
RX | GPIO17 |
TX | GPIO16 |
GND (any of) | GND |
VCC (any of) | VCC |
#include <JQ8400_Serial.h> JQ8400_Serial mp3(Serial2); void setup() { Serial2.begin(9600); // We must talk to the JQ8400 at 9600 - maybe you need to add some extra parameters to begin, consult your specific board's documents if you have trouble. mp3.reset(); // Reset the device (optional, recommended) } void loop() { // You should do more interesting stuff than just this... mp3.next(); while(mp3.busy()); // Wait until finished. }
People have problems in about this order...
This section is for users of previous JQ6500 devices and the JQ6500_Serial library who are transitioning to a JQ8400 with JQ8400_Serial library.
As much as possible the JQ8400_Serial library should follow the same "api", with some additions, however there are some "breaking changes" you should be aware of...
Example for software serial on pins 8 and 9...
#include <SoftwareSerial.h> SoftwareSerial mySerial(8,9);
#include <JQ8400_Serial.h> JQ8400_Serial mp3(mySerial);
void setup() { mySerial.begin(9600); mp3.reset(); }
Example over microcontroller's default hardware serial port...
#include <JQ8400_Serial.h> JQ8400_Serial mp3;
void setup() { Serial.begin(9600); mp3.begin(Serial); }
Example over microcontroller's other hardware serial port...
#include <JQ8400_Serial.h> JQ8400_Serial mp3;
void setup() { Serial2.begin(9600); mp3.begin(Serial2); }
countFolders()
at all (AFAIK) therefore this method is not available..countFiles
- that is use mp3.countFiles()
not mp3.countFiles(MP3_SRC_SDCARD)
, use mp3.setSource(MP3_SRC_SDCARD)
to change the source before counting if you are not already on that source.