Instructables

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
Cost

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

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

Picture of Build the Circuit
breadboard-diagram-3.JPG
breadboard-diagram-4.JPG
breadboard-diagram-5.JPG
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.
1-40 of 57Next »
vikas0014 days ago

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

Ben Finio (author)  vikas0014 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)  vikas0013 days ago

In the configuration file there should be a line something like

!keyword==pi

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

See Steven Hickson's website for the full documentation:

http://stevenhickson.blogspot.com/2013/06/voice-command-v30-for-raspberry-pi.html

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.

http://www.reddit.com/r/raspberry_pi/comments/1xh36g/not_only_will_we_have_opensource_software_and/

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: http://www.pololu.com/product/2592

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.

1010722_713220832055973_763489535_n.jpg1525540_713220812055975_1743497023_n.jpg
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?

buttons.jpg

Here is a picture of behind the buttons.

1560549_713305325380857_323901794_n.jpg
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

1510814_712724078772315_1344683086_n.jpg1511179_712724048772318_751061554_n.jpg
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: https://www.sparkfun.com/products/9609. 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: http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_878286_-1 -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

http://www.newark.com/avago-technologies/acpl-847-...

-V

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.

Suggestions?
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:
!quiet==1
!verify==0
lights==flick_lights.sh
light==flick_lights.sh

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 flick_lights.sh (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:

#!/bin/bash

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

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 »
Pro

Get More Out of Instructables

Already have an Account?

close

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!