Sound sensor stop working with DFPlayer

hi, I am having problems with my sound sensor. after DFPlayer plays the sound 2 or 3 times the sound sensor cannot receive the analog signal. I use 5v from Arduino Uno for my DFPlayer power supply. I didn't use a resistor, does that matter?

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>
#include <DFRobotDFPlayerMini.h>

// Inisialisasi LCD pada alamat I2C 0x27
LiquidCrystal_I2C lcd(0x27, 16, 2);

// Gunakan SoftwareSerial untuk DFPlayer Mini
const int DFPlayer_RX = D5; // Pin RX pada DFPlayer Mini
const int DFPlayer_TX = D6; // Pin TX pada DFPlayer Mini
SoftwareSerial mySerial(DFPlayer_RX, DFPlayer_TX);
DFRobotDFPlayerMini myDFPlayer;

const int sensorPin = A0;         // Pin sensor suara
const int sampleWindow = 50;      // Window sampling dalam ms
unsigned int sample;

bool isPlaying = false;           // Status pemutaran DFPlayer
unsigned long lastPlayTime = 0;   // Waktu terakhir DFPlayer dimainkan
const unsigned long playInterval = 5000; // Interval antar pemutaran suara (ms)

void setup() {
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Decibel Meter");
  delay(2000);
  lcd.clear();
  Serial.begin(115200);

  // Inisialisasi DFPlayer
  mySerial.begin(9600);
  if (!myDFPlayer.begin(mySerial)) {
    lcd.print("DFPlayer Error");
    while (true);
  }
  myDFPlayer.setTimeOut(500);
  myDFPlayer.volume(30);
  myDFPlayer.EQ(DFPLAYER_EQ_NORMAL);
}

void loop() {
  unsigned long startMillis = millis();
  unsigned int signalMax = 0;
  unsigned int signalMin = 1023;

  // Sampling sinyal
  while (millis() - startMillis < sampleWindow) {
    sample = analogRead(sensorPin);
    if (sample < 1024) {
      if (sample > signalMax) {
        signalMax = sample;
      } else if (sample < signalMin) {
        signalMin = sample;
      }
    }
  }

  // Hitung nilai peak-to-peak dan konversi ke desibel
  int peakToPeak = signalMax - signalMin;
  int dB = map(peakToPeak, 20, 900, 35, 70);

  // Tampilkan nilai di LCD
  lcd.setCursor(0, 0);
  lcd.print("Loudness: ");
  lcd.print(dB);
  lcd.print(" dB");

  lcd.setCursor(0, 1);
  if (dB >= 35 && dB <= 45) {
    lcd.print("Level: Tenang   ");
  } else if (dB >= 46 && dB <= 55) {
    lcd.print("Level: Sedang   ");
  } else if (dB >= 56 && dB <= 60) {
    lcd.print("Level: Bising   ");
  } else if (dB >= 61 && dB <= 90) {
    lcd.print("Level: Melampaui");

    // Mainkan suara jika interval waktu terpenuhi
    if (!isPlaying && millis() - lastPlayTime > playInterval) {
      myDFPlayer.play(1);
      isPlaying = true;
      lastPlayTime = millis();
    }
  } else {
    lcd.print("Level: Unknown  ");
  }

  // Reset status isPlaying setelah interval selesai
  if (isPlaying && millis() - lastPlayTime > playInterval) {
    isPlaying = false;
  }

  // Debugging
  Serial.print("Peak-to-Peak: ");
  Serial.println(peakToPeak);
  Serial.print("Desibel: ");
  Serial.println(dB);

  delay(50); // Non-blocking kecil untuk kestabilan pembacaan sensor
}

The Uno can not power your DFPlayer, especially when you

set the speaker volume to max. It will not provide enough current. You need a real power supply

Yet the diagram depicts a NodeMCU_8266.

The DF-Mini-player is supplied by an Arduino Uno. The higher the voltage into the Arduino-Uno the lower the current you can achieve. WHy that? because all voltage above 5V is dissipated to heat inside the arduino-Uno-Voltage-regulator.
Input Voltage into Arduino 7V voltage to dissipate to heat 7V - 5V = 2V
multiplied by the current let's say 0,3 A = 2V * 0,3 A = 0,6 W

Input Voltage into Arduino 12V voltage to dissipate to heat 12V - 5V = 7V
multiplied by the current let's say 0,3 A = 7V * 0,3 A = 2,1 W = way too much.

Still the same applies to a 8266-nodeMCU. The onboard-voltage-regulator can supply only a small current. Supplying the LCD with backlight full bright on might be too much.

What is not included in your frizzy picture is how is the 8266-nodeMCU powersupplied?

The NodeMCU_8266 has no 5V regulator, while it has a 3V regulator.

I've had no problems running a DFPlayer from a NodeMCU via VUSB.
The LCD can run off 3V? Maybe.

The DFPlayer can run but only 2-3 times after that sound sensor can't read analog signals

The DFPlayer is working but 2-3 times but the sound sensor stop working, and can't read analog signals it makes. When i try LCD same like as DFPlayer plug into 5v Arduino Uno it works nothing problem with sound sensor

Have you try my code into your esp8266?

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