Preamp for voice recognition

First, I'm new to Arduino and electronics in general; my background is in programming, so help me out and give me a little extra explanation in your responses.

I'm trying to build a light and fan controller for my bedroom, which ideally will be expandable so that I can have it control other devices in the future. By control, I mean basic "ON" and "OFF" commands. I'm working on using an XBee Bluetooth board on a 2-channel relay shield connected to the Arduino to accept Bluetooth input for the basic "on" and "off" commands. All this should fit in the double gang wall box where the switches for my light and fan currently reside, but I'm going to be removing the switches and replacing them with a blank wall plate with foil touch sensors on the back to keep some of the original switch's functionality in the event the XBee chip fails on me. I've got all that fairly worked out in my head and all the parts are on the way, but if anybody sees anything in there that won't work, I'm all ears.

While I'm working on getting all my parts together and doing research, I'm thinking of new functions to add in, which is usually how these things go. I'd like to try to add some voice commands, like "fan on," "fan off," "light on," "light off," etc. and I've spent the better part the past few days looking into it and I've delved into a lot of Instructables articles on people doing similar things, but none of them seem to exactly fit into what I'm trying to do. I'd like to use the uSpeech library on GitHub, here, to have the Arduino process the input from this microphone. I'd like to mount the microphone in the double gang wall box with the rest of the components with a small hole drilled in the wall plate to let the sound pass through. The voice commands will be coming from between 2-15 feet from the microphone.

My first question is: is this feasible?

If so, will I need a preamp for the microphone to be able to accurately pick up my voice commands?

And, I've been researching preamp modules that easily interface with the Arduino, but aside from instructions on how to make your own, there doesn't seem to be much else. I wouldn't mind learning how to make my own if need be, but if anyone knows of a better alternative, I'm definitely open to suggestions.

Thanks in advance for the help.

There is no point in telling you the answer AS YOU ARE DEAD! I will recommend you for a Darwin award.

To any one else - Do not ever mess with the mains in this way.



Thanks for the courteous response. I think a little explanation of why I AM DEAD is in order.

I've tested the basic circuit of switching the fan and lights on and off with the Arduino connected to the relay shield and it works perfectly, so what am I missing?

The microphone board you're looking at should be fine, but I don't know what kind of signal you'll get from 15 feet.

I know some people have done voice recognition with the Arduino but I don't know anything about it or how well it works. It should help that you want a limited vocabulary.

Voice recognition can be tricky, even with a powerful processor/computer, and you can have signal-level and/or signal-to-noise ratio issues.

I'd start by trying to just turn on & off the Arduino's pin-13 LED with voice commands. If you can do that, you can turn on & off a relay. And, you can test the distance-sensitivity that way too.

As far as the home automation part of things, I think Xbee is compatible with Zigbee and [u]Z-wave[/u]. In any case, I'd recommend using one of the standard home automation protocols because you can integrate commercial switches/dimmers, outlets, and controllers, etc. Using commercial components for the AC switching side will save you from building the high voltage stuff. (You'll still have to wire-up the components to AC power.)

I think a little explanation of why I AM DEAD is in order.

I assume it's because you're new to electronics and you want to play around with lethal voltages. ;)

It's important that you isolate the high voltages from yourself and the Arduino either with a relay or optically.

Explain this to the insurance company:

I'm going to be removing the switches and replacing them with a blank wall plate with foil touch sensors on the back

:astonished: I hope you know an electrician that can look over your work before you "throw touch the switch".


Thanks for the help. I'll be doing some testing as soon as the microphone arrives.

I'm using this relay shield and it seems to handle the voltage nicely, at least with a test on/off program loaded onto the Arduino. I worked as an electrician for a few summers so I'm not a total stranger to lethal voltages and I have the insulated tools to work with it. Thanks for the tips on Z-wave and Zigbee, I may look into using something like that.


I'm going for something like this, which seems to do the job.

Actually, that instructable came to mind when I read your 1st post.
I’d like to see that get UL listed.

Personally I feel safer playing with a device like that when it has the option to quickly be unplugged or extinguished IF disaster strikes. In a nice externally mounted enclosure.
Stuffing hobby grade electronics in a wall box connected to the mains is a quick way to void your home owners insurance.

Voice recognition really requires a higher quality microphone. If you are open to using a better microphone we can address the preamp circuit. If not, there's really no point in talking about it.

Assuming that your not 6ft under from a clash with the mains, and the your not in jail (in the UK/Europe) doing anything more to the mains in your home than plugging something in is now illegal unless you are qualified. Then

Take a look at mic with amp and also look at the VR shield for the Arduino.


I won't tell if you don't...

The VR SHIELD is a very good choice.


I'm definitely interested in a better microphone if it will help. I'm open to recommendations of you have any in particular.


I'm still very much intact even after having been working with this thing all night and I'm in the US where it's still perfectly legal to electrocute yourself, so we're good there. And thanks for the VR Shield and mic recommendation. The VR shield looks perfect for what I need.

I'm definitely interested in a better microphone if it will help. I'm open to recommendations of you have any in particular.


A friend of mine (studio technician) once told me that the most important piece of equipment on any stage any where is the microphone(s) , because they determine the quality and quantity of information that goes to the recording studio system. What goes in, comes out. If it is a rich signal with lots of changing data points, that translates to audio sound detail. An electret mic, (the cheap condensor kind) just don't give the quality of a good microphone. I can't help you pick one but if you goodle "quality microphones " you'll find lots of choicing of varying cost.

Found this post of this guy doing almost exactly what I'm trying to do. The only difference is I'm shooting for voice control, too.

[RobB's] house has no light switches - Hackaday

Yup, sure is, have you read all the comments? Reiterates what has been said here. All safety/insurance issues aside. EasyVR is a great module for voice recognition as it can be extremely accurate in a close to perfect setup. But if the room is noisy it won't work well. EasyVR acts upon any sound loud enough to trigger it, then it tries to match the detected sound with the pre-recorded commands. If the background noise is loud enough it will get stuck in this loop. Listen to detected sound for a duration, compare to commands, act upon sound detected either detect error and resume listening or detect command and do desired function. This takes a few seconds, LEDs are commonly used to tell what is happening in the module, green - ready to accept commands, red - processing detected sound.

If you were to sit in a specific location in the room and have a mic in the "switch plate" directed at that location it will work better than an omnidirectional mic trying to pickup commands from any location in the room. Also if you program commands spoken a certain way i.e loud, soft, hard, fast, slow than you must speak the commands the same way for EasyVR to recognize them. Out of the box it only accepts programmed commands from one user. There is a list of commands that anyone can use but for custom commands you must purchase additional software. I have a few of these in projects. I've found that if I program the EasyVR in one room and move it to another it doesn't work very well. Best to program commands in the room that you want to use it in and at the distance from the EasyVR that will be most common when it is listening for commands. Programming commands at a distance from the mic of 12 inches and expecting it to recognize commands at 10 feet will be a problem and vise versa. Not saying it won't work at all, just that the rate of detected errors in recognizing commands will be much higher.