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 77Next »
vikas0013 days ago

I am having trouble I have build everything and also edited the file with the code. But when I am putting the command of gpio write 0 1 it says not found and I have checked all my wires 5 times. Please help

Ben Finio (author)  vikas0013 days ago

Can you type the EXACT error message that you get? The GPIO pins can be set high or low even if there is nothing attached to them, so I doubt this is a wiring issue, it is probably a software issue. I wrote this Instructable 8 months ago so I cannot promise that nothing has changed with either the WiringPi or VoiceCommand software, that might make this out of date.

I have set all the wires exact showen in the guide image and when I type in the terminal gpio write 0 1
I get the message command not found and I dont here the click sound of relay
Ben Finio (author)  vikas0012 days ago

First you need to type

gpio mode 0 out

as described in Step 8, to initialize the GPIO pin. Then you type

gpio write 0 1

Did you do that?

I did typed gpio mode 0 out and it is showing me this
-bash: gpio command not found
vikas00 vikas0011 days ago
I even tried typing sudo gpio mode 0 out but no luck give me the same error of command not found
Ben Finio (author)  vikas0011 days ago

Did you install WiringPi as described in Step 5? If you are getting "command not found", my only guess is that WiringPi is not properly installed.

I reinstalled wiringPi the code is working now but I dont here realay clicking sound. I have seen in the instructions image its all same but I have noticed that, the pic you have put with the diagram has different wiring. I can follow the pic but I am un sure which wire is going in which spot which is hidden behind the relay so can u put the other side pic too so I can see the pic and follow it.
Ben Finio (author)  vikas0011 days ago

Unfortunately I actually disassembled this project a while ago so can't take new pictures. If you tell me exactly which wires you think are wrong in the diagrams (refer to the color, give breadboard row/column info, be as specific as possible) I can check to see if I made an error.

I have set all the wires according to the digram but its not working.
Ben Finio (author)  vikas0010 days ago

Hmm. As far as I can tell from the photos your wiring looks right. This is difficult to help solve over the internet, but next I would try troubleshooting individual things to try isolating the problem:

1. Make sure your Raspberry Pi's GPIO pins work. If you have LEDs, you can just use your code to drive LEDs instead of the same circuit. If you have a multimeter, you can measure the output voltage of each pin.

2. Make sure the relays work by applying 5V directly across the coil from the power and ground buses, instead of using the Pi's GPIO pins and the MOSFET. For example, for the first relay - remove the MOSFET, then use a jumper wire to connect hole J7 to the ground bus. This should apply 5V directly across the coil (since hole A7 is connected to +5V) and you should hear a click.

3. For the MOSFETs - did you order the exact part I recommended from SparkFun, or something else?

I ordered exact parts and same model of remote to make this.
Ben Finio (author)  vikas0010 days ago

Ok. Please try the first two troubleshooting steps I listed then.

I tested it and found out my all relays are not working.
Ben Finio (author)  vikas003 days ago

If you're 100% sure you connected everything correctly and the relays are not working, I'd contact the supplier (SparkFun?) for a refund and see if you can get new parts. But, I would double and triple check that you are properly applying 5V across the relay coil (the two pins that are directly across from each other, not the three pins that sort of form a triangle - look at the relay's datasheet if that helps) before you tell them that they're broken.

in digram the remote ground is down near sixth relay but in real pic it is near the first relay.
Ben Finio (author)  vikas0011 days ago

Ah, OK - that shouldn't matter because the ground buses run the entire length of the breadboard (the "buses" are the two long strips on each side, one with a red line and one with a black line, for power and ground respectively). You should be able to plug a wire anywhere into the bus and it won't make a difference. However, I found out recently that some of these breadboards have the buses broken into halves, somewhere around row 30. This could be the case with your breadboard. If you have extra jumper wires, try using them to connect the "top half" of your breadboard's ground bus (somewhere in rows 1-30) to the "bottom half" (rows 31-60), and see if that solves your problem.

Also, if you have a multimeter with a "continuity test" mode, you could use that to confirm whether the entire ground bus is connected, or if it is broken in half.

rp gpio pins
you were right that bus was split in every 30 places and I have connected them but still no luck to make it work. I have tested there is power in breadboard. I have attached some pic of my work in different angles so u can see the wiring.
vikas001 month ago

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

Ben Finio (author)  vikas001 month 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)  vikas001 month 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...

phlau744 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)  phlau744 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".

phlau744 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.
phlau744 months ago

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

Ben Finio (author)  phlau744 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)  phlau744 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.

phlau744 months ago

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

mikerbob7 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)  mikerbob7 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)  mikerbob7 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)  mikerbob6 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 Finio6 months ago

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

1-40 of 77Next »