Instructables

Voice Activated Arduino (Bluetooth + Android)

Featured
Picture of Voice Activated Arduino (Bluetooth + Android)

Control your Arduino with voice commands using an Android smartphone! Before we make a voice activated home automation system, we must first learn the basic principles of the experiment. This guide will let you command the Arduino using your Android smartphone and a HC-05 Bluetooth module.

The designer of the app did not include a sample code. I looked for alternatives in Google's PlayStore but none was as good as the app that I've found. Luckily, I was able to figure it out although it took me a while to program it. Sorry IOS users, this app isn't available in Apple's app store :/

How Does It Work?
Have you ever encountered Android's speech recognition? Yes android has one and you can use it to control your Arduino, via Bluetooth. The App works by pressing the mic button, then the it will wait for you to say a command. The app will then display the word's that you've stated and will send data strings for the Arduino to process.

Home Automation System (on July 4, 2014):
A month from now/ I'll be releasing a highly sophisticated home automation + security system. It's my biggest project ever! Our current agenda is to program a better smartphone app that work's like Siri (talks back) and sends strings (data types) to the Arduino via bluetooth. If you want to take a sneak peek of the project and it's concept, kindly skip to the last step. The prototype that I'm working on now is composed of a network of wireless switch boxes that connects to a main control panel via WiFi/ Bluetooth.

Here's A Quick Video Demo:

 
Remove these adsRemove these ads by Signing Up

Step 1: Parts & Materials

Picture of Parts & Materials
DSC_0081.JPG
collagef.jpg
bluetooth-HC05-02.jpg
If your having trouble in finding them, I'm sure RadioShack has all of them. If you want to buy online try searching on Amazon or DealExtreme.

Thing that you'll need:
- 5 LED Indicators (the color of your choice)
- Arduino UNO (a clone works fine)
- HC-05 Serial Bluetooth Module
- Solderless Breadboard
- Jumper Cables

Step 2: Assemble The Mini Bluetooth Shield

Picture of Assemble The Mini Bluetooth Shield
DSC_0084.JPG
DSC_0085.JPG
DSC_0091.JPG
My JY-MCU (DX Bluetooth Module) is still installed on my robots, what I have right now is the bare HC-05 module.

As we all know, the HC-05 doesn't come with a PCB. Soldering wires, directly to the metal conductors, isn't a good idea since the conductors could chip off anytime. As a solution, you can cut a fraction of perf-board then mount the HC-05 on it. I mistakenly connected my LED indicator on a blank (N/A) pin so mine doesn't work.
___________________________________________
Too lazy to assemble a Bluetooth shield? DX.com has a ready made version (click here). I've used the DX Bluetooth module on my robots, it's tested and it's 100% ok! You can visit Bluetooth related projects (Bluetooth Sumobot and Bluetooth FPV Rover) as reference.

Step 3: Connect The Bluetooth Module

Picture of Connect The Bluetooth Module
FJP6DCTHKVKX3JW.png
DSC_0100.JPG
DSC_0098.JPG
Grab some jumper cables and power the Bluetooth module with 3.3 volts. Remember, the bare HC-05 run on 3.3v and not on 5v. On the other hand, the JY-MCU has a built in regulator, it can run on a 5v line.

Now connect the RX (pin #0) of the Arduino to the TX pin of the Bluetooth module and the TX (pin #1) of the Arduino to the RX pin of the Bluetooth module. (refer to the image above)

Step 4: Connect The LEDs

Picture of Connect The LEDs
DSC_0104.JPG
DSC_0106.JPG
Connect the positive leads of each LED on pins # 2,3,4,5,6 of the Arduino. The negative leads of each LED goes to the negative rail of the breadboard. The negative rail of the breadboard goes to the Arduino's ground.

Step 5: Programming The Arduino

Picture of Programming The Arduino
Understanding The App: 
Before you program the arduino, you must first learn how the app works. The app work by recognizing your voice command, it will then display the words that you've spoken then sending data/ strings to the arduino via bluetooth. What's a string? A string is like a word, you can make conditional statements out of it [ex: if (voice == "*computer on") {// turn Pin #2 on} ]. The "voice" is your string, "==" is your condition (means equal to), "*computer on" is your command and the code inside the curly-braces "{ }" are the codes to be executed once your string matches the command condition. 

What's the format of the string? How does it know when the next command kicks in? How does it differentiate a set of words from a new command? The app sends strings in this format *command#, the asterisk (*) indicates the start of a new command and the hash-tag (#) indicates the end of a command. I was able to remove the hash-tag (#) after each word in the conditional statement was not able to remove the asterisk (*). You'll need to start your command condition with an asterisk otherwise the sketch will not work. 

How Can I Change The Commands?
You can see that the "*TV on" is highlighted from the image above. If you want to change the command to ,humm let's say "open garage door", you can replace the "*TV on" with "*open garage door". Always remember to start the command with an asterisk.

//Coded By: Angelo Casimiro (4/27/14)
//Voice Activated Arduino (Bluetooth + Android)
//Feel free to modify it but remember to give credit

String voice;
int
led1 = 2, //Connect LED 1 To Pin #2
led2 = 3, //Connect LED 2 To Pin #3
led3 = 4, //Connect LED 3 To Pin #4
led4 = 5, //Connect LED 4 To Pin #5
led5 = 6; //Connect LED 5 To Pin #6
//--------------------------Call A Function-------------------------------// 
void allon(){
     digitalWrite(led1, HIGH);
     digitalWrite(led2, HIGH);
     digitalWrite(led3, HIGH);
     digitalWrite(led4, HIGH);
     digitalWrite(led5, HIGH);
}
void alloff(){
     digitalWrite(led1, LOW);
     digitalWrite(led2, LOW);
     digitalWrite(led3, LOW);
     digitalWrite(led4, LOW);
     digitalWrite(led5, LOW);
}
//-----------------------------------------------------------------------// 
void setup() {
  Serial.begin(9600);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(led5, OUTPUT);
}
//-----------------------------------------------------------------------// 
void loop() {
  while (Serial.available()){  //Check if there is an available byte to read
  delay(10); //Delay added to make thing stable
  char c = Serial.read(); //Conduct a serial read
  if (c == '#') {break;} //Exit the loop when the # is detected after the word
  voice += c; //Shorthand for voice = voice + c
  } 
  if (voice.length() > 0) {
    Serial.println(voice);
//-----------------------------------------------------------------------//   
  //----------Control Multiple Pins/ LEDs----------// 
       if(voice == "*all on") {allon();}  //Turn Off All Pins (Call Function)
  else if(voice == "*all off"){alloff();} //Turn On  All Pins (Call Function)
 
  //----------Turn On One-By-One----------//
  else if(voice == "*TV on") {digitalWrite(led1, HIGH);}
  else if(voice == "*fan on") {digitalWrite(led2, HIGH);}
  else if(voice == "*computer on") {digitalWrite(led3, HIGH);}
  else if(voice == "*bedroom lights on") {digitalWrite(led4, HIGH);}
  else if(voice == "*bathroom lights on") {digitalWrite(led5, HIGH);}
  //----------Turn Off One-By-One----------//
  else if(voice == "*TV off") {digitalWrite(led1, LOW);}
  else if(voice == "*fan off") {digitalWrite(led2, LOW);}
  else if(voice == "*computer off") {digitalWrite(led3, LOW);}
  else if(voice == "*bedroom lights off") {digitalWrite(led4, LOW);}
  else if(voice == "*bathroom lights off") {digitalWrite(led5, LOW);}
//-----------------------------------------------------------------------// 
voice="";}} //Reset the variable after initiating

Step 6: Learn To Use The App

Picture of Learn To Use The App
Download The Free App Here: Android Meets Robots : Voice 

5 Simple Steps:
1st.)  Download the app from Google PlayStore
2nd.) Tap on options menu then select "Connect Robot"
3rd.)  Click on your BT-Module (in my case it's the HC-05)
4th.)  Wait until it says Connected to BT-Module (HC-05)
5th.) Tap on the mic icon and state your command!

Here's A Quick Demo Video:

Step 7: Next Project: Highly-Sophisticated Home Automation (Network)

Picture of Next Project: Highly-Sophisticated Home Automation (Network)
Here's a drawing of what to expect on my next Arduino project!

Sorry for the terrible doodle :)
1-40 of 144Next »

hey i want to do this project and i have few doubts.

1.can i use any type of arduino?

2.does any android phone can be used in this project?

please reply soon...

anyone can answer my questions...

hi . i was do by follow your step . but not function . the hc05 connected with android . can you help me ? tq

Addition to my previous post.

I got it also working on an Arduino Nano.

Still not working on an Attiny85.

Anybody luck with a Digispark. I have one of these also.

Still a great app and I love to get my hands on the app-inventor code all be it only to translate the android app in Dutch and maybe fool around a bit with it.

Thanks

Luc

Hey guys,

I have this working on an Arduino. Great App. However I was wondering if anybody got this working on an Attiny85.

Changed the code to:

#include <SoftSerial.h> /* Allows Pin Change Interrupt Vector Sharing */
#include <TinyPinChange.h>

SoftSerial mySerial(3,4);

And I changed every referral from Serial to mySerial

Just no succes. I left out the Tinypinchange also no success.

Anybody ???

Another Question.

Could you post the appinventor code so I could change it myself.

Thanks

avengers22811 days ago

i made it

but i used easy vr shield instead of bluetooth shield

i used my own codes for easy vr

and thankz for giving the codes for arduino

and i also did some editting in arduino code

thankz man !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

☺☺☺☺

avengers22811 days ago

g

sydneyb13 days ago

It's good project. Thank you for sharing. i want to practise a project same yours.Can you share source code of android application. my e-mail: bragantine@gmail.com

acap12314 days ago

It's good project. Thank you for sharing. i want to practise a project same yours.Can you share source code of android application. my gmail:amirulacap92@gmail.com

Thank you so much

ayushi12329 days ago

this was of great help for my project! I made it n am very happy...bluetooth range is approximately 10m.

do you use DTMF decoder? i haven't understood yet how to decode voice to command,ex: *TV on,*fan on,*computer on... Writing code is difficult, isn’t it?

It's good project. Thank you for sharing. i want to practise a project same yours.Can you share source code of android application. my gmail:timlaibautroi090792@gmail.com

Thank you so much

nisarg1 month ago
The changed commands are not working , its not giving any output all the connections and program are fine what should i do?
janowh1 month ago

hi

is there away to modify these voice commands from the android app ??

and expand number of outputs ??

thanks

jdahl2 janowh1 month ago
You can't change the voice commands from the Android device. But you can change the voice commands in the code.
Your device translates the voice commands and sends them as text to the arduino. In the code you can see that the Arduino use these text commands to trigger pins.

If you look at the picture you can see that I changed the text commands to something more suitable for my project.
temp_-831135386.jpg
janowh jdahl21 month ago

ok thanks for the advice >> I will try it

jdahl21 month ago
Nice and easy guide! Thank you
temp_-2007931693.jpg
BhaveshTechz7 months ago

Hi Angelo, Can i use "Wireless 4 Pin Bluetooth RF Tansciever Module RS232" in place of HC-05 bluetooth module. The link of the product is this http://www.banggood.com/Wholesale-New-Wireless-Serial-4-Pin-Bluetooth-RF-Transceiver-Module-RS232-With-Backplane-p-43441.html

bluetooth module front.jpgbluetooth module back.jpg
ASCAS (author)  BhaveshTechz2 months ago

Yes, that should work.

ASCAS (author)  BhaveshTechz7 months ago

Yes, that should work.

caferd3 months ago

Hi , I will do the project. You use the Android phone but i have got a i phone .Can i use the i phone ? how can i control it ?

ASCAS (author)  caferd2 months ago

Sorry, I don't think the app has an apple counterpart.

TimothyB23 months ago

Can you replace the led with a 5 volt relay?

ASCAS (author)  TimothyB22 months ago

Yes. You'll need transistors/s to drive them though.

JustnTheNick3 months ago

Yo buddy, I've already completed a DIY wireless plug. It actually came out quite nice, even made a custom made PCB with materials from FRY's. It works by having an Arduino serve a webpage and it sends a command to the Wireless switch via a nRF24L01(+) 2.4GHz Wireless Transceiver. With this, I can make it VOICE CONTROLLED!

ASCAS (author)  JustnTheNick2 months ago

Wow, that's awesome! You should make an inscrutable about it. :D

Hey JustnTheNick, Just wondering if you had a link to this DIY wireless plug instructable, Daniel

I dont, but I have the PCB layout, and parts used. Even have the sample code I tweaked. Although, its still a WIP because the receiver end sometimes freezes and it wont send an ack packet back to the server revealing its status. That would be why.

I have 2 images, and the Fritzing file. Although you might run into some errors because the Relay(T73 5v 10 amp) used had to be imported with a library. https://code.google.com/p/fritzing/issues/detail?i...

Ive included the Arduino code. You will need to import a library or two but thats not hard at all, just google it.

I used this method to make the board, http://www.instructables.com/id/Stop-using-Ferric-...

I used the UV light sensitive Copper clad board from frys. Be aware that the etching method above is extremely slow unless you oxidize it by removing it from time to time. Took me 2 tries.

Parts used

Copper clad board presensitized

ATmega168 -20PU

28 pin socket

5.1v Zener diode for the relay(Inductors spit out high voltage when discharged)

10k ohm resistor for keeping the reset pin high.

TO-92 3.3v voltage regulator for the transciever

220uf smoothing cap.

2x 4 pin female headers for transciever

T73 10 amp 5v relay.

6 pin male header for FTDI chip. (Cap is for reset timing but couldnt get it to work, so had to use arduino uno to program. Arduino as ISP)

Power source used was a generic 5v 1 amp Ipod charger found at the dollar store. I used a Dremel to open it up and solder some wires to the usb line. So power used is a 5v line in. Used a 1mm(I think) drill bit to drill the holes.

Screen Shot 2014-10-27 at 5.16.27 PM.png

Oh yea, the mirror PDF is what I used with my method, because when you place it ink side down, it reverses to normal. Thats why I have the mirror image.

Awesome, Thanks

Skymag2 months ago
Really enjoyable !! Thx a lot :)
temp_-2123572681.jpg
ASCAS (author)  Skymag2 months ago

You're welcome! :D

can I use you're code with an Arduino MEGA 2560??

ASCAS (author)  miguelangel.ortiz.3702 months ago

Yup.

CaioP3 months ago

hello , How do I change the language? just change the language in google search and the code? changed and it did not work , could someone help me ?

Good evening, kind regards the reason for my comment is:

not if very complicated request help or information or guidance on how I connect the circuit on a mega arduino, also know as programming with blutooth module, this orientation the need for educational issues, I hope you can help me with this information my email is haroldalejandro08@gmail.com

VoliKoN made it!4 months ago

Nice project!

ArcSoft_Image3.jpg
YurikoV4 months ago

Hi i'm using gizduino mini w/ ATmega328 and a bluetooth shield.. i'm having trouble with the connection.. should i stock up both or i'll apply the rx to tx?

here's the link

http://www.e-gizmo.com/KIT/BLUETOOTH%20SHIELD.html

please help .. i badly need this for our project... :) thank you so much...

nichloe7 months ago

Hi there!

For the HC-05 Serial Bluetooth Module can we use this one?...

http://www.amazon.com/gp/product/B00JP05S6C/ref=gn...

Thanks!

ASCAS (author)  nichloe7 months ago

That should work! slr.

Hi there, i have a grove serial bluetooth, can i use with it?

1-40 of 144Next »