Help me in not fry another ESP in my project!

Hello so I have fried I guess 2 ESPs during a project. I have a ESP8622 but the pins are not sufficient (even though I added 74hc595). I'm thinking of buying another ESP32, but I want to make sure to not fry this one, here's my project in a nutshell:

PS: I want to specify that there were a lot of changes during the making of this project, for example, at first I was only using a HW-131 and a 18V adapter, then I changed the adapter to 12V 2A one, then I powered the HW-131 through this adapter (which fried it), then I removed the HW and I'm currently only working with the 12V adapter

Existing system: A client of the company I'm an intern in has an irrigation system, and he wants to automate it and enables controlling the system from France. The system is a 380V moto pump that is bidirectional and can only be at one state at a time. The system has 3 exclusive states:

  • P (puits which means well) means that the pump pulls water from the well and stocks it in a storage tank.
  • R (repos which is like stop) means the whole system is at a stop.
  • I (irrigation) means that the motor pumps water from the tank to the fields of olives or almonds (they can't be both on at the same time). The choice of fields is also chosen manually. (O and A).

Objectif: Make a prototype using ESP presenting the solution. I chose it to be controlled through Blynk and I decided to add a "planning" mode, and a safe planning if Wifi or Blynk fails to connect.

Components: 12V 2A adapter, L298N (for the pump), 3 relays (for the micro electro valves), 1 LED and a buzzer (to blink if I is chosen and no field is chosen), 5 buttons, a water level sensor, and an RTC module (I'm still not sure whether to use this or not).
PS: I'm using the LN298 as a 5V provider because I dropped the HW-131, for the electro valves, I'm using 3.7V batteries.

Blynk: Here's what I did until now (cause it's not finished), I'll add the water level of the tank later:

The problems I have: obviously me frying everything and me not knowing how to treat the 12V and its high current. I suspect this is what fried the HW-131 because at one point it was powered by it, and one ESP32 uploads the code without any problems (with everything off), the moment I plug the adapter, it gives me weird resetting error (invalid header: 0*0ffffff if I rememebr or something like this).

I know this isn't the best way to present a project, I have an unfinished report if anyone wants to take a look at my vision of the project and the system's constraints. Also, I know someone at least is going to ask for a diagram, I'll attach it as soon as I make it in fritzing. Thanks in advance for anyone who can help me.

Note: I found a 9V 1A adapter, should I use it instead of the 12V 2A?? Will it be able to give current to relays through the L298N's 5V output?

Here's the diagram!

No, I won't ask for the diagram right now, but, will ask if you are hooking a lot of stuff together and trying to make a program to make it work, rather than doing a single tiny step at a time and testing that the step works. Sounds like you have tried to do a bunch of stuff. A project as you described might take 6 months, realistically.

6 months! Well, the internship is only 2 months long, and I'm about to finish. I have the model with pumps and tubes and stuff. Anyways, the answer is no, I learned not to do this, so I tarted with only relays, L298N, buttons, and LEDs instead of electro valves at first, and then I started adding a thing one by one, what I observed is that when I added the RTC module, and when I changed the power source of the HW-131 to that 12V adapter, the first ESP stopped working, that's why i dropped the HW-131 altogether, I still don't know what's the problem until now (I found 1.8A in the terminals 5V terminals of the HW-131 which I suspect was the reason), but I don't think the circuit I was having consumed that much current. Anyways, if you can help me with the adapter power source, 3.3V logic tips that will be very helpful. I'll send the diagram as soon as I make it.

What is the maximum current required by your ESP?
What is the maximum current required by your pump?
What is he maximum current required by the relays and valves?

Can the relays work with 3.3V logic?

I'm using 3.7V batteries.

For what?

Hello, thanks for responding. This is what I found on the internet (I have ESP32S Nodemcu):

  1. Max current for ESP32: because it's a nodemcu I didn't find my exact model and a lot of infos, here are some that could be helpful:


  2. Max current for the pump:

  3. Max current for valves and relays:
    image

I think relays can work, I tried it once, but that won't be ideal. I'm using 3.7V Li-on batteries for the electrovalves.

Where are the pumps getting their power from ?

So you see for the ESP current > 600mA and that is more than the L298 5V can provide. Don't even think about putting 10V to an ESP board!

If your relays are not designed for 3.3V logic then don't connect them to an ESP!

From the 12V 2A adapter going through the L298N, and I adjust 12V through ENA (PWM) so that it decreases by half (6V). The pump works fine!

They're 5V relay modules! but I don't have other relays! I'll see if they can work with 3.3V, and are you sure? Because I was using relays just fine through the ESP pins and nothing happened! I don't think they're the main problem but I understand where you're coming from.

Maybe not today or tomorrow but if you continue to apply 5V to and ESP pin it will eventually fail.
Did you not learn anything for your other topic

I know but most say it's safe! Because of the optocoupler. I find re-buying everything i have that should work with 3.3V logic is tedious, don't you think?

I'll really appreciate advices concerning what I have now! I'm kind of short in time, I need to work with what I have!

Only if the opto works on 3.3V

I find re-buying everything i have that should work with 3.3V logic is tedious, don't you think?

More tedious than buying more ESPs when you burn them out. Up to you.

Hey! I just finished the diagram!