Clap on, clap off with the Raspberry Pi Clapper ??

While many people use off-the-shelf automation setups for their electrical appliances, Ash Puckett’s Raspberry Pi Clapper pays homage to the king of infomercial classics.

Remember this?

Build your own Raspberry Pi Clapper

Sometimes, the best Raspberry Pi projects don’t need thousands of lines of code and a makerspace full of tech to make an impact: Ash Puckett‘s Clapper uses only a Raspberry Pi and a USB microphone as a basis. After that, it’s up to you to integrate the device into whatever project you wish, from home lighting and security systems to entertainment consoles — really anything you can switch from one state to another, including a Raspberry Pi!

GitHub user nikhiljohn10’s clap detection script allows the USB mic to pick up the control clap. With the help of the RPi.GPIO and PyAudio libraries, Ash demonstrates that the Clapper works by turning on and off a red LED attached to the Pi.

You will find instructions for putting together the code and running it on your Pi on the project’s Howchoo page. Howchoo also hosts some of Ash’s other Raspberry Pi projects, including a music streaming device, a smart clock, and a Pi-powered calendar.

Try the Clapper

Why not give the Clapper a go, and let us know what you decide to use it for!

I, for one, will secretly set one up to mess with all the lights in the office — what could possibly go wrong?

11 comments

Giles Read avatar

I’m sure I’m missing the point somewhere but clap switches have been implemented in very, very simple electronic hardware for an enormous amount of time. For instance, see
https://circuitdigest.com/electronic-circuits/clap-switch-project
– a representative example that uses just ten components including the battery, microphone and LED. The total cost is pennies: the most expensive thing is probably the 9V battery.

I know I’m old and moany but I question the wisdom of using a multi-core, multi-MIPS processor and gigabytes of memory (= billions of transistors) to replicate a device that can be put together much more cheaply in pure hardware, uses a teensy, teensy fraction of the power, and which ‘boots’ in microseconds, not minutes. I venture to suggest this is training people to overcomplicate solutions and waste resources. How much of my desktop PC’s power is used to accomplish an actual task compared to running the bloated operating system and vast swathes of code in the application?

OK, end of rant. But do remember, simple is often good too.

Alex Bate avatar

I see this statement a lot when sharing projects on our social media channels. While it’s sometimes true that a project could be completed with a smaller, cheaper device, we must consider the possibility that the project creator only owns a Raspberry Pi. Or maybe they want it to do more than just that one function, and running everything off of a Raspberry Pi saves time, cost, and space. I don’t own a Teensy, an Arduino, etc. I just own a Raspberry Pi. So I run all my projects on that. Simple is often good, but so is accessibility.

AndrewS avatar

And using a RaspberryPi also instantly enables it to be extended to “IoT” type stuff, e.g. https://projects.raspberrypi.org/en/projects/tweeting-babbage

Giles Read avatar

Thanks Alex. I do of course recognise that programming a Raspberry Pi (or PIC or Arduino) to blink a LED in response to a stimulus is an important ‘Hello world’ first step. Once you’ve mastered that, writing a real-time control system for an engine or a nuclear power plant or a rocket is merely a matter of scale.

Simple analogue electronics alone cannot meet more than a tiny proportion of needs, and neither can pure software-based techniques. But pairing these, with a knowledge of both, is where the true power lies.

It amuses and saddens me when I see vast computing power used for trivial applications that could so easily be done in cheap hardware – “Alexa, turn on the lights”.

AndrewS avatar

*round of applause*
Whoops! ;-)

Dan3008 avatar

AndrewS – instant rave ;-)

madnerd avatar

Clapper are really fun, until you get sick, and realize that it activates when you cough loudly lol.

James avatar

In response to all the comments above I agree that this could be implemented with very simple electronics.. and yes the original device would respond to any loud noises.. It would be an interesting exercise to see if one could improve the original device with an overkilled version powered by a Raspberry Pi, for example, with all this processing power, one should no only be able to distinguish between a real clap-clap and a cough, but also distinguish between claps that happen by a person or on TV, or distinguish between the claps of more than one person, and also distinguish different patterns of claps by multiple people.. etc…

AndrewS avatar

And you could also have different clap patterns (e.g. clap-clap-pause-clap) triggering different actions ;-)

Buzz-T avatar

I used the pyaudio and the pycurl library to send a HTTP-Request to my ESP8266-µC. The µC is connected to a WS2812B-LED-Strip and has endpoints for different animation modes. If I clap twice the light turns off/on. With three claps I switch to the next animation.
Unfortunatly the USB-Microphone on my Pi registers if I walk on the floor of my room and sometimes triggers the HTTP-Request randomly.

Tom avatar

Hi, any ideas as to how I could connect this up to a lamp that has an inline switch?
Is it possible? I really want to try this.

Comments are closed