Wireless Multi-Channel Voice-Controlled Electrical Outlets with Raspberry Pi

FeaturedContest Winner
Picture of Wireless Multi-Channel Voice-Controlled Electrical Outlets with Raspberry Pi
Update 2/11/2014: Thanks to everyone who voted for this project in the Raspberry Pi contest!

This project is a combination of several difference resources:

The end result is voice-activated control of up to three electrical outlets using the Raspberry Pi. Here's a video of the final product in action (read on for a detailed parts list, circuit diagram, and code):

A couple notes before you begin. This project is up-to-date as of December 2013, but Gordon and Steve may update their respective software in the future. If you notice any major changes to WiringPi or Voice Command that make my instructions obsolete, please leave a comment or send me a message. Also, while my previous Instructable was written to be super beginner friendly, this one is a little more advanced so it skips over a lot of the introductory material. I refer back to the single-channel version several times, instead of duplicating the content here.

Here is a list of the parts I used. Of course, if you know what you're doing you can make substitutes as needed, or shop around for cheaper suppliers. Quantities in parenthesis.

Materials & Tools

The cost of this project depends heavily on what you already have lying around. If you already have a Raspberry Pi, webcam/mic and basic electronics equipment (tools, breadboard, jumper wire etc) it will only be about $40 for the wireless remote, relays and MOSFETs, and the cost goes up from there.

*My Quickcam Pro is 5 years old and I'm not sure if this exact model has been discontinued, or if it is the same thing as the "Webcam Pro 9000", which pops up on Amazon. You may need to do some poking around online to find out if your webcam is compatible with the Raspberry Pi (keep in mind that you only need the mic, and don't care about video). This wiki has an extensive list of verified peripherals.
Remove these adsRemove these ads by Signing Up
1-40 of 57Next »
vikas0013 days ago

hi i want to know dose raspberry pi listens to you every time without going to sleep ?

Ben Finio (author)  vikas0013 days ago

The Raspberry Pi does stay on continuously. You have to say the keyword first ("Pi" in my video) for it to process a voice command, but it does not go to sleep in between commands.

thanks and where can i change the word pi because i dont want to use pi word for it to listening i want to use different word like computer etc.

Ben Finio (author)  vikas0012 days ago

In the configuration file there should be a line something like


change "pi" to whatever you want to use a different keyword.

See Steven Hickson's website for the full documentation:

Thanks you were really helpful...

Thanks you were really helpful...

phlau743 months ago
From the video, you said "turn lamp on" and voicecommand repeated "turn lamp on".

Is there such option in voicecommand to set to do that? Thanks.
Ben Finio (author)  phlau743 months ago

What I said in my other comment. Change the response text in the config file:

light one on==tts "Yes, sir." && gpio write 0 1 && sleep 1 && gpio write 0 0

to whatever you want, like

light one on==tts "Turning lamp on." && gpio write 0 1 && sleep 1 && gpio write 0 0

It is hard-coded, VoiceCommand is not automatically repeating what I say. Notice that I say "turn" and VoiceCommand says "turning".

phlau743 months ago
From the video, you said "turn lamp on" and voicecommand repeated "turn lamp on".

Is there such option in voicecommand to set to do that? Thanks.
phlau743 months ago

Hi, nice project. How you configured the VoiceCommand to repeat your command that you have spoken?

Ben Finio (author)  phlau743 months ago

Oops - I might have misunderstood your question. Do you mean "repeat the command out loud" or "execute the command more than once"?

Ben Finio (author)  phlau743 months ago

In the config file (Step 7), change the text in quotes:

light one on==tts "Yes, sir." && gpio write 0 1 && sleep 1 && gpio write 0 0

I have it set to "Yes, sir." but you can change it to whatever you want.

phlau743 months ago

Hi, nice project. How you configured the VoiceCommand to repeat your command that you have spoken?

mikerbob5 months ago

Great instructable - well done. Now my problem. My remote set is a little different from yours, but so close though that the pin outs are the same on the remote. My symptom is that when I raise the GPIO to high, the relay triggers, the LED on the remote lights up, but does not trigger the 120V plug. Unplug the remote from everything, and it works as it should (so it still works). Is there some troubleshooting step that I missed? Thanks in advance.

Ben Finio (author)  mikerbob5 months ago

Hmm. So, you know there's nothing wrong with your remote since it works fine when you unplug it and just push the buttons. You know your code, GPIO pins and relays are working correctly since you can hear the relays triggering. And you know the remote is receiving a signal since its LED lights up.

The only thing I can think of is that you soldered to the wrong pins on the remote, or the pinout is actually different even if it looks very similar to mine. Did you actually measure the voltage at each of the pins when you push each button, or just go by looks and visually following the circuit traces to the buttons? Can you post pictures of your remote and the circuit board?

Thanks Ben. I did recheck and see that each soldered lead goes +5V when the corresponding button is pressed (and doesn't move off 0 when the other buttons are pressed :-). I attached an image of this remote for reference.

Again, thanks for you reply. It's great to get a response.
photo (1).JPG
Ben Finio (author)  mikerbob5 months ago

Ok, so to add to the mystery (or maybe help resolve it?): I just moved my whole setup from my office to my living room. Everything worked very reliably in my office, where I shot the video. The only problems I had were related to the actual voice recognition (i.e. sometimes it would interpret "lights off" as "white sauce"), but the remote always triggered the outlets.

Now, in my living room (about 12'x17' vs 10'x10' for the office), it's very inconsistent. Even skipping voice command entirely and just typing the GPIO commands at the command prompt - sometimes it works, and sometimes it doesn't. I've been trying to figure out if it has something to do with the state of the pins/outlets when the Pi shuts down or turns on, e.g. if the lights are already on when the Pi boots up, does that somehow screw it up? But I can't find anything consistent - sometimes I reboot the Pi and it goes back to working, sometimes it doesn't.

Since I didn't have that problem in my smaller office, my only guess is that it actually has something to do with the range or signal power of the remote. If so, that would be very disappointing - I forget the advertised range of the remote, but I'm pretty sure it's way more than 15 feet. Have you tried using the adapters on an outlet that's physically very close to your Pi?

My remote has the same chip, so I think we are just a different revs of the remote overall.

I did do my testing of the standard remote, unconnected, to test that it still is functioning in the same location that it sits when it is connected. It works without issue to plugs 1, 6, and 15 feet away.

The only additional item I can add is that the LED on the remote glows bright and steady when unconnected and a button is pressed. It glows less-bright and has a "flicker" when it is driven by the Pi. I'll look next into power to see if there is a mismatch there from what is being driven by the remote itself and what the Pi delivers.

I'll keep plugging away - no pun intended - and see what I can come up with and report back.

Thanks and good luck with your issue after movement from test bench to final environment.

Ben Finio (author)  mikerbob5 months ago

Checking back in - check out this thread. The creator of the kit suggested increasing the length of the remote's antenna by soldering an additional 6" of wire on. I'm going to give that a shot when I get a chance.

Ben Finio (author)  Ben Finio5 months ago

Doh...stupid link didn't work. I blame the new editor.

I don't think my issue is the antenna (I could be wrong there) unless the rig or pi is causing enough interference that it no longer works in this "harsher" environment.

I did add a separate power source (1A USB) for just the breadboard. Same result. gpio triggers the relay, the LED on the remote light up, the remote plug does not trigger.

Is there a way to simply test the remote via the leads that are soldered there and a power source applied manually?

Ben Finio (author)  mikerbob5 months ago

Hmm. You could either use a 3xAA (or AAA) battery pack, which should supply 4.5V; or cut up a USB power supply cable (like the one that powers the Pi) and use that to get 5V from the V+ and GND wires. That way you can just connect a HIGH logic signal directly to the wires you soldered to the remote and not use the Pi at all (you'll probably still want to use a solderless breadboard though). If you do that make sure the remote shares a common ground with either the battery pack or the USB cable.

If you don't want to cut up a USB cable you can look for a breadboard adapter like this:

Ben Finio (author)  mikerbob5 months ago

Ok - so last night, I had myself convinced it was a range issue with the remote, because I could get it to work consistently when I plugged an adapter in right next to my TV stand, but not when the lamp was plugged in across the room.

Of course, this morning I was unable to reproduce that issue. I booted the Pi up and everything worked just fine. While I'm still unable to consistently reproduce the problem, I've noticed two things:

1. Either unplugging the remote adapters or rebooting the Pi while the lights are on seems to screw things up, sometimes. i.e. reboot the Pi while both lights are on, and then I can't turn them off from the command line - even if it was controlling both lights fine before the last reboot. Or, unplug a light that's on, and then the Pi can't control it when I plug it back in in the exact same spot. So, if you haven't already, try using the disconnected remote to turn the lights off, then boot up the Pi. Maybe unplug everything and plug it back in while you're at it (can't hurt, right?).

2. A vague hunch that it's a power issue, especially when you mention your LED flickering. I'm actually powering my Pi from this powered USB hub (I combined this build with a RetroPie and didn't want to have two power cords). That hub can provide 3A total split between 7 devices, which should be more than enough for the Pi and the remote - but things seem to work more consistently when the Pi is powered off certain ports more than others. I'm not sure if there are internal limitations on the hub where some of the ports have current limits and are only intended for low-power devices. Regardless - can you try just running the breadboard's power bus off a completely separate power supply? Either a 5V USB source, or 4.5V from a 3xAA battery pack (should still be recognized as a logical high)? I'd be surprised if the remote is drawing more current than the Pi's +5V supply can provide, because as far as I know that comes straight from USB...but who knows. If you do that, make sure the other power supply still shares a common ground with the Pi.

Ben Finio (author)  mikerbob5 months ago

Honestly I'm stumped then. Comparing your image to this one from my project, it does look like the layout of your board's traces is slightly different, but ultimately all the same pins go to the same buttons.

How about making sure we actually have the same chip? You can't really see it in my photos, but mine has AUT980202-B printed on the top. Maybe there's something else going on with your board that my tutorial doesn't account for at all...

My only other guess would be to somehow read the RF signals, but I have absolutely no idea how to do that because I have zero experience working with RF. Assuming you find some way to decode/read/whatever the signal when each button is pressed, then you could compare that to the signal when you drive it using the Pi (or see if it's even generating an RF signal at all). Again, not a clue how to do that myself, but I'm betting there's an Instructable on it somewhere...

Last question - are you testing it under the exact same conditions when you push the buttons and when you use the Pi? Same outlets, same range between the remote and the outlet, etc? My remote is a little finicky sometimes, so just a thought.

mason101985 months ago

To automatically set the GPIO's as outputs and auto-run the "voicecommand -c" command, you can visit this link for a quite easy way to create a startup script.

Easy startup script to run every time your RasPi boots:

Create a file for your startup script and write your script in the file:

$ sudo nano /etc/init.d/superscript

Save and exit!

Make the script executable:

$ sudo chmod 755 /etc/init.d/superscript

Register script to be run at startup:

$ sudo update-rc.d superscript defaults

All done!

Easy startup script to run every time you login:

Make sure you are in the pi folder:

$ cd <mypifolder>

Create a file and write a script to run in the file:

$ sudo nano superscript

Save and exit!

Open up .bashrc for configuration (still in pi folder):

$ sudo nano .bashrc

Scroll down to the bottom and add the line: ./superscript

Save and exit!

All done!

JamesKay6 months ago

Thanks for the reply, although I'm sure it is a push button remote, the switch on the back is used to change between different channels that the sockets might be operating on. Here is some photos when the casing and the silicone is put back in place.

Ben Finio (author)  JamesKay6 months ago

Whoops. Look like I couldn't have been more wrong then. Someone with a better EE background can probably recognize this easily and give you a better answer. My assumption is that the 8 buttons on the front line up with these 8 pads on the circuit board (see picture below). Can you post a picture of the back side of the top half of the remote case, so we can see what the backs of the buttons look like? I'm guessing they press against the board, somehow changing the resistance (or maybe capacitance) of those traces, which is what gets measured...but I could be totally wrong (again).

If you don't get a good answer here, maybe head over to the Tech forum and ask there?


Here is a picture of behind the buttons.

Ben Finio (author)  JamesKay6 months ago

Ok - so looks like it is just rubber pads that press directly against the circuit board. Again, I'm not the right person to ask but my best guess is that this changes the capacitance or resistance of the traces on the board, and this gets detected by the chip. If you have a multimeter, you could still just test what happens to the voltage at each pin on the chip when you push each button.

If you find answers elsewhere please let me know how it works, I'd be curious to know.

I'll try that thanks :) then if I can't figure it out I'll post in the forums

JamesKay6 months ago

My remote looks like this, could anybody help me to try and figure out how this would work?, Thanks

Ben Finio (author)  JamesKay6 months ago

Ok - so it looks like you have a toggle switch instead of a pushbutton switch. Can't say 100% from the picture but it is probably something like this: It has three pins - my guess would be that the two outer pins are connected to HIGH and LOW (whatever those voltages happen to be for your remote), and the middle pin toggles between the two depending on the position of the switch. The middle pin of that switch is probably connected to one of the pins on the chip (the black rectangle on the back of the board) - you can figure out which one either by looking at the circuit traces, or using a multimeter. I give more details about that here. Can't tell you for sure which one it is just by looking at the pictures, I would need to be holding the remote in my hand.

So, you need to figure that out, and then follow my procedure as usual. The only other difference will be the code - you will need the GPIO pin to stay high (or low) when you want the lights on (or off), since the remote has a slide switch and not a pushbutton switch. If that doesn't make sense or you need help editing the code, just let me know.

vvjunk6 months ago
I think the relay and mosfets are an overkill. I think a 4 channel optocoupler ic can replace all those relays and mosfets. Here is a link to optocoupler: -V
n8icus vvjunk6 months ago
I'm pretty new to circuit design, but I think I understand how the optocoupler works. Could you elaborate a little on how you would replace the 6 relays with the optocoupler.
vvjunk n8icus6 months ago

Here is the circuit. You totally need 6 channels. You can get two 4 channel optocouplers.

Here is another link to optocoupler


pi to remote.jpg
vvjunk vvjunk6 months ago

Actually in this circuit, we are not isolating the pi from the remote. Since the remote pins need 5v and 5v is not available on the remote (only 12v is available), author is taking 5v from Pi. Since we are not isolating, you can as well use an NPN transistor array or individual transistors.

Ben Finio (author)  vvjunk6 months ago
That link gave me an error but I just searched "optocoupler" on Jameco and think I found what you mean.

Honestly I've never used an optocoupler before, so this is news to me, but if you're right, that would make the circuit much simpler (and cheaper).
nerys6 months ago
any way to simplify this? I don't want to say "pi" first and I don't want it talking back to me. I want to make it super "star trek" simple. I want to come into the room and simply say "lights" and have the lights go on. say "lights" again have them go off. IE simple voice keyword toggle.

To combine what Ben Finio and chrwei say, you need to create a script and then change the voicecommand config file.

You need to change the voicecommand config file to have the following:

This will turn off the keyword and the response (i.e. it will never call tts because it is in quiet mode). Then you just need to create a sh file in /usr/bin/ or /usr/local/bin named (make sure to chmod +x it to make it executable) that sets a variable in memory with /dev/shm/ (can't use an environmental variable in this case) and then flicks the lights appropriately. Your script might look like this:


state=`cat /dev/shm/lightstatus`
if [ $state == "ON" ] ; then
gpio write 1 1 && sleep 1 && gpio write 1 0
echo "OFF" > /dev/shm/lightstatus
gpio -g write 0 1 && sleep 1 && gpio -g write 0 0
echo "ON" > /dev/shm/lightstatus

Ben Finio (author)  StevenHickson6 months ago
Hi Steve - just wanted to say thanks for chiming in, and thanks for putting together Voice Command in the first place (obviously this project wouldn't be possible without it).
1-40 of 57Next »

Get More Out of Instructables

Already have an Account?


PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!