Ground of L298N causes trouble in a rotary phone project

Issue with Ground Connection Causing DFPlayer Mini to Short Out

Hi everyone,

I'm working on a project using an ESP32, an L298N motor driver, and a DFPlayer Mini, and I've encountered an issue when connecting a specific ground wire. Below are my connections:

Connections Overview

ESP32 (Powered via USB-C)

  • GPIO 25, 33IN1, IN2 (L298N driver)
  • GPIO 16, 17TX, RX (DFPlayer Mini) (GPIO 16 to DFPlayer TX)
  • GPIO 4Hang-Up Point on Phone (Found via a YouTube video showing detection of the mechanism)
  • VINVCC (DFPlayer Mini)
  • GroundGround (DFPlayer Mini)

DFPlayer Mini

(Excluding connections already mentioned to ESP32)

  • SPK1Green Wire (Headphone Jack on Phone)
  • SPK2Red Wire (Headphone Jack on Phone)

L298N Motor Driver

(Excluding connections already mentioned to ESP32)

  • 12V+ Power Supply12V+ (L298N)
  • 12V- Power SupplyGround (L298N)

The Problematic Connection

  • Ground (ESP32) → Ground (L298N)

Issue Description

When I connect the ESP32 ground to the L298N ground, I observe the following problems:

  1. The DFPlayer Mini shorts out (sometimes burning and emitting smoke).
  2. Occasionally, the ESP32 throws the error:
Brownout detector was triggered
  1. If I disconnect the DFPlayer Mini, the ringer circuit works fine.

I've attached photos of my wiring and tried multiple configurations, but the issue persists. I also linked a YouTube video where someone uses a different motor driver—I've ordered the same one, but I’d like to understand what mistake I might have made with my current setup.

What I’ve Tried

  • Removing the DFPlayer Mini: The rest of the circuit works fine.
  • Checking the power connections: Everything seems correct.
  • Trying different grounding configurations: Still results in the DFPlayer Mini failing.

Code

#include "HardwareSerial.h"
#include "DFRobotDFPlayerMini.h"

#define PHONE_PIN 4  // Pin to detect pickup/hang-up
#define DEBOUNCE_DELAY 100  // Debounce delay in milliseconds
#define PIN_MP3_TX 17  // TX to DFPlayer RX
#define PIN_MP3_RX 16  // RX to DFPlayer TX
const byte ringerPins[] = {25, 33};

// Phone state variables
bool lastState = HIGH;
bool currentState;
unsigned long lastDebounceTime = 0;

// Ringer variables
unsigned long lastRingTime = 0;
unsigned long ringDuration = 20;
unsigned long timeBetweenRings = 4000;
unsigned long shortDelayBetweenPatterns = 200;
int ringIterations = 20;
int ringRepeats = 2;
bool ringInProgress = false;
bool shouldRing = false;

// DFPlayer Mini
HardwareSerial mySerial(1);
DFRobotDFPlayerMini player;
bool shouldPlay = false;

void setup() {
    Serial.begin(115200);
    pinMode(PHONE_PIN, INPUT_PULLUP);
    pinMode(ringerPins[0], OUTPUT);
    pinMode(ringerPins[1], OUTPUT);
    mySerial.begin(9600, SERIAL_8N1, PIN_MP3_RX, PIN_MP3_TX);

    if (player.begin(mySerial)) {
        Serial.println("DFPlayer Mini ready!");
        player.volume(30);
    } else {
        Serial.println("Failed to connect to DFPlayer Mini!");
    }
}

void detectPhoneState() {
    int reading = digitalRead(PHONE_PIN);
    if (reading != lastState) {
        lastDebounceTime = millis();
    }
    if ((millis() - lastDebounceTime) > DEBOUNCE_DELAY) {
        if (reading != currentState) {
            currentState = reading;
            if (currentState == LOW) {
                Serial.println("Phone is PICKED UP");
            } else {
                Serial.println("Phone is HUNG UP");
            }
        }
    }
    lastState = reading;
}

void ringPattern() {
    for (int j = 0; j < ringRepeats; j++) {
        for (int i = 0; i < ringIterations; i++) {
            digitalWrite(ringerPins[0], i % 2);
            digitalWrite(ringerPins[1], 1 - (i % 2));
            delay(ringDuration);
        }
        delay(shortDelayBetweenPatterns);
    }
    digitalWrite(ringerPins[0], LOW);
    digitalWrite(ringerPins[1], LOW);
}

void parseCommand(String input) {
    input.trim();
    if (input == "ring") {
        shouldRing = true;
        Serial.println("Ringing started");
    } else if (input == "stopring") {
        shouldRing = false;
        Serial.println("Ringing stopped");
        digitalWrite(ringerPins[0], LOW);
        digitalWrite(ringerPins[1], LOW);
    } else if (input == "play") {
        shouldPlay = true;
        player.play(1);
        Serial.println("Playing audio");
    } else if (input == "stopplay") {
        shouldPlay = false;
        player.stop();
        Serial.println("Audio stopped");
    }
}

void loop() {
    detectPhoneState();

    while (Serial.available() > 0) {
        String mystr = Serial.readString();
        parseCommand(mystr);
    }

    if (shouldRing && millis() - lastRingTime > timeBetweenRings && !ringInProgress) {
        ringInProgress = true;
        ringPattern();
        lastRingTime = millis();
        ringInProgress = false;
    }
}

Request for Help

  • What could be causing the DFPlayer Mini to short out when I connect the L298N ground to the ESP32 ground?
  • Could there be a ground loop or power isolation issue?
  • Any suggestions on troubleshooting steps or modifications to prevent damage?

Thanks in advance for any help!

YouTube Video Reference:



Please translate the words and the fritzing to real schematis for the circuit making trouble.

What is the voltage difference between the two grounds?

On your diagram it says 'ground for phone'. Phones use a 2 wire balanced connection, they are not designed to work with one wire grounded, so the whole concept is flawed.

+1 for a proper schematic, what you have posted is a nightmare to read.

See forum guide for information on schematics.

I apologize for not providing a proper schematic earlier and for any comments that lacked sufficient detail. Today, I was trying to organize everything more neatly, including on the breadboard, which unfortunately led to burning one ESP32. However, I did come to a few basic conclusions that I thought might be worth sharing, in case they help others:

  1. Only wire when the power is off.
  2. The 12V line doesn't need to be connected to the ESP32 – it worked fine for me even though others suggest connecting it.
  3. Check multiple diagrams for the same components and review the schematics – it turns out I used a misleading schematic for the DFPlayer, which caused several of them to burn out.

I plan to post a recap this weekend with pictures, clean schematics, and updated code. Hopefully, it will be useful to others!

Your "schematic" doesn't show the ESP power supply; how do you power it?

You are right, as I wrote in the last comment better schematics will be uploaded soon, because of my lack of experience it might take me a moment but I wish to do it by the weekend.
As of the esp32 power supply, I wrote it is powered via USB , but you are right it suppose to be shown in the schematics and I will add that.
Thank you!

Do you intend to tell us the voltage difference between the two grounds?

My bad, I missed it. :man_facepalming:

Assuming this is connected to a tel co line note what @PerryBebbington indicates the phone system is a non grounded 600 Ohm system. Th CO (Central Office) in some systes is 900 Ohms. Other countries may also be different. Grounding a phone line will cause a fault at the CO . When connecting expect a ring to be about 20Hz and about 100 Volts.

Your pictures look nice but do not convey any information. I will be waiting for your annotated schematic. Also post links to technical information on any non Arduino devices.

If you are not connecting to a CO at least you will have an indication as to what your phone connected to.