Buzzer keeps making sound

Hello! i am trying to make an alarm system for gas and i am using a gas sensor and a passive buzzer module , the problem is the buzzer make a sharp sound no matter what .it works if i use tone() but if tone is not called or does not even exist , the sound again, no tone() has no effect. What could it be?

Here is the code:

int buzzer = 32;
int smoke = A1;

void setup() {

pinMode(buzzer,OUTPUT);
pinMode(smokeA0, INPUT);
Serial.begin(9600);

}

void loop() {

Serial.println(analogRead(smoke));

// Checks if it has reached the threshold value
if (analogRead(smoke) > 300)
{

tone(buzzer, 1000, 200);
}
else
{

noTone(buzzer);
}

}

It's probably not a "passive buzzer". Do you have a link to the specs? If it makes a tone when connected between +5V and ground, it's an active buzzer.

Does it turn-off with digitalWrite(LOW); ?

Technically, there are no "passive buzzers". There are (passive) piezo transducers AKA piezo speakers WITH no electronics inside that convert the and electrical signal to sound, and there are (active) buzzers with (active) electronics inside to generate sound when power is applied.

If you have an active buzzer you are probably drawing excess current from the Arduino and you should use a transistor or MOSFET driver.

DVDdoug:
It's probably not a "passive buzzer". Do you have a link to the specs? If it makes a tone when connected between +5V and ground, it's an active buzzer.

Does it turn-off with digitalWrite(LOW); ?

Technically, there are no "passive buzzers". There are (passive) piezo transducers AKA piezo speakers WITH no electronics inside that convert the and electrical signal to sound, and there are (active) buzzers with (active) electronics inside to generate sound when power is applied.

If you have an active buzzer you are probably drawing excess current from the Arduino and you should use a transistor or MOSFET driver.

it makes the beep sound when i connect it to 32 digital pin as you see in the code, if i pull it off and is conected
only to vcc an ground stops beeping.

 if (analogRead(smoke) > 300)

Serial print the value of smoke to see if it ever drops below 300?

Read the how to use this forum-please read sticky to see how to post code properly. Use autoformat (ctrl-t or in the IDE, Tools, Auto Format) to indent your code to make it easier to follow.

It's not going above 300;

Look at this , when noTone() the beep is on, when tone(). the the sound works fine, i just can't make the buzzer stop.

int buzzer = 32;



void setup() {

 pinMode(buzzer,OUTPUT);
 
 
}

void loop() {

   tone(buzzer,2000);
   delay(5000);
  noTone(buzzer);
  delay(5000);
 
}

Well... I have no explanation for noTone() not working.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html . Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :slight_smile:

Hi,
The "buzzer" you have got is a BEEPER, it BEEPs when power is connected and it is activated.

You do not need tone output to drive it .

Just power, 3.3V to 5V to the Vcc pin, gnd to the gnd pin, and an output from your Arduino.

Please a circuit diagram and if possible a picture of your project.

Thanks.. Tom.. :slight_smile:

Quote from the website you linked to:

Passive Buzzer Module for Arduino low level trigger buzzer control panel alarm module

What is it?

  • Passive Buzzer Module for Arduino

What makes it special?

  • Module use 9012 transistor drive
  • working voltage 3.3V-5V
  • with fixed bolt holes, easy to install
  • PCB size: 3.3cm * 1.3cm

Module interface description (3 wire):

  • VCC external connect 3.3V-5V voltage (which can be connected directly with the 5V MCU and 3.3V chip)
  • GND external connect GND
  • I/O external connect microcontroller IO port

It says it has *low level trigger . *( I would have called it low level enable).

The module uses a 9012 transistor, which according to google is PNP. You would take the base of a PNP transistor low to make it conduct.

My guess is that you need to take the I/O pin high to silence the device , and that taking it low will make it sound.

As TomGeorge said, there is no need to use a tone to use this type of buzzer.

:stuck_out_tongue: This is what happens when you buy the cheapest thing you can find on the Internet instead of buying from a reliable distributor with links to datasheets & schematics, etc. You think you're buying a passive transducer and you get an active beeper.

...I was confused because the description is wrong and I could see the transistor on the board and I could see that there not an oscillator on the board (not enough circuitry for an oscillator). But... The "answer" was in my 1st post. You have an active beeper with an oscillator inside the beeper, plus they put a transistor driver on the board so you don't have to provide it.