MicroController Recommendation for Podcast Player

Hi Everyone,
I am interested in making a Podcast player that has a sleep timer for listening to in bed when I wake during the night. With my old eyes I want it to be easy to press a button and get x minutes of play.
Things that I think are needed:

  • Low power Mode when not playing
  • Not too hard to move podcasts to device
  • Can drive a pillow speaker or wired earbuds
  • Low powered screen, hopefully with a few buttons

Nice to have:

  • Lipo Battery support - I currently use an iPod nano with earbuds which is great but needs replacing

Background:
I have used Teensy with its Audio Card a lot but I am thinking it might be overkill for this project. I am confident with coding this and would probably prefer to use Arduino C but not adverse to using Python if it works.

Canā€™t think of anything else at the minute.

Thanks,
John

3 Likes

Hi John,

Throwing in my 2c
Instead of going the hardware route, a more software oriented approach might be easier.

If you have Spotify they have great APIā€™s that let you pause and resume playback of whatever you are listening to.
https://developer.spotify.com/documentation/web-api/reference/pause-a-users-playback

(They already have the option for sleep mode on mobile where you set a timer for music, podcasts and audiobooks)
Though you could connect to your PC with the wire or bluetooth

To get the button working all you would need is a Pico W to make the API call.

2 Likes

Thanks Liam. Interesting idea.
The problem is I donā€™t have Spotify, more as a moral objection. I am a practicing amateur musician/composer of Prog Rock and I object to the pitiful amount Spotify pays me for the one album I put on it. I actually use Bandcamp to publish my music, which is way more artist friendly.
Thanks for your idea.

3 Likes

Hi John,

Yeah, thats the main thing pulling me away from the service, for my favourite artists Iā€™ll grab some merch or donate.

Back to your project, what format are you saving/playing the podcasts as?

The DFplayer is a pretty common pick for other forum members looking to add audio, though Iā€™ve always gone through a dedicated computer for the interface and seeking through tracks.

They are Mp3. I just download them from the audioboom website.


Iā€™ll check the dfplayer outā€¦
Thanks!

Thanks Liam. I think this one looks to be ideal. It has 128Mb of storage so I could just load a couple of podcasts onto it via its USB interface.

Have to see if it supports remembering where the playhead is.

1 Like

Looks like the API has plenty of function that allow positioning of the playhead! Nice
https://wiki.dfrobot.com/DFPlayer_PRO_SKU_DFR0768

2 Likes

What speaker would you suggest to go with this? It says a 3W 4Ohm speaker. I can only find a 5W 8Ohm speaker here.

1 Like

Hi John,

Iā€™ve heard some success stories with this pair, nice and small - should be easily concealable around the bed: Stereo Enclosed Speaker Set - 3W 4 Ohm | Adafruit ADA1669 | Core Electronics Australia

2 Likes

Thanks Liam.

So it is finished and it works well.
Press the start/stop button and it plays an mp3 file for 10 minutes (Hard coded by me as my ideal time) then stops. Next press of the button plays form the 10 minute mark etc. if a file is finished then it goes onto the next file and cycles back at the end of all files.
If anyone is interested I can elaborate or answer questions.

2 Likes

Hi @John136772

Nice build. I would like to see your code base if you are happy to post it / make a project out of itā€¦

I have a couple of these MP3 modules I used previously , and am looking for a ā€˜new homeā€™ for them :partying_face:

Murray

2 Likes

Sure. I am happy to share, except I have a bug which is to do with data types. Get back to it when I am sure it is fixedā€¦ :wink:

Okā€¦
I have struck a problem with positioning the ā€œplayheadā€ within a file. What happens is when I try to play a file from a time bigger than 255 seconds from the start of the file it moves back to the start of the file as if 255 (a byte?) is a limit even though the functions are supposed to be uint16_t !! I wrote a simplified test code which plays at various positions through a file in jumps of 20 seconds. When I get past 255 ish it starts from the beginning again. See the data at the bottom.

I am using an Arduino Nano clone to control the DFPLayer Pro

Code and data belowā€¦

/*
   Night Time Podcast Player - Testing 
*/

#include <EEPROM.h>
#include <DFRobot_DF1201S.h>
#include <SoftwareSerial.h>

SoftwareSerial DF1201SSerial(2, 3);  //RX  TX
DFRobot_DF1201S DF1201S;

uint16_t count = 0; 

// ========== Set Up ==============

void setup(void) {
  //Serial Monitor
  Serial.begin(9600);

  //DF1201S Serial
  DF1201SSerial.begin(115200);
  while (!DF1201S.begin(DF1201SSerial)) {
    Serial.println("Init failed, please check the wire connection!");
    delay(1000);
  }

  // ---- Setup Player ------------------------
  /*Set volume*/
  DF1201S.setVol(1);
  /*Enter music mode*/
  DF1201S.switchFunction(DF1201S.MUSIC);
  /*Set playback mode to "repeat all"*/
  // DF1201S.setPlayMode(DF1201S.SINGLE);
  Serial.println();
}

void loop() {
  //set file number
  DF1201S.playFileNum(2);
  DF1201S.setPlayTime(count * 20);
  Serial.print(count * 20);
  Serial.print(",");
  delay(1000);
  uint16_t playTime = DF1201S.getCurTime();
  Serial.println(playTime);
  count++;
  DF1201S.pause();
  delay(500);
}

Data in seconds from running the code
setPlayTime, getCurTime
0,1
20,20
40,40
60,60
80,80
100,100
120,120
140,140
160,159
180,179
200,199
220,219
240,239
260,5
280,24
300,44
320,64
340,84
360,104
380,124
400,144
420,163
440,183
460,203
480,223
500,943
520,9
540,28

Any insights would be much appreciated.

1 Like

Hi John.
Donā€™t know much about doing this but there is something that stands out a bit.
The line uint16_t playtime = DF12015 etc stands out.
Any time I have used ā€œuint16 (or 8 or 32)_tā€ it has always always displayed ā€œuint16_tā€ in green. Is there something wrong with the syntax. Did you copy and paste the sketch? If you did there are quite often funny things happen as if there seems to be hidden characters transferred or something. It might be worth a try to delete any lines that carry this ā€œuint etcā€ bit and retype in directly. I have had this problem 3 or 4 times in the past. Donā€™t know what happens and I donā€™t think anyone else has got to the bottom of it either.

When this occurred in the past the sketch compiled correctly, ran but not properly. Nasty problem and I typed a whole sketch once.
Cheers Bob

1 Like

If the module follows the pattern of earlier models then it is unlikely to have been tested with files of that size. You could see how the device is responding to the request by running in AT command mode and checking the response to the AT command for that function:

AT+QUERY=3\r\n
2 Likes

You might also place these lines into your code to verifiy that the command is actually sending what you believe it is. (code lifted from the DFRobot library in github)

   sPacket_t cmd;                        // temp variable
   cmd = pack("TIME", String(second));   // this should create the required AT command
                                         //  AT+TIME=nnn     where nnn should be equal
                                         //  to the output of Serial.print(count * 20);
   Serial.print(cmd);
   Serial.print(count * 20);

Murray

2 Likes

Thanks Robert. I did try changing the variable type but this didnā€™t help.

1 Like

Thanks Jeff.
I have been trying to use the AT command mode and this works as expected.

e.g. This code moves the ā€œplayheadā€ to the expected position. I think I will use this approach to controlling the player rather than the DFRobot_DF1201S library which might be more buggy.

#include <SoftwareSerial.h>
#include <Button.h>

SoftwareSerial DFPlayer(2, 3);
Button button7(7); // Connect button between pin 7 and GND - This is the play button
Button button12(12); // Connect button between pin 7 and GND - This is the Reset button

int count = 0;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  //Switch Input
  button7.begin();
  button12.begin();
  Serial.println("Started");

  // set the data rate for the SoftwareSerial port
  DFPlayer.begin(115200);
  DFPlayer.write("AT\r\n");
  DFPlayer.write("AT+AMP=ON\r\n");
  DFPlayer.write("AT+PLAYMODE=2\r\n");
  DFPlayer.write("AT+VOL=10\r\n");

}

void loop() {
  if (DFPlayer.available()) {
    Serial.write(DFPlayer.read());
  }
  if (Serial.available()) {
    DFPlayer.write(Serial.read());
  }
  checkButtons();
}


void checkButtons() {
  if (button7.pressed()) {
    DFPlayer.write("AT+TIME=+100");
  }
  if (button12.pressed()) {
   // DFPlayer.write("AT+QUERY=4");
    DFPlayer.write("AT+QUERY=3");
  }
}
1 Like

Thanks Murray, this is a good idea but it would seem the DFRobot_DF1201S library is buggy so Iā€™ll use AT commands.

1 Like