Small Microphone Sound Detection Module KY-038 in Raspberry Pi

Learn interfacing Small Microphone Sound Detection Module KY-038 in Raspberry Pi. A sound sensor acts like a microphone that detects sound signals. The sensor will detect sound signals a provide digital or analog output. The sound sensor can be used to make exciting projects like clap switch. This article will make led glow on the detection of sound. So, let’s start.

Step 1: Required Components

Raspberry Pi x 1
Small Microphone Sound Detection Module KY-038 x 1
Generic LED x 1
Breadboard x 1
220Ω Resistor x 1
Jumper Wires

Step 2: Circuit Time

The following are instructions for making a circuit to interface small sounds with Arduino.

  1.  Connect (+) pin and GND pin of the sound sensor to +5v and GND of Raspberry Pi.
  2. Now, connect the D0 pin of the sound sensor to GPIO pin 17 of Raspberry Pi.
  3. Then connect LED to GPIO pin 27 of Arduino by placing a 220Ω resistor in between long leg of LED and GPIO pin 17.



Step 3: Code Time

This code for Small Microphone Sound Detection Module KY-038 in Raspberry Pi. Firstly, we initialize pin d0 (sound) and led pin. Now, we have to set the sound pin as input and led pin as an output. We added event detect to detect rising/falling edge of signals. Event detect will get the value of the signal and send it’s value to the callback method. The callback method will check if the value of the sound signal. If it is a high LED, it will glow otherwise LED will not glow.



Step 4: Run code to Raspberry Pi

Run the Python program in your Raspberry Pi after setting components as per the circuit diagram. The LED will turn on when sound is detected. If you are facing issues while detecting sound, adjust the sensitivity of potentiometer on board.

For running python code in Raspberry PI, visit: raspberrypi.org/documentation/usage/python/

Learn basic hardware information of Raspberry Pi 3.

1 thought on “Small Microphone Sound Detection Module KY-038 in Raspberry Pi”

Leave a Reply