DHT 11 + Buzzer with Arduino UNO


I have connected DHT 11 with arduino UNO and i would like to connect the buzzer too so that buzzer starts ringing when it crosses the threshold value.
Can anyone please suggest the code?
Will appreciate your help.


Can you read values from the DHT11 ?
Libraries for such devices usually have example code.

Yes @UKHeliBob
I can read values from sensor.

So, read the value, compare it with the target and turn on the buzzer when the threshold is exceeded. Where are you stuck ?

What type of buzzer is it ?

It is SFM-27.
I was stuck at turning on the buzzer and how to set its frequency, but now its done.
Thanks Bob

I need to increase the sound of a buzzer, it is very low. I am using the tone function as:
tone(7, 1000, 4000);

Anybody can help?

Thanks in advance.

There are 2 types of buzzer.

One requires the input to be pulsed to produce an output, for which the tone() function could be used to set the frequency, the other just requires a voltage to be applied across its terminals and it produces a fixed frequency.

Which type is the buzzer that you have ? What happens if you simply put 5V across its terminals ?

It produces a fixed frequency when i simply put 5v across its terminals. And when i increases the voltage, sound increases. But i need to increase the sound by frequency.

Sorry, but you cannot change the frequency of that buzzer. You could increase the volume by using an Arduino output to switch an external 12V supply to the buzzer using a transistor.

OK. Thanks