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





Introduction: Wireless Multi-Channel Voice-Controlled Electrical Outlets With Raspberry Pi

About: For my day job I write K-12 STEM projects for www.sciencebuddies.org. In my spare time I write Instructables.
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.

Step 1: Open the Remote and Remove the Circuit Board

The first thing you'll need to do is open the plastic case of the remote to expose the circuit board.

1. Remove the battery cover and take the battery out for now.
2. Use a small Phillips head screwdriver to remove the single screw holding the front and back halves of the plastic case together.
3. Use needle nose pliers to bend off the keychain ring.

This exposes the underside of the circuit board, which you can remove from the case entirely to get a look at the top half. However, I find it easier to work with the circuit board attached to the front half of the case. This way, you can easily push the buttons when you're testing the circuit (next step). The battery also tends to stay in better when it's in the case. There was an unoccupied hole in the case that lined up with a hole in the circuit board - I used the small screw to attach the circuit board to the front half of the case (see the last two pictures above).

Step 2: Reverse-Engineer the Remote

This step will assume you already have basic knowledge of how a single-channel remote works. You can find a detailed explanation of that in my previous Instructable.

The basic idea here is the same - but instead of two buttons controlling a single channel (one ON and one OFF), you have six buttons controlling three channels (three ON and three OFF). Each of these buttons is connected to a pin on a chip on the circuit board (the black rectangle). Normally, these pins sit at 0V (a logical LOW). When the respective button is pressed, the pin goes up to 5V (a logical HIGH). Your ultimate goal is to "trick" the remote into thinking buttons are being pressed by sending a 5V signal from a circuit controlled by the Raspberry Pi (more on that later). In order to do that, you need to figure out which pins on the chip are connected to the pushbuttons, so you can solder jumper wires to them.

There are two complementary ways to do this. One is to just look at the traces on the back of the circuit board, and figure out which ones connect the pushbuttons to pins on the chip. You can also test this with a multimeter by testing to see which pin changes from 0V to 5V when you push each button (make sure the battery is in, or that won't work!). The latter can be a little difficult to do with just two hands, and is definitely easier if you have alligator clip attachments for your multimeter.

If you're using the exact same remote I linked to from Amazon, you should be able to follow my diagrams exactly. If not, you'll need to do some tinkering on your own to figure out which pins to solder to in the next step.

Step 3: Solder Jumper Wires to the Remote

Note: I opted for economy shipping from SparkFun for my multi-colored jumper wire. The good news is I got free shipping. The bad news is I only had red and black jumper wire available before that. The connections in this project are a little easier to keep track of if you have 8 different colors available. So, for the circuit diagrams (expertly drawn in Powerpoint), I'll use the following convention:

+5V: red
GND: black
ON1: blue
OFF1: gray
ON2: yellow
OFF2: brown
ON3: green
OFF3: white

In the photos of my actual build, you will only see red and black wire. Of course you can use whatever colors you prefer - my intent is that the color-coding scheme in the diagrams will be easier to follow, and I apologize that it doesn't match up to my photos exactly (it was this, or miss the deadline for the Hardware Hacking contest).

Anyway - now you need to solder jumper wires to the six pins identified in the previous step, plus the negative terminal of the battery connection (this will make sure your whole circuit has a common ground later). Seven connections total, as shown in the pictures above (a "fake" photo with the color-coded wires drawn in, as well as a photo of the real thing).

Optionally, if you'd like to protect the circuit board a little better, you can drill holes in the back of the remote's original case to feed the jumper wires through. Just make sure you can keep track of which wire is which. I used a label maker since I didn't have properly color-coded wire.

Step 4: Build the Circuit

Assemble the circuit on the breadboard. If you're good at following breadboard diagrams, you can just go ahead and use the first image above. If that seems a little overwhelming, try doing it one step at a time (following the pictures in order):

1. Insert the relays and MOSFETS (six of each). Important - I didn't realize until after I made all of these diagrams that the packaging on the relays is slightly too bulky for them to occupy adjacent breadboard rows, as pictured here. You will actually need one blank row in between each relay, adding five rows of total space to the build (which shouldn't be an issue if you're already using a big 60+ row breadboard).
2. Use jumper wires to make all the +5V (red) and ground (black) connections on the breadboard.
3. Connect the breadboard to the Raspberry Pi's +5V and GND pins, and to the negative battery terminal (-) on the remote. Important: do NOT connect the positive power rail on the breadboard to the (+) battery terminal on the remote. The remote battery is 12 volts, so if you short that to your Raspberry Pi's 5V pin, bad things will happen.
4. Connect the Raspberry Pi's GPIO pins (17, 18, 22, 23, 24, and 25) to the gates (left-most pin when facing the side with the writing) of the respective MOSFETs as shown. See the color-coded table above, which matches the wire colors I used in the breadboard diagrams, for help keeping track of everything. See this page for more information about the GPIO pins and the numbering scheme (which can be confusing if you're new to Raspberry Pi, especially if you're used to Arduino).
5. Connect the wires you previously soldered onto the remote to the breadboard. I use the same color-coding convention for these wires in the diagrams above.

For an explanation of how the circuit works, see this step of my previous Instructable.

Step 5: Install WiringPi

WiringPi is a very convenient way to control the Raspberry Pi's GPIO pins, especially if you are used to Arduino. It was created by Gordon Henderson and you can find download and installation instructions here. Follow the directions on his site to download and install WiringPi on your Raspberry Pi (using the command line in a terminal).

Note: I originally found out about WiringPi through this tutorial on controlling a single LED with the GPIO pins, hosted on projects.drogon.net. It links to these download and installation instructions. WiringPi has since been moved to its own site, wiringpi.com. According to this post I believe wiringpi.com will contain the most recent updates - so in the future make sure you follow download and installation instructions from wiringpi.com and not projects.drogon.net, in case anything changes (as of December 2013, the instructions are still the same).

Step 6: Install Voice Command

In short, Voice Command is a C++ program included as part of a package called PiAUISuite (Pi Alternative User Interface Suite) written by Steven Hickson. It uses a microphone connected to your Pi to record audio, then connects to a Google speech-to-text service to convert the sounds to text that can be used to execute commands. Steve has some very helpful and extensive tutorials and YouTube videos that I highly recommend checking out before you dive into this part, and he already has it set up to do some neat things like open and play videos, Google stuff, or connect to Wolfram Alpha to try and answer questions. So, all of the credit for this goes entirely to Steve - I just took his setup and put a couple lines in the config file to control GPIO pins (using WiringPi, and of course the credit for that goes to Gordon Henderson).

I will provide all of the links that I found helpful, but it looks like he is still actively updating the project - so be sure to check his blog for updates and instructions to download and install the latest version. If you notice an update in the future, please leave a comment below with a new link.
So, as of December 2013, follow the directions in that last link to download and install PiAUISuite and Voice Command. In the next step you'll edit the config file to include voice commands for the GPIO pins.

Step 7: Edit the Voice Command Config File

In a terminal, open the Voice Command config file by typing the command

voicecommand -e

Add the following lines to the config file*:

light one on==tts "Yes, sir." && gpio write 0 1 && sleep 1 && gpio write 0 0
light one off==tts "Yes, sir." && gpio write 1 1 && sleep 1 && gpio write 1 0
light two on==tts "Yes, sir." && gpio write 3 1 && sleep 1 && gpio write 3 0
light two off==tts "Yes, sir." && gpio write 4 1 && sleep 1 && gpio write 4 0
light three on==tts "Yes, sir." && gpio write 5 1 && sleep 1 && gpio write 5 0
light three off==tts "Yes, sir." && gpio write 6 1 && sleep 1 && gpio write 6 0

You can probably guess what each line of this code does. When the phrase before the double equals sign is detected (e.g. "light one on") the code after the double equals sign executes. You can change each phrase to whatever suits your needs (e.g. "TV on", "desk light on" etc). tts is "text to speech" and will make your personal robot assistant respond appropriately (Steve's default is "Yes sir", I prefer something a little more ego-maniacal like "At your command, master."). The rest is the digital equivalent of pushing and releasing a button on the remote:

  • gpio write 0 1: set GPIO pin 17 to HIGH (ultimately sending a 5V signal to the remote, equivalent to pushing the button). See note below about pin numbering convention.
  • sleep 1: hold the pin HIGH for one second (equivalent of holding the button down)
  • gpio write 0 0: set the pin back to LOW (equivalent of releasing the button)
Be careful to get the syntax right -primarily no spaces immediately before or after the double equals signs.

Follow the on-screen directions to save the config file once you've added this code (ctrl+x to exit then y to save).

*Apparently WiringPi is compatible with two different numbering conventions - the Raspberry Pi GPIO pin numbers (17, 18 etc) or its own system that starts numbering the pins at 0. So, the following block of code will also work. You can use whatever convention you prefer.

light one on==tts "Yes, sir." && gpio -g write 17 1 && sleep 1 && gpio -g write 17 0
light one off==tts "Yes, sir." && gpio -g write 18 1 && sleep 1 && gpio -g write 18 0
light two on==tts "Yes, sir." && gpio -g write 22 1 && sleep 1 && gpio -g write 22 0
light two off==tts "Yes, sir." && gpio -g write 23 1 && sleep 1 && gpio -g write 23 0
light three on==tts "Yes, sir." && gpio -g write 24 1 && sleep 1 && gpio -g write 24 0
light three off==tts "Yes, sir." && gpio -g write 25 1 && sleep 1 && gpio -g write 25 0

I skipped using WiringPi pin 2 so I could stick with "pairs" of pins that were across from each other on the header for on/off (for the first two channels, at least). Somewhat arbitrary, and you can use different pins if you'd like. You can read about the reasoning behind the WiringPi convention here.

Step 8: Test It!

Plug in three different appliances to your wireless outlet adapters. Make sure you are in range of the remote (check the original packaging or instruction manual).

Before you start, you need to initialize the GPIO pins as outputs. At the command prompt in a terminal, enter

gpio mode 0 out
gpio mode 1 out
gpio mode 3 out
gpio mode 4 out
gpio mode 5 out
gpio mode 6 out

Next, run Voice Command in continuous mode

voicecommand -c

and start issuing commands! Make sure your spoken commands exactly match the ones you put in the config file. Not working as expected? Head over to the next step for some troubleshooting tips.

Challenge to Linux gurus (I'm a complete amateur): put the GPIO initializations and voicecommand -c into a shell script so you can run a single command to initialize everything. Don't hesitate to leave a helpful comment.


Step 9: Troubleshooting

Something not working? Here are some troubleshooting steps you can try, roughly in order:

  • Make sure your wireless remote and outlet adapters are working on their own, independent of the Raspberry Pi. Completely unplug the remote from your Raspberry Pi circuit, make sure the battery is in, and make sure you can turn lights on and off just by pushing buttons on the remote. If that works, at least you know your remote isn't broken.
  • Skip Voice Command and try turning your GPIO pins on and off directly from the command prompt (e.g. just type gpio write 0 1, then remember to type gpio write 0 0 to set the pin LOW again). You should hear a very audible "click" when the relays switch positions. Try this individually for each of the six GPIO pins and corresponding relays.
  • If you don't hear the relays click at all, double check your breadboard wiring relative to the circuit diagrams. One misplaced wire can mess everything up. If you have a multimeter available, this would be a great time to use it - make sure you are actually getting 3.3V at the outputs of the GPIO pins, and 5V at the outputs of the relays.
  • If you're having trouble with Voice Command, there are several things you can try, such as adjusting the threshold in the config file, or the amount of time the program will listen for commands (e.g. it might cut you off if your command phrases are too long).  The speech recognition isn't perfect, so try enunciating your speech very clearly, or new command phrases that might be easier to recognize. For example, sometimes my program would record "lights off" when I said "light off", and the command wouldn't work.
Raspberry Pi Contest

Second Prize in the
Raspberry Pi Contest

9 People Made This Project!


  • Clocks Contest

    Clocks Contest
  • Oil Contest

    Oil Contest
  • Water Contest

    Water Contest

161 Discussions

Hi - you'd have to contact the author of PiAUISuite for help with errors when installing it. I am not the author of that software so unfortunately can't really help with debugging it. Note that I wrote the directions for this project several years ago so they may be out of date if he has updated his software. There are a lot of new projects out there for doing voice control on the Pi, for example using Google Home. Sorry I can't be of more help!

Thanks for the reply. I haven't been able to get a hold of Steven Hickson who wrote the program. Would you still be able to use the voice command software from a different source to control the GPIO pins? That is the only problem I'm running into with that.

Hi - as I understand it, in general there are two different systems you need to connect here:

- something that converts voice commands to text and allows you to run Linux commands. There are various ways to do that like PiAUISuite and various new commercial solutions like Google Home, Amazon Alexa etc, and people have started hacking the latter to get them to work with Raspberry Pis: https://aiyprojects.withgoogle.com/voice#project-... Do some googling and you will probably find more examples.

- a way to control the GPIO pins with a programming language of your choice. In this project I used WiringPi but you can also do it in Python, etc.

So basically, there are multiple ways to interpret voice commands, and multiple ways to control the GPIO pins - there should be multiple combinations that will work.


I'm having some troubles getting the remote to send signals to the receivers. As far as I can tell, I have everything hooked up on the breadboard correctly, I can clearly hear the click of the relays when I send signals through the console of the raspberry pi. The light on the remote also turns on and off, however, no signal is sent to any of the receivers. When pressing the buttons manually on the remote, I get the exact same result, the light turns on and off but no signal is sent.

The remote still works, when I disconnect it from the raspberry pi the buttons all work as intended, but as soon as I plug it back in the remote stops sending signals. This leads me to believe that I have not created a short with my amateur soldering job. I should mention the the negative wire (the one connected closest to the battery) seems to have no effect on any of my test regardless of if it was plugged in or not.

I'm lost as to what to try next, any ideas?

Thanks in advance,


5 replies

Hi Conrad - the next step I'd recommend is getting a multimeter and debugging what's going on by measuring voltages at different points in the circuit. If you can hear the relays clicking then you know your GPIO pins are toggling on and off correctly, but something might be wrong with the connections to the remote. I have a more detailed breakdown of this process in an earlier project if you haven't seen that already:


and if you aren't familiar with using a multimeter, there are TONS of instructables on that topic, along with one here that I wrote for work (shameless plug):



Thanks for the quick response! I've done as you asked, here are my findings.

The pins I have the wires connected to seem to be the correct pins. When the button is not pressed, 12 volts come through on one side, and 0 on the other. When the button is pressed, 4.2 volts on both sides (exactly as your diagram in the Wireless Christmas lights instructibles shows). I've tested every pin on all 6 buttons, and concluded that I am hooked up to the correct places.

Here are some interesting things I found while debugging...

The breadboard outputs 5 volts when I activate the pins accordingly, the button on the transmitter however only passes through 4.2 volts. Does the 0.8 volt difference make any difference as to if the transmitter would work or not? A reminder that the light on the transmitter is turning on when activated through the pi.

When the transmitter is fully plugged into the breadboard (both the wires to the buttons and the negative battery wire), pressing the button on the transmitter no longer gives the 4.2 volts it did before, instead it gives 0.01 volts. When I disconnect the negative side from the breadboard, the button works as if it was not connected at all, but trying to "press" the button from the pi still does not work.

Any ideas as to what could be going on? Please let me know if you would like pictures/diagrams, and I'll do the best I can!

Thanks again!


Hi Conrad - if I understand your description correctly, there might be a short circuit somewhere involving the ground wire that you connect to the breadboard. The first thing to do would be to check your soldering job for the ground wire. If your multimeter has a continuity test function you can use that to test different contact points to see if they are connected (and if you find any that SHOULDN'T be connected, that's a short). Another approach would be to remove some components from the breadboard and test the relays one at a time. That might help you isolate the problem.

Pictures might help but unfortunately you've caught me at a bad time - I'm moving this weekend and won't be online for most of next week. So if you take some pictures of your circuit I'll be able to take a look but probably not for a couple weeks.


I know its been awhile since you've heard from me, but I've got some good news! My circuit boards are working! Not sure what the problem was, but after boxing them up and shaking them around (literally I moved to college), they seem to be working.

I've got just one more problem, this one with the PiAUISuite/voice command. The voice command for "Turn the lamp on" is recognized, but instead of running the "gpio write 17 1 && sleep 1 && gpio write 17 0", it just prints out that string.

Do you know how to get it to actually run the command or should I go to the creator of PiAUISuite?

Thanks in advance (again),


Hi Conrad -

This project is so old (by software standards) that unfortunately it will be hard for me to debug anything like that. My first guess is that maybe you don't have WiringPi properly installed (see step 5) - but with 3 years of changes to Raspbian, WiringPi, and VoiceCommand, who knows what change to any of those three things could prevent my original instructions from working as written. I haven't really used them since I wrote this.

If your goal is to get some sort of voice-controlled home automation going, then there are probably a lot of new options out there with the burgeoning popularity of home assistants like Google Voice and Amazon Alexa. Google released something specifically for the RPi:


and I have seen various posts about people hacking the Alexa on sites like hackaday.com.

So, I'd say the *hardware* part of this project is still relevant (wiring up an RPi's GPIO pins to a wireless outlet remote), but there are probably newer, better, and faster ways to do the software (with better support) that you can look into.

I am currently working on this project and uptil now it is working great but instead of remote i wanto use xbee to send signal wirelessly can anybody help me?

1 reply

Hi - unfortunately I don't have any experience using xbee. You might be better off asking in the tech forum


or maybe a dedicated Arduino forum somewhere.

I am currently working on this for a school project. I'm wondering, since the raspberry pi doesn't have built in speakers, did you have to add some?

1 reply

Correct. The Raspberry Pi has two ways to output audio - HDMI (if you connect it to an HDMI monitor or TV with built-in speakers) and the 3.5mm "headphone" jack where you can plug in external speakers.


2 years ago

Your project is very impressive and I would like to learn to make it too. But Raspberry Pi 1 model B that you are using is not longer in my country. If I use Raspberry Pi 2 Model B, whether the setting circuit wiring on a breadboard system you describe previously changed or not? Thank you for your explanation

5 replies

Hi - luckily all the newer model Raspberry Pis are backwards-compatible with the original GPIO pin layout. The original model only had 24 pins; the newer ones have 40 but the first 24 are still in the same order, so nothing changes.

what if the wireless adapter socket not just plugged in the lights but in a fan and TV. Fan and TV can be turned on with a voice like a lamp or not? If not, what settings should be added so that it happens?

Any appliance (lamp, TV, fan, etc) that plugs into the wireless socket will work. I just used lights as an example.

Okay. Voice command software does not explain her fit or not with Raspberry Pi 2 models B. What do you think, I should buy Raspberry Pi 1 model B+ or no problem to buy Raspberry Pi 2 Model B? Your suggestions are very helpful. Thank you very much for answering all my questions :)

Be careful not to get the physical model of the Raspberry Pi (B+, 2, etc.) mixed up with the version of the operating system (Raspbian). Raspbian is designed to be largely backwards-compatible so the newest version will always run on older Raspberry Pis. You would have to contact the author of VoiceCommand to find out if his software is compatible with the latest version of Raspbian (forget his website but it's listed in my Instructable somewhere). If not, you could try to find a place where you can download older versions that are compatible.


2 years ago

how can I connect wireless microphone with Raspberry pi ?.