Simple to use Arduino library to interface to JQ8400 (JQ8400-FL, JQ8400-TF) Mp3 Player Modules
Table of Contents
- Download, Install and Example
- Connecting To Your Arduino
- Troubleshooting
- Further Documentation and Library Reference
- JQ6500 to JQ8400 Breaking Changes
- Alternative One Wire Implementation For Low Sleep Current
JQ8400-TF | JQ8400-FL |
---|---|
- Download: https://sparks.gogo.co.nz/JQ8400_Serial.zip
- Open the Arduino IDE (1.6+)
- Select the menu item Sketch > Import Library > Add Library
- Choose to install the JQ8400_Serial.zip file you downloaded
- Now you can choose File > Examples > JQ8400_Serial > HelloWorld
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...
- Incorrectly wired, make sure that TX/RX crossover and that you have GND shared
- Insufficient power supply. The power demands are not insignificant, USB from a computer... likely not good enough. Use external power.
- Trying to upload to JQ8400 while it is still connected to the Arduino. Best to unplug the JQ8400 from your project and just have it plugged into a USB cable when you want to change the files on it.
- MP3 file problem. Try re-encoding your MP3 files.
- Complete Documentation about the JQ8400 Mp3 Player Module For Arduino
- JQ8400_Serial Library Methods Reference (with thanks to githack.com)
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...
- The initialisation has changed so that you can (must) point the JQ8400 library to a specific serial connection to the JQ8400 player, you can use SoftwareSerial, or any of your other serial ports (or any Stream). This enables you to use devices that do not support SoftwareSerial.
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(Serial);
void setup()
{
Serial.begin(9600);
mp3.reset();
}
Example over microcontroller's other hardware serial port...
#include <JQ8400_Serial.h>
JQ8400_Serial mp3(Serial2);
void setup()
{
Serial2.begin(9600);
mp3.reset();
}
- JQ8400 does not support
countFolders()
at all (AFAIK) therefore this method is not available.. - JQ8400 is not given a source for
countFiles
- that is usemp3.countFiles()
notmp3.countFiles(MP3_SRC_SDCARD)
, usemp3.setSource(MP3_SRC_SDCARD)
to change the source before counting if you are not already on that source. - JQ8400 does not support MP3_EQ_BASS
Github user @arduino12 has produced a Low Sleep Current JQ8400 Library which uses the alternative One Wire prototcol of the JQ8400 which with some modificiations allows the JQ8400 to have sleep current of just 140uA.