ESP32 and L298 module: Power Supply Issues

Hello everyone,
I’m building a small car controlled via a PS4 controller. The software works fine, but I’m having hardware issues.

When the ESP32 is powered through its mini USB port, everything works: the controller connects, sends commands, and the motors respond. The motors are powered separately by 4 AAA batteries (6V total) to avoid overloading the ESP32.

However, when I try to power the ESP32 from the same 6V source using an AMS1117 voltage regulator, the circuit initially works but stops when I quickly reverse the motors’ direction. It seems like the ESP32 loses connection with the controller.

components i'm using:

-esp32: DevKitC V2 esp32-wroom-32 made by Az-Delivery. (datasheet: https://azde.ly/embeajwu)

-"TT motor" made bySunfounder (info: TT Motor — SunFounder 3in1 Kit documentation)

-Ams1117 module 3.3V Stepdown voltage regulator made by Az-Delivery (datasheet: https://cdn.shopify.com/s/files/1/1509/1638/files/AZ050_B_2-1_IT_B072FTMS89_5b294f9f-122a-4cc7-b60c-0cb685c32523.pdf?v=1721113156)

-L298N module made by ATOYT, brand = xocome (I could not find the datasheet for this module, but this one should do: https://www.handsontec.com/dataspecs/L298N%20Motor%20Driver.pdf?)

-4 AAA batteries in series as the power supply.

Circuit Schematic

I hope the photo makes the circuit layout clear. I apologize in advance for any inaccuracies, as I’m a beginner and this is my first attempt at drawing a circuit diagram.

(P.S.: The GND connected to the ESP32 is shared with the GND of the battery pack. I’ve shown it separately for clarity and organization purposes.)

conclusions

I’m a beginner, and I recognize that this is an ambitious project for me, so the issue is likely related to incorrect power supply (I’m not sure how to calculate the current requirements for each component). I also considered that since I’m using a 6V power supply, I should connect 5V to the logic of the L298N module (according to the datasheet, it can be left unconnected only if using a 7V or higher supply). I left it unconnected, but before spending more money on voltage regulator modules, I prefer to ask someone with more experience.
What do you think is causing the problem? Should I change the type of battery or something else?

(I haven’t included the code because, as mentioned, everything works fine when the ESP32 is powered from the PC, but if you think it’s necessary, let me know, and I’ll share it.)

I appreciate any suggestions or help. Thank you!

  • The L298 5v pin needs to be powered.

  • Show us your wiring.

What @LarryD wrote.

And ...

Please elaborate specifically where that is stated.
I briefly scrolled through the datasheet; ST Datasheet L298
and searched for Vss without finding mentions about your allegations.

I did however note the lack of bypass capacitor which are explicitly in the datasheet:

VSS Supply voltage for the logic blocks. 
A 100nF capacitor must be connected between this pin and ground.

That says you are powering both the ESP32 and motors from the same power supply. That is a no no. We probably get this problem once a day.

You are right. I could not find the information either in the datasheet... I believe that I misinterpreted this:
"The module have an onboard 5V regulator which is either enabled or disabled using a jumper. If the motor supply voltage is up to 12V we can enable the 5V regulator and the 5V pin can be used as output, for example for powering our Arduino board. But if the motor voltage is greater than 12V we must disconnect the jumper because those voltages will cause damage to the onboard 5V regulator. In this case the 5V pin will be used as input as we need connect it to a 5V power supply in order the IC to work properly."

I just read this here. I can't remember where I read this in the first place.

About the wiring, I couldn't find a website that lets me draw wiring circuits, I took some photos instead, if you can send me the link to one I'll be happy to draw it there

wiring

I'm sorry if they're not so clear

thank you for that, I will try it

I understand, as I mentioned, I'm a beginner, and since I plan to include this in a project, I liked the idea of using a single power supply for the entire system. Is there really no way to do this? Also, it's still not clear to me why this is a problem in the first place

Hi,
I thought about it, but I couldn't figure out how... The problem I'm having is mostly due to the fact that I want to use a single power supply for everything, and I was not so sure if purchasing another voltage regultor was the right solution. Now, after what @wittrup said, I'm not so sure if this is even possible

  • See by the wiring image which L298 you have.
  • This should work for you:

Do not connect the USB cable while the ESP is being powered by the L298N

2 Likes

1 Like

It is possible to use a single PSU, but you need a much more powerful PSU. 4 AAA is puny. The reason is motors cause dips in voltage which can cause the ESP32 to re-boot. Since it's a car, a mains powered PSU is out of the question and you need batteries. This means you can use the AAA to power the ESP32 ONLY, then get 4 genuine 18650 type Lithium batteries (NO parallel) . Also, do not use the old inefficient L298N, get a mosfet type like TB6612FNG. Of course now you will need a proper Lithium charger like a SkyRC M3000

1 Like
  • And powering the L298N with 6V batteries (aim for 7-9 volts) will not properly power the onboard 78M05, 5V voltage regulator.

I have closed your other cross-post @marcusprojects .

Cross-posting is against the Arduino forum rules. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting can result in a suspension from the forum.

In the future, please only create one topic for each distinct subject matter. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Firstly, thank you so much to everyone for taking the time to provide such detailed responses. I really appreciate it!

I tried the circuit LarryD designed (with the only modification being the use of 7 AAA batteries, since with fewer I couldn’t get the controller to connect), and it works much better than my setup. However, unfortunately, I encountered the same issue after some time: as you predicted, the ESP32 reboots due to voltage dips.

I then followed your advice and tested the setup, using the 4 AAA batteries to power the motors, and another set of 4 AAA batteries connected to an AMS1117 3.3V voltage regulator to power the ESP32. This configuration works perfectly! I’ll definitely look into the specific batteries you recommended.

Regarding the motor driver, you're absolutely right. I initially bought the L298 when I didn’t know much about motor drivers, but now I plan to switch to more modern ones, like the TB6612FNG you suggested.

I’m really happy that this setup works, though I do wish I could have used just one power supply for everything.

1 Like

@pert:

I authorised @marcusprojects to start the same thread he had started in the Italian section also in the International section, since he had not received an answer after several days (probably due to the holidays).

The agreement was that as soon as a solution was found, @marcusprojects would post it in the Italian section as well, doing something useful for the readers of that section (which is why I have reopened his thread in the Italian section). :slight_smile:

Guglielmo

3 Likes

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