DFPlayer volume goes up when switching USB to PowerBank

I am working on a simple setup to play some mp3 files thru an onld rotary phone based on the number you dial. I have the number dialing part working but I am having difficulty getting the volume to play correctly. It works fine when I test on my MacBook Pro USB but when I diconnect from the computer and power it from an Anker USB Power Bank the volume is about 10 times as high! Any ideas why this might be happening?

Here is my code (just for playing a loop of different mp3 files):

#include <Arduino.h>

#include <SoftwareSerial.h>
#include <DFMiniMp3.h>

#define RX_PIN 10
#define TX_PIN 11

class Mp3Notify; 

SoftwareSerial secondarySerial(RX_PIN, TX_PIN);
typedef DFMiniMp3<SoftwareSerial, Mp3Notify> DfMp3;
DfMp3 dfmp3(secondarySerial);

bool notPlaying = true;

uint8_t maxVolume = 3;

class Mp3Notify
{
public:
  static void PrintlnSourceAction(DfMp3_PlaySources source, const char* action)
  {
    if (source & DfMp3_PlaySources_Sd) 
    {
        Serial.print("SD Card, ");
    }
    if (source & DfMp3_PlaySources_Usb) 
    {
        Serial.print("USB Disk, ");
    }
    if (source & DfMp3_PlaySources_Flash) 
    {
        Serial.print("Flash, ");
    }
    Serial.println(action);
  }
  static void OnError(DfMp3& mp3, uint16_t errorCode)
  {
    // see DfMp3_Error for code meaning
    Serial.println();
    Serial.print("Com Error ");
    Serial.println(errorCode);
  }
  static void OnPlayFinished(DfMp3& mp3, DfMp3_PlaySources source, uint16_t track)
  {
    Serial.print("Play finished for #");
    Serial.println(track);
    notPlaying = true; 
  }
  static void OnPlaySourceOnline(DfMp3& mp3, DfMp3_PlaySources source)
  {
    PrintlnSourceAction(source, "online");
  }
  static void OnPlaySourceInserted(DfMp3& mp3, DfMp3_PlaySources source)
  {
    PrintlnSourceAction(source, "inserted");
  }
  static void OnPlaySourceRemoved(DfMp3& mp3, DfMp3_PlaySources source)
  {
    PrintlnSourceAction(source, "removed");
  }
};

void waitMilliseconds(unsigned long maxWaitTime)
{
  unsigned long start = millis();
  
  while ((millis() - start) < maxWaitTime)
  {
    // calling mp3.loop() periodically allows for notifications to be handled without interrupts
    dfmp3.loop(); 
    delay(1);
  }
}

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

  Serial.println("initializing...");
  
  dfmp3.begin();
  waitMilliseconds(100);
  uint16_t volume = dfmp3.getVolume();
  waitMilliseconds(100);
  Serial.print("start volume ");
  Serial.println(volume);
  dfmp3.setVolume(maxVolume);
  waitMilliseconds(100);
  volume = dfmp3.getVolume();
  Serial.print("new volume ");
  Serial.println(volume);
  waitMilliseconds(100);
  uint16_t count = dfmp3.getTotalTrackCount(DfMp3_PlaySource_Sd);
  Serial.print("files ");
  Serial.println(count);
  waitMilliseconds(1000);
  Serial.println("starting...");
}

void millisecondsLoop()
{
  unsigned long maxWaitTime = 85000;
  notPlaying = false;
  unsigned long start = millis();
  
  while ((millis() - start) < maxWaitTime)
  {
    // calling mp3.loop() periodically allows for notifications to be handled without interrupts
    dfmp3.loop(); 
    if (notPlaying)
    {
      return;
    }
    delay(1);
  }
}

void loop() 
{
  uint16_t count = dfmp3.getTotalTrackCount(DfMp3_PlaySource_Sd);
 
  for (uint16_t i = 1; i <= count; i++)
  {
    Serial.print("track: ");
    Serial.println(i);
    dfmp3.playMp3FolderTrack(i);
    millisecondsLoop();
  }
}

Her is the wiring, just a pic but it is very basic ...


Let me know if you have an idea when the volume would change when I change the power supply.

Thanks

Greg

Different wattage, volatage, etc...?
Why does this matter?

I am using an old rotary hand set that you will hold next to your ear. I have set the volume to 3 (out of 30 for DFPlayer) which good. But it will hurt your ears on the Anker Power Bank.

I don't want to add a separate volume control and the phone could be plugged into any number of USB or laptop banks.

The voltage should be the same from the USB (5V) shouldn't it be?

Greg

You can tell us when you have measured it, you have the two power sources.

Too much power ... I'm thinking the MacBook Pro limits the current when connected to the serial monitor ... a 10K resistor seems to have solved the issue.

Thanks

Greg

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.