Wednesday, 22 October 2014

Voice Controlled Automation Using Arduino

Voice Controlled Automation Using Arduino

This project uses Easy VR voice recognition module (V2). I was able to get one for myself from www.nskelectronics.com . This module is a replacement to HM-2007 module and has very good recognition efficiency even in the presence of background noise. Efficiency no doubt is not 100% and some false recognition is also possible. The data sheet of this module claims that the module is speaker dependent but while working on it I found that if your friend also speaks in the same accent as you speak the module might interpret it as your own voice. Fig. below shows the pictorial view of voice recognition module-


This module can store 15 voice instructions in 3 groups with 5 voice instructions in one group.  The module is first required to be trained before one could start working in recognition mode. In recognition mode it is first required to import the group and then the module can recognize the current input voice commands by comparing it with the 5 voices of that group.

Parameters
Voltage: 4.5-5.5V
 Current: <40mA
Digital Interface: 5V TTL level UART interface and GPIO
Analog Interface: 3.5mm mono-channel microphone connector + microphone pin interface
Size: 30mm x 47.5mm
Recognition accuracy: 99% (under ideal environment)

Training Phase-

This phase requires a USB-TTL converter module. You can get one for yourself from any electronics web store. I used the one from EleSof Tech (http://www.elesof.com/electronics/product/usb2ttl).
The snap shot of USB-TTL converter that I used is shown below-




The pin details of this module are given below-




The connection of this module with voice recognition module is very easy.



Once these connections are made you need one Serial tool to communicate with the voice recognition module.  You can use the following download link for the serial tool-

It is a point to be noted that the maximum length of voice instruction is 1.3 sec and one has to ensure that whatever you speak it must not be greater than 1.3 sec in duration. Once the recording process of a particular group starts then it cannot be stopped until you finish training of all the 5 voices in that group. If voices are already stored in that group and you have again started the training procedure then these previous voice instructions present in that group will be erased and will be overwritten by the new trained voices.

Now for training purpose open the access port serial tool. The following window will appear-




Click on tools and then configuration a new window will pop up in which do the following settings-

Serial port setting:
Ø  Baud rate: 9600
Ø  Parity bit: None
Ø  Data bit: 8
Ø  Stop bit: 1
Ø  Send format: Hex
Ø  Receive format: Char





Click Ok

Now with all these settings done you can send the commands to perform appropriate action and for that it is required to understand the format of voice commands that this module responds to.
Command format is "Head + Key". "Head" is a 0xaa, and "Key" can be any of the commands that the VR module recognizes:

For Example Command-
 0XAA11 (key=0X11) performs the following function-
Begin to record instructions of group 1

0XAA12 (key=0X12)
Begin to record instructions of group 2  

0XAA13 (key=0X13)
Begin to record instructions of group 3
0XAA21 (key=0X21)
Import group 1 and ready for voice instructions.


0XAA22 (key=0X22)
Import group 2 and ready for voice instructions.

0XAA23 (key=0X23)
Import group 3 and ready for voice instructions.

0XAA33 (key=0x33)
Change the baud rate to 9600bps.

0XAA37 (key=0X37)
Switch to compact mode.

0XAA01 (key=0X01)
Delete the instructions of group 1.

0XAA02 (key=0X02)
Delete the instructions of group 2.

0XAA03 (key=0X03)
Delete the instructions of group 3.

0XAA04 (key=0X04)
Delete the instructions of all the three groups.

0XAA70 (key=0X70)
Reset serial port to 9600 baud rate, 8 data bits, no parity, 1 stop bit.

------------------------------------------------------------------------------------------------

Send: 0xaa11
Receive (in Common Mode):

START
No voice // I did not make any sound. So it replied such message
START
Speak now
Again
START
Speak again now
Different // I spoke another words for the second time. So it replied such message
START
Speak now
Again
START
Speak again now
Finish one // recording one instruction successfully
START
Again
START
Finish one
START
Again
START
Finish one
START
Again
START
Finish one
START
Again
START
Finish one
Group1 finished! // recording group 1 successfully
Now group 1 training is done and similarly you can train other groups.



Now I will show how easy it is to use VR module with Arduino UNO to switch on/off a led which is connected at pin 13 of Arduino UNO.

Step 1 - Train VR group 1 with your voice- say one, two, three, four and five.

Step 2- Write the following code in Arduino IDE.

Code-


byte com = 0; //reply from voice recognition

void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT); // sets 13th pin as an output pin
delay(2000);
Serial.write(0xAA);
Serial.write(0x37); // Compact mode
delay(1000);
Serial.write(0xAA);
Serial.write(0x21); // to import group 1
}

void loop() // run over and over again
{

while(Serial.available())
{
com = Serial.read();
switch(com)
{
case 0x11:
digitalWrite(13,HIGH); // turn on the LED connected to pin 13th
break;

case 0x12:
digitalWrite(13,LOW); // turn off the LED connected to pin 13th
break;

}
}
}


Step 3 – Compile the above given code in Arduino IDE and upload it to your Aduino Uno board.

Step 4- connect your VR module with Arduino as per the circuit diagram shown below-


Circuit Diagram-






Step 5- Now power your Arduino board using USB or Adapter and press reset button.

Step 6- Give voice command- Speak “ONE” in the microphone to turn on the LED and “TWO” to turn off the led.

Step 7- Now you can edit your code as per your application but before you upload your code to Arduino, do not forget to remove VR connection pins at TXD and RXD pins of Arduino because uploading occupies TXD and RXD pins and so they must not perform any other function or must not be connected to any other device during the process of uploading of the Arduino code.

                                           THANKS FOR READING.........


                                                                                                             
                                                                                                                 UMESH DUTTA







3 comments:

  1. Great post, nice write up and can be utilised in various aspects of design. Thank you for sharing.

    ReplyDelete
  2. can u tell how to train it with arduino

    ReplyDelete
  3. Not Working for me.
    Voice module not communicating with arduino.

    ReplyDelete