KY-012 Active Piezo-Buzzer
When this sensor is powered, this active buzzer generates a sound with the frequency of 2.5kHz.

When this sensor is powered, this active buzzer generates a sound with the frequency of 2.5 kHz. The active buzzer module, unlike the passive module KY-006 does not require a square wave voltage to generate a tone. If a voltage of min. 3.3 V is applied to its signal pin, the required square wave voltage is generated by the buzzer itself.
Technical data
Operating voltage | 3,3 V - 5 V |
Maximum current | 30 mA |
Tone frequency | 2,5kHz ± 300 Hz |
Minimum sound output | 85 dB |
Operating temperature | -20 °C - 70 °C |
Storage temperature | -30 °C - 105 °C |
Dimensions | 19 x 15,5 x 11 mm |
Pin assignment
Code example Arduino
Pin assignment Arduino
Arduino | Sensor |
---|---|
Pin 13 | Signal |
- | +V |
ground | GND |
This code example shows how the buzzer can be switched on alternately for four seconds and then switched off for two seconds using a definable output pin.
int Buzzer = 13;
void setup ()
{
pinMode (Buzzer, OUTPUT); // Initialize output pin for the buzzer
}
void loop () //main program loop
{
digitalWrite (Buzzer, HIGH); // Buzzer is switched on
delay (4000); // wait mode for 4 seconds
digitalWrite (Buzzer, LOW); // Buzzer is switched off
delay (2000); // Wait mode for another two seconds in which the LED is then turned off
}
Example program download
Code example Raspberry Pi
Pin assignment Raspberry Pi
Raspberry Pi | Sensor |
---|---|
GPIO 24 [Pin 18] | Signal |
- | +V |
Ground [Pin 6] | GND |
This code example shows how the buzzer can be switched on alternately for four seconds and then switched off for two seconds using a definable output pin.
# Required modules are imported and set up
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
# Here the input pin is declared, to which the sensor is connected.
Buzzer_PIN = 24
GPIO.setup(Buzzer_PIN, GPIO.OUT, initial= GPIO.LOW)
print("Buzzer test [press CTRL+C to exit test]")
# main program loop
try:
while True:
print("Buzzer 4 seconds on")
GPIO.output(Buzzer_PIN,GPIO.HIGH) #buzzer is switched on
time.sleep(4)#wait mode for 4 seconds
print("Buzzer 2 seconds off")
GPIO.output(Buzzer_PIN,GPIO.LOW) #buzzer is switched off
time.sleep(2)#wait mode for another two seconds then LED is off
#rearrange after the program has been terminated
except KeyboardInterrupt:
GPIO.cleanup()
Example program download
To start with the command:
sudo python3 KY012-RPi.py
Code example Micro:Bit
Pinout Micro:Bit:
Micro:Bit | Sensor |
---|---|
Pin 1 | Signal |
- | +V |
Ground | GND |
