{"id":237054,"date":"2021-01-31T22:31:18","date_gmt":"2021-01-31T21:31:18","guid":{"rendered":"https:\/\/emariete.com\/?p=237054"},"modified":"2021-01-31T22:31:18","modified_gmt":"2021-01-31T21:31:18","slug":"buzzer-active-or-passive-buzzer-for-arduino-esp8266-nodemcu-esp32-etc","status":"publish","type":"post","link":"https:\/\/emariete.com\/en\/zumbador-activo-o-pasivo-para-arduino-esp8266-nodemcu-esp32-etc\/","title":{"rendered":"Active or passive buzzer for Arduino, ESP8266, NodeMCU, ESP32, etc."},"content":{"rendered":"<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Sometimes we need our ESPEasy-based project to generate sound alerts, such as warnings, alarms, confirmation of certain actions, or other reasons. In this article, we will see, step by step, how we can<strong> add a buzzer to our project with ESPEasy<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Buzzers give people a lot of problems when it comes to getting them to work and this is mainly because there are several types of buzzers and each one has to be used in a different way. The best way to make them work is to know how to use them from the beginning, <strong>the type of buzzer you have in hand<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I'm not going to limit myself to just using buzzers with the ESP8266, NodeMCU and Wemos D1 Mini, but I'm also going to cover how to do it with Arduino and ESP32, although it's very similar.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this case, the examples are going to be done on the <a href=\"https:\/\/emariete.com\/en\/carbon-gas-co2-meter\/\">CO2 meter<\/a> I published a few days ago, but <strong>can be applied to any other type of project<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-tipos-de-zumbadores-o-buzzers\">Types of buzzers, or buzzers<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The first thing we need to know is that <strong>not all buzzers are the same<\/strong>. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We can differentiate them mainly by <strong>two characteristics<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Does the buzzer have an integrated oscillator (it is a <strong>active or passive buzzer<\/strong>)?<\/li><li>How are the tones generated (buzzer <strong>piezoelectric or electromagnetic<\/strong>)?<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">As each of these characteristics is independent, this means that we have in total four different combinations:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th class=\"has-text-align-center\" data-align=\"center\"><\/th><th>Piezo<\/th><th>Magnetic<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\"><strong>Liabilities<\/strong><\/td><td>The tone is generated by a piezo buzzer and there is no built-in oscillator.<\/td><td>It has no built-in oscillator and the tone is generated by a magnetic buzzer.<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\"><strong>Active<\/strong><\/td><td>The tone is generated by a piezoelectric diaphragm and the buzzer has a built-in oscillator.<\/td><td>It has a built-in oscillator and magnetic buzzer.<\/td><\/tr><\/tbody><\/table><figcaption>Table of buzzer types<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In the course of this article we will go into the different types of buzzers in more detail.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Differences between passive and active buzzer<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The fundamental difference between an active and a passive buzzer is that the active buzzer has an internal oscillator, whereas the passive buzzer does not. The other differences are derived from this and are summarised in the following table.<\/p>\n\n\n\n<figure id=\"tablepress-229\" class=\"wp-block-table\"><table><thead><tr><th>&nbsp;<\/th><th class=\"has-text-align-center\" data-align=\"center\">Passive Buzzer<\/th><th class=\"has-text-align-center\" data-align=\"center\"><strong>Active Buzzer<\/strong><\/th><\/tr><\/thead><tbody><tr><td><strong>Oscillator<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\">No internal oscillator<\/td><td class=\"has-text-align-center\" data-align=\"center\">Integrated oscillator<\/td><\/tr><tr><td><strong>Power input<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\">Alternating current<\/td><td class=\"has-text-align-center\" data-align=\"center\">Direct current or square wave<\/td><\/tr><tr><td><strong>Terminal length<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\">Same length of terminals<\/td><td class=\"has-text-align-center\" data-align=\"center\">The positive has a longer terminal<\/td><\/tr><tr><td><strong>Relative price<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\">Cheap<\/td><td class=\"has-text-align-center\" data-align=\"center\">Caro<\/td><\/tr><tr><td><strong>Identification<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\">No sticker on top<\/td><td class=\"has-text-align-center\" data-align=\"center\">With white sticker on top<\/td><\/tr><tr><td><\/td><td class=\"has-text-align-center\" data-align=\"center\"><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" class=\"wp-image-237110\" style=\"width: 150px;\" src=\"https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/zumbador.png\" alt=\"\" srcset=\"https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/zumbador.png 1000w, https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/zumbador-300x300.png 300w, https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/zumbador-150x150.png 150w, https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/zumbador-768x768.png 768w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/td><td class=\"has-text-align-center\" data-align=\"center\"><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" class=\"wp-image-237352\" style=\"width: 150px;\" src=\"https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/zumbador-activo.png\" alt=\"\" srcset=\"https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/zumbador-activo.png 500w, https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/zumbador-activo-300x300.png 300w, https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/zumbador-activo-150x150.png 150w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/td><\/tr><\/tbody><\/table><figcaption>Differences between passive and active buzzers<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Notice, as <strong>a good trick to tell them apart<\/strong>The active buzzers usually come with a label or sticker on the top and the bottom of an active buzzer is usually sealed with resin.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Differences between piezo and magnetic buzzers<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Buzzers can be classified depending on <strong>technology<\/strong> they use to generate the sound.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The most commonly used buzzers in microcontroller projects are the piezo buzzer, or piezoelectric buzzer, and the magnetic buzzer, or electromagnetic buzzer.  There are other technologies, but they are not as common in microcontroller projects.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the following table I show you the main ones <strong>differences between a piezo and a magnetic buzzer<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th><\/th><th class=\"has-text-align-center\" data-align=\"center\">Piezo buzzer<\/th><th class=\"has-text-align-center\" data-align=\"center\"><strong>Magnetic buzzer<\/strong><\/th><\/tr><\/thead><tbody><tr><td><strong>Operating voltage<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\">12V~220V<\/td><td class=\"has-text-align-center\" data-align=\"center\">1.5V~12V<\/td><\/tr><tr><td><strong>Current consumption<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\">&lt; 20mA<\/td><td class=\"has-text-align-center\" data-align=\"center\">&gt; 20mA<\/td><\/tr><tr><td><strong>Sound pressure level (SPL)<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\">85~120 dB<\/td><td class=\"has-text-align-center\" data-align=\"center\">70~95dB<\/td><\/tr><tr><td><strong>Resonant frequency<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\">2~6 kHz<\/td><td class=\"has-text-align-center\" data-align=\"center\">1~3 kHz<\/td><\/tr><\/tbody><\/table><figcaption>Differences between piezoelectric and electromagnetic buzzers<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Below, I explain, in a little more detail, the most important things about each of them.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-c-mo-funciona-un-zumbador-piezo\">How a piezo buzzer works<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The piezoelectric buzzer is a type of buzzer based on the properties of piezoelectric crystals (polyester or ceramic), which <strong>deform when a stress is applied between their faces<\/strong> and which, acting as an electro-acoustic transducer, is used for sound reproduction.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If a flared cone is attached to one of its faces, it will undergo displacements capable of producing an oscillating pressure within an audible frequency range, i.e. low frequency.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Piezoelectric buzzers <strong>are simple<\/strong>and capable of emitting sounds using <strong>very little electrical energy<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Your answer is <strong>optimal for the reproduction of high frequencies<\/strong>are incapable of reproducing low-frequency ranges.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Piezo buzzers are designed for use with high voltages (typically between 5V and 220V) and with current consumptions of less than 20mA. Because of the higher voltages, piezo buzzers typically have a <strong>higher sound pressure level<\/strong> (SPL) (between 85db and 120db) than magnetic buzzers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A piezo buzzer responds to voltage at any frequency, but much more strongly the closer you get to its <strong>resonance frequency between 2 kHz and 6 kHz<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-c-mo-funciona-un-zumbador-magn-tico\">How a magnetic buzzer works<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Understanding how a magnetic buzzer works is much easier because we are more familiar with them. <strong>This is the way the loudspeakers work.<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When a voltage is applied to a <strong>coil <\/strong>generates a magnetic field which causes a movement by the attraction or repulsion effect it exerts on one or more magnetic fields. <strong>magnets <\/strong>of which the buzzer is equipped.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-diferencia-entre-zumbador-y-m-dulo-zumbador\">Difference between buzzer and buzzer module<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Differentiating between a buzzer and a buzzer module <strong>is very important when it comes to their connection<\/strong>but it is also very easy to distinguish.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A buzzer is just the buzzer itself and the buzzer module additionally incorporates <strong>the transistor and the resistor<\/strong> (and sometimes a protection diode).<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"300\" class=\"wp-image-237110\" style=\"width: 300px;\" src=\"https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/zumbador.png\" alt=\"\" srcset=\"https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/zumbador.png 1000w, https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/zumbador-300x300.png 300w, https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/zumbador-150x150.png 150w, https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/zumbador-768x768.png 768w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/td><td>The buzzer is a single component whose function is to generate sounds.<br><br>A buzzer (the individual component), in most cases, needs external components to function.<\/td><\/tr><tr><td><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"133\" class=\"wp-image-237111\" style=\"width: 300px;\" src=\"https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/modulo-zumbador.jpg\" alt=\"\" srcset=\"https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/modulo-zumbador.jpg 946w, https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/modulo-zumbador-300x133.jpg 300w, https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/modulo-zumbador-768x341.jpg 768w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/td><td>A buzzer module is a board on which we find the buzzer together with the additional external components needed to connect it to a microcontroller.<\/td><\/tr><\/tbody><\/table><figcaption>Buzzer and buzzer module difference table<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Buzzer<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-medium\"><a href=\"https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/zumbador.png\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"300\" src=\"https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/zumbador-300x300.png\" alt=\"Piezoelectric buzzer\" class=\"wp-image-237110\" srcset=\"https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/zumbador-300x300.png 300w, https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/zumbador-150x150.png 150w, https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/zumbador-768x768.png 768w, https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/zumbador.png 1000w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption>Piezoelectric buzzer<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">If you have a loose buzzer, as a rule, <strong>you will not be able to connect it directly to the microcontroller<\/strong> ESP8266, because, although its power consumption is not too high, it is higher than what the microcontroller can provide.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Buzzer module<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-medium\"><a href=\"https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/modulo-zumbador.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"133\" src=\"https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/modulo-zumbador-300x133.jpg\" alt=\"\" class=\"wp-image-237111\" srcset=\"https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/modulo-zumbador-300x133.jpg 300w, https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/modulo-zumbador-768x341.jpg 768w, https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/modulo-zumbador.jpg 946w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption>Piezo buzzer module<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">If you have a buzzer module, the connection between the module and the Arduino, EPS8266 or ESP32 microcontroller board is very simple. Just connect the positive and negative power supply and the control signal to the I\/O pin of the microcontroller and you are ready to go.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"127\" class=\"wp-image-237350\" style=\"width: 150px;\" src=\"https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/Buzzer-Activo.jpg\" alt=\"\" srcset=\"https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/Buzzer-Activo.jpg 325w, https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/Buzzer-Activo-300x254.jpg 300w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/td><td>Passive buzzer module<\/td><\/tr><tr><td><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"127\" class=\"wp-image-237351\" style=\"width: 150px;\" src=\"https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/Buzzer-Pasivo.jpg\" alt=\"\" srcset=\"https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/Buzzer-Pasivo.jpg 325w, https:\/\/emariete.com\/wp-content\/uploads\/2020\/12\/Buzzer-Pasivo-300x254.jpg 300w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/td><td>Active buzzer module<\/td><\/tr><\/tbody><\/table><figcaption>Trick to tell them apart: The one with the sticker on top is active.<\/figcaption><\/figure>\n\n\n<div class=\"gb-container gb-container-02d7beb2\"><div class=\"gb-inside-container\">\n\n<h2 class=\"wp-block-heading\" id=\"h-por-qu-motivo-necesitamos-un-transistor\">Why do we need a transistor?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When creating a circuit to control a buzzer, either active or passive, with a microcontroller such as Arduino, ESP8266 or ESP32, we must take into account <strong>the limits of the current that can be supplied by its pins<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Buzzers, as a rule, <strong>consume more current than one pin of a microcontroller is capable of supplying.<\/strong>If the buzzer draws more current than the pin is capable of supplying, we will have to provide a solution.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong>peak currents<\/strong> that can be provided by the pins of the microcontrollers we are talking about, are the following:<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table class=\"has-subtle-pale-blue-background-color has-background\"><thead><tr><th class=\"has-text-align-center\" data-align=\"center\"><strong>Microcontroller<\/strong><\/th><th><strong>Plates<\/strong><\/th><th class=\"has-text-align-right\" data-align=\"right\"><strong>Max current<\/strong>.<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">ATmega328P<\/td><td>Arduino Nano, Arduino Uno, Arduino Pro Mini<\/td><td class=\"has-text-align-right\" data-align=\"right\">40 mA<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">ATmega2560<\/td><td>Arduino Mega<\/td><td class=\"has-text-align-right\" data-align=\"right\">20 mA<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">ESP8266<\/td><td>ESP-01, NodeMCU, WeMos D1 Mini<\/td><td class=\"has-text-align-right\" data-align=\"right\">12 mA<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">ESP32<\/td><td>DevKitC, Adafruit HUZZAH32, Sparkfun ESP32 Thing Plus<\/td><td class=\"has-text-align-right\" data-align=\"right\">20 mA<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The buzzers <strong>piezoelectric<\/strong>have a current consumption of <strong>20mA <\/strong>and can therefore be powered directly by the Arduino microcontroller and the ESP32 (not the ESP8266, if you look at the table above). But if we want to use magnet buzzers with a current consumption higher than 20 mA, we need to have a <strong>power supply <\/strong>different from the I\/O pin of the microcontroller.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The solution is to use a transistor and separate the control signal and the power supply line. In my case, I use the <strong>2N2222 NPN as power transistor for supplying the buzzer<\/strong>.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>NPN transistor: because we want to turn on the buzzer, active or passive, by setting the digital pin of the microcontroller HIGH.<\/li><li>Low-side switch: the transistor is on the low (negative) side of the circuit and the buzzer is connected to the positive (5V or 3.3V) side. If this were not the case, we would not be able to disconnect a load that has a higher voltage than the control voltage.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Many (most) commercial modules use a <strong>PNP instead of NPN transistor<\/strong> which has the effect that <strong>are triggered by a low signal<\/strong> (when the control signal is removed they sound). You will need to take this into account when writing your rules and adapt them, if necessary.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When you use a buzzer module with <strong>low signal activation<\/strong>is <strong>particularly important<\/strong> that, after the sound is emitted, the pin that controls the buzzer <strong>stay at a high level<\/strong> (pin activated or at 1), otherwise the buzzer would remain activated without emitting sound and would burn out (remember that the buzzers with PNP type transistor, almost all of them, are activated by low level).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The best thing to do, if you have a multimeter, is to make sure, by measuring voltage <strong>directly on the buzzer element <\/strong>(not at the module input), that there is no voltage applied.<\/p>\n\n<\/div><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-esquema-de-un-m-dulo-zumbador\">Diagram of a buzzer module<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In the following image you can see the <strong>common scheme<\/strong> of commercially available buzzer modules (such as those illustrated in this article).<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/emariete.com\/wp-content\/uploads\/2021\/01\/Modulo-Zumbador-PNP.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"576\" height=\"444\" src=\"https:\/\/emariete.com\/wp-content\/uploads\/2021\/01\/Modulo-Zumbador-PNP.jpg\" alt=\"\" class=\"wp-image-237524\" srcset=\"https:\/\/emariete.com\/wp-content\/uploads\/2021\/01\/Modulo-Zumbador-PNP.jpg 576w, https:\/\/emariete.com\/wp-content\/uploads\/2021\/01\/Modulo-Zumbador-PNP-300x231.jpg 300w\" sizes=\"auto, (max-width: 576px) 100vw, 576px\" \/><\/a><figcaption>Buzzer module schematic<\/figcaption><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Buzzer connection to an Arduino Uno<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The following images show the <strong>wiring between the buzzer and different microcontrollers<\/strong> (in preparation).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Buzzer connection to an ESP8266<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In the following images you can see the <strong>wiring between the buzzer and the NodeMCU or WeMos D1 Mini<\/strong>. On other ESP8266 based boards the wiring will be almost identical, adapting to the appropriate pins.<\/p>\n\n\n\n<p class=\"has-vivid-red-color has-text-color wp-block-paragraph\"><strong>WARNING UNTIL I CAN CHANGE THE DIAGRAM: DO NOT CONNECT THE BUZZER TO 5V. CONNECT IT TO 3.3V TO AVOID ANNOYING NOISES (AS EXPLAINED BELOW).<\/strong>)<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/emariete.com\/wp-content\/uploads\/2021\/01\/Diagrama-Conexion-NodeMCU-Modulo-Zumbador.png\"><img loading=\"lazy\" decoding=\"async\" width=\"718\" height=\"446\" src=\"https:\/\/emariete.com\/wp-content\/uploads\/2021\/01\/Diagrama-Conexion-NodeMCU-Modulo-Zumbador.png\" alt=\"\" class=\"wp-image-237526\" srcset=\"https:\/\/emariete.com\/wp-content\/uploads\/2021\/01\/Diagrama-Conexion-NodeMCU-Modulo-Zumbador.png 718w, https:\/\/emariete.com\/wp-content\/uploads\/2021\/01\/Diagrama-Conexion-NodeMCU-Modulo-Zumbador-300x186.png 300w\" sizes=\"auto, (max-width: 718px) 100vw, 718px\" \/><\/a><figcaption>NodeMCU connected to passive buzzer module<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/emariete.com\/wp-content\/uploads\/2021\/01\/Diagrama-Conexion-Wemos-D1-Mini-Modulo-Zumbador.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"475\" src=\"https:\/\/emariete.com\/wp-content\/uploads\/2021\/01\/Diagrama-Conexion-Wemos-D1-Mini-Modulo-Zumbador.jpg\" alt=\"\" class=\"wp-image-237527\" srcset=\"https:\/\/emariete.com\/wp-content\/uploads\/2021\/01\/Diagrama-Conexion-Wemos-D1-Mini-Modulo-Zumbador.jpg 624w, https:\/\/emariete.com\/wp-content\/uploads\/2021\/01\/Diagrama-Conexion-Wemos-D1-Mini-Modulo-Zumbador-300x228.jpg 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/a><figcaption>Wemos D1 Mini connected to passive buzzer module<\/figcaption><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Wiring between the Buzzer and ESP32 boards<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The ESP32 follows the names of the ESP8266. Simply connect it as in the examples above to the pins with the same names.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-un-inconveniente-de-los-m-dulos-de-zumbador-activados-por-nivel-bajo\">A drawback of low level activated buzzer modules<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Unfortunately (for what I will discuss below), most commercially available buzzer modules are low level activated (you will have a harder time finding one that is high level activated) and this has the following drawback:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A buzzer of the type we are talking about here, emits a louder sound when connected to 5V than when connected to 3.3V. The problem is that <strong>with low level activated modules we cannot (or should not) supply them at 5V.<\/strong>If we are going to use them with an ESP8266 or ESP32 (with the consequent loss of sound power) because of the following:<\/p>\n\n\n\n<p class=\"has-cyan-bluish-gray-background-color has-background wp-block-paragraph\">Suppose we connect the buzzer module to 5V. <br><br>The problem is that, for the buzzer, the \"high level\" (silence) would be those 5 volts, but, of course, the ESP8266 or ESP32 do not output 5 volts on their pins, but 3.3 volts.<br><br>This means that when we pull a high level on the pin to silence the buzzer, the buzzer does not receive 5V, which is what it expects, but 3.3V. An intermediate voltage that <strong>for him it is neither high nor low<\/strong>. <br><br>Consequence: the buzzer will probably emit clicks, clacks, and strange sounds because those 3.3V are leading it to <strong>an undefined place, where he (in his digital world of 0 and 5 volts) doesn't know how to live<\/strong>.<br><br>Solution: Power it at 3.3 volts, albeit at a lower sound level. Most of the time you will want the buzzer for warning purposes, not as an alarm, and the sound level at 3.3 volts is more than enough.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-construye-tu-m-dulo-zumbador\">Build your own buzzer module<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">I, in particular, always prefer to build my own buzzer modules. That way I have it <strong>quickly <\/strong>and build them with an NPN transistor, <strong>so that they are activated by high level<\/strong>. Much more logical and easier to use.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized is-style-default\"><a href=\"https:\/\/emariete.com\/wp-content\/uploads\/2021\/02\/Buzzer-DIY.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/emariete.com\/wp-content\/uploads\/2021\/02\/Buzzer-DIY-1024x576.jpg\" alt=\"\" class=\"wp-image-237559\" width=\"768\" height=\"432\" srcset=\"https:\/\/emariete.com\/wp-content\/uploads\/2021\/02\/Buzzer-DIY-1024x576.jpg 1024w, https:\/\/emariete.com\/wp-content\/uploads\/2021\/02\/Buzzer-DIY-300x169.jpg 300w, https:\/\/emariete.com\/wp-content\/uploads\/2021\/02\/Buzzer-DIY-768x432.jpg 768w, https:\/\/emariete.com\/wp-content\/uploads\/2021\/02\/Buzzer-DIY-1536x864.jpg 1536w, https:\/\/emariete.com\/wp-content\/uploads\/2021\/02\/Buzzer-DIY.jpg 1920w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><figcaption>SMD NPN homemade buzzer module<\/figcaption><\/figure>\n<div class=\"essb_break_scroll\"><\/div>","protected":false},"excerpt":{"rendered":"<p>Everything you need to know about connecting a buzzer to a NodeMCU, ESP8266 or Arduino<\/p>","protected":false},"author":1,"featured_media":237529,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","_lmt_disableupdate":"yes","_lmt_disable":"no","footnotes":""},"categories":[17],"tags":[20,26,28,41,43],"class_list":["post-237054","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-proyectos-arduino","tag-arduino","tag-espeasy","tag-esp8266","tag-nodemcu","tag-proyectos-arduino"],"modified_by":"Mariete","uagb_featured_image_src":{"full":["https:\/\/emariete.com\/wp-content\/uploads\/2021\/01\/Zumbador-activo-o-pasivo-para-Arduino-ESP8266-NodeMCU-ESP32-etc.png",1080,608,false],"thumbnail":["https:\/\/emariete.com\/wp-content\/uploads\/2021\/01\/Zumbador-activo-o-pasivo-para-Arduino-ESP8266-NodeMCU-ESP32-etc-150x150.png",150,150,true],"medium":["https:\/\/emariete.com\/wp-content\/uploads\/2021\/01\/Zumbador-activo-o-pasivo-para-Arduino-ESP8266-NodeMCU-ESP32-etc-300x169.png",300,169,true],"medium_large":["https:\/\/emariete.com\/wp-content\/uploads\/2021\/01\/Zumbador-activo-o-pasivo-para-Arduino-ESP8266-NodeMCU-ESP32-etc-768x432.png",768,432,true],"large":["https:\/\/emariete.com\/wp-content\/uploads\/2021\/01\/Zumbador-activo-o-pasivo-para-Arduino-ESP8266-NodeMCU-ESP32-etc-1024x576.png",1024,576,true],"1536x1536":["https:\/\/emariete.com\/wp-content\/uploads\/2021\/01\/Zumbador-activo-o-pasivo-para-Arduino-ESP8266-NodeMCU-ESP32-etc.png",1080,608,false],"2048x2048":["https:\/\/emariete.com\/wp-content\/uploads\/2021\/01\/Zumbador-activo-o-pasivo-para-Arduino-ESP8266-NodeMCU-ESP32-etc.png",1080,608,false],"trp-custom-language-flag":["https:\/\/emariete.com\/wp-content\/uploads\/2021\/01\/Zumbador-activo-o-pasivo-para-Arduino-ESP8266-NodeMCU-ESP32-etc.png",18,10,false]},"uagb_author_info":{"display_name":"Mariete","author_link":"https:\/\/emariete.com\/en\/author\/admin_xlyz052h\/"},"uagb_comment_info":2,"uagb_excerpt":"Todo lo que necesitas saber para conectar un zumbador a un NodeMCU, ESP8266 o Arduino","_links":{"self":[{"href":"https:\/\/emariete.com\/en\/wp-json\/wp\/v2\/posts\/237054","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/emariete.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/emariete.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/emariete.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/emariete.com\/en\/wp-json\/wp\/v2\/comments?post=237054"}],"version-history":[{"count":0,"href":"https:\/\/emariete.com\/en\/wp-json\/wp\/v2\/posts\/237054\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/emariete.com\/en\/wp-json\/wp\/v2\/media\/237529"}],"wp:attachment":[{"href":"https:\/\/emariete.com\/en\/wp-json\/wp\/v2\/media?parent=237054"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/emariete.com\/en\/wp-json\/wp\/v2\/categories?post=237054"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/emariete.com\/en\/wp-json\/wp\/v2\/tags?post=237054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}