Magnetic vs piezo buzzer

broken image

Let me know in the comment section if you know the melody that we create in this example. The passive buzzer has the advantage that we can not only create a tone, but also a melody with different frequencies. The digital I/O pin of the Arduino, EPS8266 or ESP32 microcontroller is therefore connected to the gate of the MOSFET with a resistor of 220Ω in series, because the Arduino operation voltage of 5V or even the 3.3V operation voltage of the ESP8266 or ESP32 would damage the transistor. Otherwise we were not able to switch off a load that has a higher voltage than the control voltage. In my case I use the IRLZ44 NPN MOSFET as low-side transistor to control the buzzer. The solution is to use a transistor and divide between the control signal and the power consumption. But if we want to use magnetic buzzers with a current consumption higher than 20mA we have to find a different power supply than the digital I/O pin of the microcontroller.

broken image
broken image

Piezo buzzer have a current consumption lower than 20mA and could therefore be powered by Arduino microcontroller as well as the ESP32.

broken image