Home Automation with Clap Sequence Control
C++, Signal Processing, Circuit Design
Overview
This is a clap sequence sensitive home automation prototype that switches a lamp on and off. The C++ code on an Arduino Nano triggers when two loud bursts are heard with a short delay between them. It also takes a running average of the ambient noise to dynamically adjust how loud a clap “should” be. The main accomplishments of this project are:
- Can control any mains voltage appliance only by clapping.
- Only registers a sequence of two claps with a short delay, and within some tolerance.
- Adjusts for ambient noise to not give false positives.
- Has debouncing protection to prevent false positives from a series of loud noises.
- Allows manual control with a button.
Personal Motivation
When the pandemic hit, I was in my first year of undergrad. Despite my newfound enthusiasm for building circuits (thanks to my friend gifting me an Arduino kit that changed my life!), I was stuck at home with limited resources. To entertain myself I would take apart and study the PCBs of stuff like bug zappers, oxygen sensors, lasers etc. while slowly building up an inventory of bought/scavenged electronic parts. My mom finally directed me in a more constructive direction by asking me to build something that would let her turn the lights off without getting out of bed… and here we are!
Hardware
The hardware consists of an LM 393 sound sensor
, a 5V relay
with a flyback diode
, a 2N3906 npn transistor
as a switch, and an Arduino Nano
.
There is also a 50kΩ potentiometer
which can be used to adjust the sensitivity of the device i.e., if there’s too much background noise, make the device less sensitive.
Conclusion
This device works extremely well, even over long periods of time. It does exactly what its supposed to and is very good at filtering out false positives like my dog barking, people talking, the TV running, and construction work outside of the house. Eventually, I ended up uninstalling it because it needed to be plugged in constantly, which would interfere with charging stuff. Also, sometimes it is more convenient to get out of bed and just flip a switch, than clap your hands and wake half the house up!