Sound Sensor Interfacing Raspberry Pi

 1. Introduction

A sound sensor is used to detect sound levels in the environment. It works using a microphone that converts sound waves into electrical signals. This sensor is commonly used for clap detection and sound-activated systems.


2. Components

  • Raspberry Pi
  • Sound Sensor Module 
  • LED
  • 220Ω Resistor
  • Breadboard
  • Jumper Wires

3. Circuit and connections

Raspbery Pi
Raspberry Pi Pinout Diagram
Pinout Diagram of Sound Sensor Module
Pinout Diagram of Sound Sensor Module

Connections:

  • VCC → 5V (Pin 2)
  • GND → GND (Pin 6)
  • DO → GPIO17 (Pin 11)
  • LED + → GPIO18 (Pin 12)
  • LED – → GND (via 220Ω resistor)

4. Detailed Step By Step Circuit working

  1. Microphone detects sound waves
  2. Sound is converted to electrical signal
  3. Comparator circuit generates digital output
  4. When sound exceeds threshold → DO becomes LOW
  5. Raspberry Pi reads signal
  6. When sound detected → LED turns ON
  7. When no sound → LED OFF

5. Libraries to be included

import RPi.GPIO as GPIO
import time

6. Code

import RPi.GPIO as GPIO
import time

sound = 17
led = 18

GPIO.setmode(GPIO.BCM)
GPIO.setup(sound, GPIO.IN)
GPIO.setup(led, GPIO.OUT)

while True:
if GPIO.input(sound) == 0: # Sound detected
GPIO.output(led, True)
print("Sound Detected")
else:
GPIO.output(led, False)
time.sleep(0.1)

7. Detailed Step By Step Code working

  1. Import GPIO and time libraries
  2. Assign sound sensor to GPIO17
  3. Assign LED to GPIO18
  4. Set GPIO mode to BCM
  5. Set sensor as input
  6. Set LED as output
  7. Read sensor value
  8. If LOW → sound detected → LED ON
  9. Else → LED OFF
  10. Add delay for stability

8. Tips

  • Adjust sensitivity using onboard potentiometer
  • Avoid noisy environments for testing
  • Place sensor close to sound source
  • Use proper shielding for stable readings

9. Uses

  • Clap switch systems
  • Sound-activated lights
  • Noise monitoring
  • Security alarms

10. Conclusion

The sound sensor is a simple and effective module for detecting sound events. This project helps in building interactive and automation systems using Raspberry Pi.

തുടക്കക്കാർക്കായുള്ള ഇലക്ട്രോണിക്സ് ലളിതമായി പഠിക്കാം.

Empowering students in Kerala with hands-on technical skills.