๐น Overview
The KY-037 is a high-sensitivity sound detection sensor that can detect noise levels in the environment. It provides both analog and digital outputs. In this tutorial, we’ll interface the digital output of KY-037 with Raspberry Pi 3 Model B+ (without using an ADC like MCP3008) and detect sound events.
๐ ️ Components Required
✔️ Raspberry Pi 3 Model B+
✔️ KY-037 Sound Sensor
✔️ Breadboard & Jumper Wires
๐ Circuit Diagram
In this project, we'll use only the D0 (Digital Output) pin of the KY-037 sensor, which can be connected directly to a GPIO pin on the Raspberry Pi.
๐ KY-037 to Raspberry Pi Connections
KY-037 Pin | Raspberry Pi 3 (BCM Pin) |
---|---|
VCC | 3.3V |
GND | GND |
D0 | GPIO 17 (Physical Pin 11) |
๐ Python Code to Detect Sound Events
Save the following Python code as ky037_digital.py
and run it on your Raspberry Pi.
import RPi.GPIO as GPIO
import time
SOUND_SENSOR_PIN = 17 # GPIO17
GPIO.setmode(GPIO.BCM)
GPIO.setup(SOUND_SENSOR_PIN, GPIO.IN)
print("Sound Sensor Test (KY-037 - Digital Output)")
try:
while True:
if GPIO.input(SOUND_SENSOR_PIN) == GPIO.LOW:
print("Sound Detected!")
time.sleep(0.1)
except KeyboardInterrupt:
GPIO.cleanup()
print("\nProgram stopped.")
๐ก How It Works
The KY-037 sensor outputs a LOW signal on the D0 pin when the sound level exceeds a set threshold. This signal is read by Raspberry Pi's GPIO pin. The Python script checks for a LOW signal and prints a message when sound is detected.
๐ฏ Applications
✅ Voice-activated triggers
✅ Clap detection
✅ Basic sound alarms and alerts
๐ เคฎเคฐाเค ीเคค เคธเคฎเคाเคตเคฃी (Marathi Explanation)
๐น เคชเคฐिเคเคฏ
KY-037 เคนा เคเค เคเค्เค เคธंเคตेเคฆเคจเคถीเคฒเคคेเคा เคธाเคंเคก เคธेเคจ्เคธเคฐ เคเคนे เคो เคเคตाเคाเคी เคชाเคคเคณी เคเคณเคเคคो. เคฏाเคฎเคง्เคฏे analog เคเคฃि digital เคฆोเคจ्เคนी เคเคเคเคชुเค เค
เคธเคคाเคค. เคฏा เค्เคฏुเคोเคฐिเคฏเคฒเคฎเคง्เคฏे เคเคชเคฃ KY-037 เคा เคซเค्เคค เคกिเคिเคเคฒ เคเคเคเคชुเค (D0) เคตाเคชเคฐूเคจ เคฐाเคธ्เคชเคฌेเคฐी เคชाเคฏ 3 B+ เคถी เคเคจेเค्เค เคเคฐเคฃाเคฐ เคเคนोเคค.
๐ ️ เคเคตเคถ्เคฏเค เคเคเค
✔️ เคฐाเคธ्เคชเคฌेเคฐी เคชाเคฏ 3 B+
✔️ KY-037 เคธाเคंเคก เคธेเคจ्เคธเคฐ
✔️ เคฌ्เคฐेเคกเคฌोเคฐ्เคก เคเคฃि เคเคฎ्เคชเคฐ เคตाเคฏเคฐ
๐ เคธเคฐ्เคिเค เคเคจेเค्เคถเคจ
KY-037 เคा D0 เคชिเคจ เคฐाเคธ्เคชเคฌेเคฐी เคชाเคฏ เค्เคฏा GPIO17 เคฒा เคोเคกा.
KY-037 เคชिเคจ | เคฐाเคธ्เคชเคฌेเคฐी เคชाเคฏ เคเคจेเค्เคถเคจ |
---|---|
VCC | 3.3V |
GND | GND |
D0 | GPIO 17 (เคชिเคจ 11) |
๐ เคชाเคฏเคฅॉเคจ เคोเคก
เคाเคฒिเคฒ เคोเคก ky037_digital.py
เคจाเคตाเคจे เคธेเคต्เคน เคเคฐा เคเคฃि เคाเคฒเคตा:
import RPi.GPIO as GPIO
import time
SOUND_SENSOR_PIN = 17 # GPIO17
GPIO.setmode(GPIO.BCM)
GPIO.setup(SOUND_SENSOR_PIN, GPIO.IN)
print("Sound Sensor Test (KY-037 - Digital Output)")
try:
while True:
if GPIO.input(SOUND_SENSOR_PIN) == GPIO.LOW:
print("เคเคตाเค เคเคขเคณเคฒा!")
time.sleep(0.1)
except KeyboardInterrupt:
GPIO.cleanup()
print("\nเคช्เคฐोเค्เคฐॅเคฎ เคฅांเคฌเคฒा.")
๐ก เคนे เคเคธे เคाเคฐ्เคฏ เคเคฐเคคे?
KY-037 เคा D0 เคชिเคจ เคเคตाเคाเคी เค เคฐाเคตिเค เคชाเคคเคณी เคเคฒांเคกเคฒ्เคฏाเคตเคฐ LOW เคธिเค्เคจเคฒ เคฆेเคคो. เคนा เคธिเค्เคจเคฒ เคฐाเคธ्เคชเคฌेเคฐी เคชाเคฏ เคตाเคเคคो เคเคฃि เคค्เคฏा เคตेเคณी เคช्เคฐिंเค เคธ्เคेเคเคฎेंเค เคฆाเคเคตเคคो.
๐ฏ เคเคชเคฏोเค
✅ เคต्เคนॉเคเคธ-เค्เคฐिเคเคฐ เคฏंเคค्เคฐเคฃा
✅ เคाเคณी เคिंเคตा เคเคตाเค เคเคณเคเคฃे
✅ เคฌेเคธिเค เคธाเคंเคก เค
เคฒाเคฐ्เคฎ्เคธ
Comments