ESP32 - Relay - Water Pump getting feedback buzzing?

To give the full layout i have 120V AC comming from house, it goes to control box which has a Meanwell RS15-5 (5Volt Power Source) which goes to 10uf & 0.1uf Capacitor to ESP32-Wroom Board. I have gpio14 going to seed 3.3v relay. the relay has 1N4007 rectifier diode going from power to ground at relay. the 120V AC 25watt water pump load wire is attached to the 5v power souce then the relay output. My problem is that when i turn the pump on or off the esp32 goes to sleep half the time because of power fluctuation of some kind. if i run the relay without the pump it works perfectly. when the relay does work with pump is buzzes. i am thinking it is because the water pump power is also the esp32 through the power source, but i dont want to have to plug 2 wires into house. I have the simaler setup with a bigger pump no problems but power wire is seperated. i am thinking a SSR like G3MB-202P might be needed. i will share my code just cus. Any help is appreciated. Cheers

switch:
  - platform: gpio
    name: "Tower Water Pump"
    pin: 
      number: GPIO14
      mode: OUTPUT
      inverted: False
    id: tower_water_pump
    restore_mode: RESTORE_DEFAULT_OFF
    on_turn_on:
      - delay: 500ms  # Add a small delay before action
      - lambda: |-
          id(manual_tower_water_pump_switch_override) = true;
    on_turn_off:
      - delay: 500ms  # Add a small delay before action
      - lambda: |-
          id(manual_tower_water_pump_switch_override) = true;

globals:
  - id: manual_tower_water_pump_switch_override
    type: bool
    restore_value: no
    initial_value: 'false'

Your problem is 15W power supply with 25W pump. You need beefier psu, there’s no way around.
Gpio 34 is input only, but your yaml presents gpio14.
1N4007 from power to ground would cause short circuit, maybe you mean from gnd to power.

1 Like

I had similar troubles trying to run a tiny motor from a transistor whose base was connected to a GPIO, and power supply same as ESP. ESP blew up everytiem.

A 50¢ motor controller chip totally solved the problem.

The Pump is 120v AC the power supply is for esp32 alone. gpio misreference u are correct it is gpio14. the diode is hooked - to - , + to +

all im doing is controlling a relay that just happens to be a pump that is running, could be a light a whatever. its more about the power fluctiation of start up shut down and isolating my system from the power drops.

When in doubt, add more capacitors… :tired_face:

See what your osciolloscope says between gpio and gnd or +5v and gnd, when the pump starts.

Good cheap oscilloscope for this kinda thing is the Zoyi that’s like $50 on aliexpress.

Thanks for info on $65 Zoyi. Till i get 1 do u think i should put capacitors or resisters in different spots or just increase the size?

I only see what you write.
I wouldn’t expect 25W pump to cause voltage fluctuation that can cause esp to reset. I drive 1500W pump without issues from same outlet. Do you have pump wires enough distant from Esp wiring?

the power wire for pump is the power wire for esp. esp power & ground are just Tees off pump wire. its only three feet wire to the pump. ( i am thinking it is because the water pump power is also the esp32 through the power source, but i dont want to have to plug 2 wires into house.)

That’s not possible if your pump is 120VAC. Make a simple circuit scheme or good photo.

1 Like

Unless you really WANT a challenge, you are better off buying one of the premade solutions that can control your line voltage devices. I started with Sonoff devices, when they were the only ones around. There are now many choices. Most of them work quite well and are likely much much safer.

1 Like

Athom makes excellent ESPHome plugs.

Definitely suggest looking at oscilloscope readings between neutral of the ESP and the GPIO pin you’re using to drive the relay module. Also, if you’re using an LM2596, why not directly use the 3.3 volt output to power the 3V3 pin in the ESP?

Your wiring for the relay and the pump looks very unusual. If your picture is accurate, it is no wonder the pump isn’t working.

Here is a random search result for how to do it.

replace the light bulb in the example with your pump. You picture does not show the pump getting 120V, since only one wire is connected and it is connected to ground. The relay should be switching the high/hot/120V line, which is the green wire in your picture. You NEVER use a green wire for a hot line (in any of the several color codes used around the world). This is the reason I say you should be using a commercial product. Working with high voltage :zap:can be dangerous and lead to death, especially if you don’t know what you are doing or if you get too complacent.

there is a white wire going to the pump to if u look close. i messed up the wire colors there i just adjusted colors even though load wire ac is black i made it maroon just so i didnt have ground on low voltage side black as well as load wire. i fixed the image. i could bring the AC ground to the pump because only 2 pins on pump so it would make the wire color wrong.

You could simplify you circuit to take out some odds.
If your relay module really is 3.3V module (3.3V written on relay), you can power it directly from Esp 3.3V pin, it can handle the coil current without problems. That 1N4007 there doesn’t have any purpose, relay module already have diode in the right place.
Make sure the low voltage wiring doesn’t run together with 120VAC wiring, keep them distant. Also relay needs to have certain distance to the pump. And keep the wiring between Esp and relay module short as possible.

I adjusted to a new schematic and design. I have made verything straight forward changed to a 38 pin esp32. I removed all capacitors & diodes. AC power for power source and water pump are coming from different recepticles on wall. i powered esp32 through pins. i do have other sensor , leds that go on this thats why i have more power than needed. doesnt matter what code i use to switch relay it just buzzes and works 80% of the time then it just cuts out esp32. all relays esp32 etc are within 6 inches of eachother. i dont understand. i have the same setup but different esp and bigger power source and it works fine. would a ssr solve this for me ?

Get a motor controller. Motor controller solved the exact same problem for me.

Did you follow my advice to get an oscilloscop and probe the circuit?