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 86Next »

would this be strong enough for a power strip?

Ben Finio (author)  tracy.nguyen.3976 days ago

It should be fine. The wireless outlets are designed to control anything you would normally plug into an outlet. None of the high-voltage AC is actually going through the Raspberry Pi circuit itself. If you are plugging a TON of stuff into a power strip and you are really concerned about the rating of the wireless adapters, you'd have to look up the specs (I don't see them on the product page):

But I'm guessing at that point you'd trip the power strip instead.

TimL620 days ago

I created something similar and wrote a detailed blog post. Check it out:

pk.jimoc5 months ago

Your project is awsome!!

I have a question this project works without computer?


Ben Finio (author)  pk.jimoc5 months ago

I'm not quite sure what you're asking. The Raspberry Pi is a type of tiny computer, and this project requires a Raspberry Pi. You do not need a "regular" computer (PC or Mac) to do the project though. Is that what you meant?

puneethbr5 months ago
In first place, I would like to congratulate you for such an excellent instructable!! :)

I'm thinking to make a wired version of this instead of using remote. So I am thinking to use external relays connected to AC power and lights. Then control the external relays by the existing relays. Would that work?

Also please let me know which mic can I use as a substitute to your webcam. I need to design the project in less cost.

Note: I'm a beginner. I have not used Raspberry pi till now. This would be my first project.
Ben Finio (author)  puneethbr5 months ago

Thanks! To answer your questions - there are products that make it very easy to control an outlet with a hardwired connection to a microcontroller, no relays required, like this:

The problem with that one is that it's very expensive - $30 (USD) to control just one outlet. I'm sure SparkFun's shipping to India isn't cheap either, so I'd recommend looking for something similar from an Indian supplier (I'm not really familiar with electronics vendors over there).

The good thing about it is that it safely contains the high voltage wiring so you do not have to touch it at all, beyond just plugging in an appliance like you would normally. You just handle the logic-level wiring to your microcontroller like you would with any other Arduino or Raspberry Pi project, which is perfectly safe. If you are a beginner, you should NOT wire relays up to high-voltage AC yourself. It is dangerous and can kill you or burn your house down if you do not know what you are doing.

By saying I'm new to this means I'm new to programming controllers. I'm a Telecom Engineer. I have knowledge about electrical and electronic circuits. :)

Very thanks for the reply. :)

Glad to see your enthusiasm!!
Ben Finio (author)  puneethbr5 months ago

Ah, OK. Sometimes complete beginners think they can dive right into high-voltage wiring and of course that is not safe.

I forgot to mention - most USB webcams or mics should be compatible with the Raspberry Pi. My webcam was just plug-and-play, I didn't have to install any drivers. If you are going to buy something, I would just do a quick Google search first to see if you can find anything about compatibility with the Raspberry Pi, or if you need to install certain Linux drivers to get it to work.

Good luck!

vikas006 months 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)  vikas006 months 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.

vikas00 Ben Finio6 months ago
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)  vikas006 months 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?

vikas00 Ben Finio6 months ago
I did typed gpio mode 0 out and it is showing me this
-bash: gpio command not found
vikas00 vikas006 months 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)  vikas006 months 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.

vikas00 Ben Finio6 months ago
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)  vikas006 months 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.

vikas00 Ben Finio6 months ago
I have set all the wires according to the digram but its not working.
Ben Finio (author)  vikas006 months 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?

vikas00 Ben Finio6 months ago
I ordered exact parts and same model of remote to make this.
Ben Finio (author)  vikas006 months ago

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

vikas00 Ben Finio6 months ago
I tested it and found out my all relays are not working.
Ben Finio (author)  vikas006 months 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.

vikas00 Ben Finio6 months ago
in digram the remote ground is down near sixth relay but in real pic it is near the first relay.
Ben Finio (author)  vikas006 months 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.

vikas00 Ben Finio6 months ago
vikas00 Ben Finio6 months ago
rp gpio pins
vikas00 Ben Finio6 months ago
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.
vikas007 months ago

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

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

vikas00 Ben Finio7 months ago

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)  vikas007 months 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:

vikas00 Ben Finio7 months ago

Thanks you were really helpful...

vikas00 Ben Finio7 months ago

Thanks you were really helpful...

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

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

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

Ben Finio (author)  phlau7410 months ago

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

1-40 of 86Next »