I have a Raspberry Pi that is powered by mains from a AC-DC Laptop Charger (with DC Buck regulator).

I also have a DIY Nodemcu (Home Automation project), it has a relay (5V with a control circuit that I got somewhere here and built it[ the relay module itself does use PNP and the nodemcu cannot turn off the relay itself]), they are powered by another AC-DC charger (5V output).

Both of them are connected to a single automatic voltage regulator but, whenever I turn on or off the relay (nodemcu is controlling the relay) with a plugged in Electric Fan as the AC Load, the Raspberry Pi suddenly resets (hardware reset, like shorting the RESET pin on the Board). I live in SE Asia and we only have 2 prong US like outlet (no grounding, | |), I beleive that they are both live (220V) or maybe each prong are half of the 220V.

Is there any way to determine why this happen? My initial design was to use the same PSU from the RPi and the NodeMCU but I've encountered the problem whenever I cycle the relay, so I used a separate PSU for the nodemcu but I was surprised that the issue persist. The relay module has the glass diode (maybe 1n4148) connected in reverse (protection from spikes?) it is connected to the NodeMCU GPIO D5 with an arduino sketch program that I made.

  • \$\begingroup\$ Could you post a schematic of what you have and how it is connected? \$\endgroup\$
    – Wendall
    Dec 14, 2019 at 17:32
  • \$\begingroup\$ is there any load connected to the relay? does the problem persist with no load on the relay? \$\endgroup\$ Dec 14, 2019 at 20:52
  • \$\begingroup\$ The question should be not how RPi and NodeMCU are powered, but how you fan is connected and how much current it draws on startup. Regardless of this, try adding about 100uF caps to the power inputs of both RPi and NodeMCU and see if it fixes the problem \$\endgroup\$
    – Maple
    Dec 14, 2019 at 21:48
  • \$\begingroup\$ I will post schematic later, I have not tested the 'no load' scenario of the relay as I risk corrupting my Pi's HDD/microSD if it happens, will try to find 100uF (they are powered isolated from each other). \$\endgroup\$
    – R1BNC
    Dec 15, 2019 at 0:06
  • \$\begingroup\$ the schematic for the pi is here: electronics.stackexchange.com/questions/471712/… \$\endgroup\$
    – R1BNC
    Dec 15, 2019 at 0:38

1 Answer 1


I had a similar situation. An intercom would operate a solenoid strike normally. But a pulse or a glitch from the electric strike would reset the postal timer circuit back to the top of the hour. I added a clamp diode onto the solenoid coil.

  • \$\begingroup\$ The question explicitly states that this was a already done for the relay. To be a useful answer, you'd need to explain a way in which your approach would be superior to the method described in the question. The load of the circuit in the question is an AC fan, so a diode obviously can't be used on that the way it could on your solenoid load. \$\endgroup\$ Dec 14, 2019 at 19:40
  • \$\begingroup\$ I tried to use the AC electric fan without a relay from nodemcu and the pi, does not reset. But whenever I plug that fan to the relay and cycle it on/off the pi resets. \$\endgroup\$
    – R1BNC
    Dec 14, 2019 at 23:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.