Hi,
Please can you help me understand and solve the problem with dfmini - the light is "on" (not full bright but very low) and there is noise(kind of white noise) in the speaker
My sketch makes Nano in deep sleep and uses interrupts and kicks off only at a particular trigger, but that is not in scope of tis problem
Goal: To be able to keep DFmini silent , make the battery last longer.
I kind of understand phantom power etc terms...but I am looking for fix
please help
Phantom power occurs when IO signals are High when power is off.
Try bringing all the IO to Low before going into Deep Sleep.
If that doesn't work, then you'll probably need something to cut power to the DF player.
the light is "on"
Which light is that ?
Despite what you say the program may be causing a problem and should be posted here
#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
void setup()
{
mySoftwareSerial.begin(9600);
Serial.begin(9600);//115200);
Serial.println();
Serial.println(F("DFRobot DFPlayer Mini Demo"));
Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));
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!"));
while(true){
delay(0); // Code to compatible with ESP8266 watch dog.
}
}
Serial.println(F("DFPlayer Mini online."));
myDFPlayer.volume(22); //Set volume value. From 0 to 30
myDFPlayer.play(8); //Play the first mp3
}
void loop()
{
}
The above sketch also produces the noise after playing the file + light on DFmini (10% light), as if it is busy
Observation: When I supply power via mini usb, the light is not visible, but white noise is there.
My actual setup will be 2 x 14500 = 7.4 to Vin of Nano
My active sketch
Note: I use a DS3231 (not in the OP)
#include <Wire.h>
#include <Time.h>
//#include <DS1307RTC.h>
#include <DS3232RTC.h>
#include <avr/sleep.h>//this AVR library contains the methods that controls the sleep modes
#include "DFRobotDFPlayerMini.h"
#include "SoftwareSerial.h"
#define interruptPin 2 //Pin we are going to use to wake up the Arduino
const int time_interval=2;//1440;// Sets the wakeup intervall in minutes
//const int time_interval2=2;// Sets the wakeup intervall in minutes
SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
void setup() {
mySoftwareSerial.begin(9600);
Serial.begin(9600);
while (!Serial) ; // wait for serial
delay(200);
Serial.println("DS1307RTC Read Test");
pinMode(interruptPin,INPUT_PULLUP);//Set pin d2 to input using the buildin pullup resistor
// initialize the alarms to known values, clear the alarm flags, clear the alarm interrupt flags
RTC.setAlarm(ALM1_MATCH_DATE, 0, 0, 0, 1);
RTC.setAlarm(ALM2_MATCH_DATE, 0, 0, 0, 1);
RTC.alarm(ALARM_1);
RTC.alarm(ALARM_2);
RTC.alarmInterrupt(ALARM_1, false);
RTC.alarmInterrupt(ALARM_2, false);
RTC.squareWave(SQWAVE_NONE);
/* Begin block
tmElements_t tm;
tm.Hour = 00; // set the RTC to an arbitrary time
tm.Minute = 00;
tm.Second = 00;
tm.Day = 4;
tm.Month = 2;
tm.Year = 2018 - 1970; // tmElements_t.Year is the offset from 1970
RTC.write(tm); // set the RTC from the tm structure
Block end * */
time_t t; //create a temporary time variable so we can set the time and read the time from the RTC
t=RTC.get();//Gets the current time of the RTC
RTC.setAlarm(ALM1_MATCH_HOURS , 0, 8, 11, 0);// Setting alarm 1 to go off 5 minutes from now
// clear the alarm flag
RTC.alarm(ALARM_1);
// configure the INT/SQW pin for "interrupt" operation (disable square wave output)
RTC.squareWave(SQWAVE_NONE);
// enable interrupt output for Alarm 1
RTC.alarmInterrupt(ALARM_1, true);
//for larm 2
RTC.setAlarm(ALM2_MATCH_HOURS , 0, 9, 11, 0);// Setting alarm 1 to go off 5 minutes from now
// clear the alarm flag
RTC.alarm(ALARM_2);
// configure the INT/SQW pin for "interrupt" operation (disable square wave output)
// RTC.squareWave(SQWAVE_NONE);
// enable interrupt output for Alarm 2
RTC.alarmInterrupt(ALARM_2, true);
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!"));
while(true){
delay(0); // Code to compatible with ESP8266 watch dog.
}
}
Serial.println(F("DFPlayer Mini online."));
myDFPlayer.volume(30); //Set volume value. From 0 to 30
}
void loop() {
delay(5000);//wait 5 seconds before going to sleep. In real senairio keep this as small as posible
Going_To_Sleep();
}
void print2digits(int number) {
if (number >= 0 && number < 10) {
Serial.write('0');
}
Serial.print(number);
}
void Going_To_Sleep(){
sleep_enable();//Enabling sleep mode
attachInterrupt(0, wakeUp, LOW);//attaching a interrupt to pin d2
set_sleep_mode(SLEEP_MODE_PWR_DOWN);//Setting the sleep mode, in our case full sleep
digitalWrite(LED_BUILTIN,LOW);//turning LED off
time_t t;// creates temp time variable
t=RTC.get(); //gets current time from rtc
Serial.println("Sleep Time: "+String(hour(t))+":"+String(minute(t))+":"+String(second(t)));//prints time stamp on serial monitor
delay(1000); //wait a second to allow the led to be turned off before going to sleep
sleep_cpu();//activating sleep mode
Serial.println("just woke up!");//next line of code executed after the interrupt
digitalWrite(LED_BUILTIN,HIGH);//turning LED on
t=RTC.get();
Serial.println("WakeUp Time: "+String(hour(t))+":"+String(minute(t))+":"+String(second(t)));//Prints time stamp
if ( RTC.alarm(ALARM_1) ) {// clear the alarm flag
RTC.setAlarm(ALM1_MATCH_MINUTES , 0, minute(t)+time_interval, 0, 0);//Set New Alarm
myDFPlayer.play(6);
}else if ( RTC.alarm(ALARM_2) ) {// clear the alarm flag
RTC.setAlarm(ALM2_MATCH_MINUTES , 0, minute(t)+time_interval, 0, 0);//Set New Alarm
myDFPlayer.play(7);
}
}
void wakeUp(){
Serial.println("Interrrupt Fired");//Print message to serial monitor
sleep_disable();//Disable sleep mode
detachInterrupt(0); //Removes the interrupt from pin 2;
}
CrossRoads:
Phantom power occurs when IO signals are High when power is off.
Try bringing all the IO to Low before going into Deep Sleep.
If that doesn't work, then you'll probably need something to cut power to the DF player.
Need help on how to do this.
EDIT: I now update my setup to use 7.2v to 5v step down converter and supplying to Nano 5v and DFmini VCC. The DFmini light is not getting on, but noise is there. Is it draining my battery?