Passive buzzer shorting NodeMCU on restart

Hi All,

I have an IR sensor hooked up to a NodeMCU v3 and passive buzzer with an LED. The device triggers the LED and the buzzer if the sensor detects an object for more than 10 seconds. It is working well but I have a hardware issue. The buzzer causes the board to short if I have it connected during startup (it makes a buzz and lights up all LEDs). This prevents the board from every functioning as it just gets stuck during startup. If I have the buzzers positive input disconnected during startup and then connect after, it works fine. The trouble is, the nature of my project is one where you would unplug and store when not using, then plug in and power up when you need it. So if it shorts on power up this won't work. I am still very new to all of this so the electronics side is still a learning curve for me. I tried a resistor in line with the live input to the buzzer but this just made the sound quieter. Can anyone provide some guidance as to the correct wiring set up to prevent this short from happening? The buzzer is connected to D4/GND, LED to D5/GND and IR sensor to VCC/A0/GND. I actually tried startup with all other devices removed and just the buzzer connected and I had the same issue so I don't think the other wiring is causing anything. Thanks for any help anyone can give!

Is the + side of the buzzer connected to pin D4 or to ground?

Pin D4 (gpio2) can't be low at boot time. Use another pin for the buzzer or use an npn transistor with say a 4.7k base resistor to drive the buzzer.

Passive buzzer (piezo) act like capacitor and as already mentioned, GPIO2 is special during startup. Some boards also have a blueLED on this pin.
Another pin should be utilized.

Search - ESP32 - — esptool.py latest documentation (espressif.com)

This page shows the pinouts for various ESP8266 boards and has a listing of which pins can be used and the pros and cons of using them.

Thank you for your advice. Moving to D1/GPIO5 solved the problem. Interesting to know about the way the pins are used during boot up. @groundFungus the article was helpful thank you. I also found this page very helpful and clear:

https://rabbithole.wwwdotorg.org/2017/03/28/esp8266-gpio.html

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