Introduction: IOT Voice Interaction Device

About: Software Architect & Robotics Engineer

How to make your own IOT device ?

This device have the ability to receive and interpret dictation or to understand and carry out spoken commands to automate your Home Appliances.

Step 1: Components

Option 1 Bluetooth version:

  1. Arduino Uno
  2. HC-06 Bluetooth Device
  3. Relay 2 ways
  4. 2* 220 uhm
  5. resistors
  6. 9v battery
  7. wires
  8. BreadBoard or PCB
  9. 2* LED light

Option 2 WIFI version:

  1. NodeMcu development board with (ESP8266)
  2. wires
  3. Relay 2 ways
  4. 2* 220 uhm resistors
  5. 2* LED light
  6. 9v battery
  7. BreadBoard or PCB

Optional Components:

Voice Recognition Module v3

Step 2: Relay Circuit

HOW TO ADD RELAYS TO ARDUINO Or NodeMCU

This is the type of relay its able to use to switch mains powered devices. These relays will handle most devices used in homes except the highest powered ones like room heaters, stoves, and motors. Make sure the VA (Volts x Amps) of the device you are switching on/off is less than the relay rating.

Warning: Always be very careful when experimenting with AC, electrical shock can result in serious injuries. Relay module from bottom side is open when AC is connected do not touch the circuit.

For the DC part of the circuit:

Arduino digital pin 10 –> module pin S

Arduino GND –> module pin –

Arduino +5V –> module pin +

Step 3: NodeMcu Configuration

  1. Unlike the rest of other components ESP8266 module needs to be

setup before using, because it’s stand-alone module and there are many methods you can follow to upload the code to it.

  1. Open Adruino IDE
  2. Go to file > References
  3. Enter http://arduino.esp8266.com/stable/package_esp8266...
  4. into Additional Board Manager URLs field.
  5. You can add multiple URLs, separating them with commas.
  6. Open Boards Manager from Tools > Board menu and find esp8266 platform.
  7. Select the version you need from a drop-down box.
  8. Click install button.Don’t forget to select your ESP8266 board
  9. from Tools > Board menu after installation.
  10. Restart Arduino IDE

Check the IP Address for your board:

  1. Open Arduino IDE
  2. Tools > Boards > Choose NodeMCU 1.0
  3. Tools > Upload Speed > 115200
#include ESP8266WiFi.h
#include <esp8266webserver.h

int8_t pin_led = 16;   // initiate 8 Bit unsigned variable </p><p>const char* ssid = "WIFI user name";
const char* password = "WIFI password";</p><p>void setup() {</p><p>  pinMode(pin_led, OUTPUT);
  
  // put your setup code here, to run once:
  WiFi.begin(ssid,password);
  Serial.begin(115200);
  
  while(WiFi.status()!= WL_CONNECTED)
  {
    Serial.print(".."); // Connection Failed! Rebooting
    delay(100);
    }
    
    Serial.println("");
    Serial.print("IP Address: ");
    Serial.print(WiFi.localIP());</p><p>    myserver.on("/",[](){myserver.send(200,"text/plain","Hello World");});
    myserver.on("/toggle",toggleLED);
    
    myserver.begin();
}</p><p>void loop() {
  // put your main code here, to run repeatedly:
  myserver.handleClient();</p><p>}</p><p>void toggleLED()
{
  digitalWrite(pin_led,!digitalRead(pin_led));  // toggle on/off led according to its status
  myserver.send(204,""); // send response '204' 
  }

Open serial port and copy the IP Address as shown. and now your device is ready you may open any browser and check the URL:

HTTP://192.168.40.10 (change the IP address as giving in your serial monitor) 

Step 4: Voice Recognition Installation

The are two ways to work with voice recognition applications:

1: Google voice recognition SDK via mobile App.

Google have a Multi-language speech recognition SDK with the ability to dictate in any third party software or to fill forms on websites. Apart from dictation, also provides voice command features that allows you to search the web, open file, programs & websites, find information, set reminders, take notes and much more. automate processes and improve your personal and business productivity.

You Can make your own App using the easiest way to build a mobile App in few hours using App Inventor for Android

http://appinventor.mit.edu/explore/

Sample Code for Arduino and Bluetooth:


upload the current code then connect your Bluetooth device to TX and RX then use the mobile App to control it.
int line1 = 8; // relay line
void setup()
{
  Serial.begin(9600);
  pinMode(line1,OUTPUT);
  digitalWrite(line1,HIGH);

}
void loop()
{
  
 if(Serial.available())
 {
   String value = Serial.readStringUntil('\n');
   Serial.println(value);
   if(value == "*close#")
   {
     digitalWrite(line1,HIGH);
     Serial.print ( "Light Closed");
   }
   else if(value == "*open#") 
   {
     digitalWrite(line1,LOW);
     Serial.print ( "Light Opened");
   }
 } }

2. Install Voice Recognition Module

A. Connect the pins

5v 5v
Tx 2

Rx 3

GND GND

B. Install the library

https://github.com/elechouse/VoiceRecognitionV3.gi...

C. File -> Examples -> VoiceRecognitionV3 -> vr_sample_train

D. Open Serial monitor and type : settings

E. Type sigtrain 0 On > Send

F. Record Your voice

G. close serial port and Open New file and paste this code:

Now you are able to close and open the led using your Voice Recognition Module

#include "VoiceRecognitionV3.h" 
VR myVR(2,3);    // 2:RX 3:TX, you can choose your favourite pins.
 
uint8_t records[7]; // save record
uint8_t buf[64];
 
int led = 13;
 
#define onRecord    (0)
#define offRecord   (1) 
 
void printSignature(uint8_t *buf, int len)
{
  int i;
  for(i=0; i<len; i++){=""     if(buf[i]="">0x19 && buf[i]<0x7F){ 
      Serial.write(buf[i]); 
     } 
    else{ 
      Serial.print("["); 
      Serial.print(buf[i], HEX); 
      Serial.print("]"); 
    } 
  } 
} 
/** @brief Print signature, if the character is invisible, print hexible value instead. @param buf -->  VR module return value when voice is recognized.
             buf[0]  -->  Group mode(FF: None Group, 0x8n: User, 0x0n:System
             buf[1]  -->  number of record which is recognized. 
             buf[2]  -->  Recognizer index(position) value of the recognized record.
             buf[3]  -->  Signature length
             buf[4]~buf[n] --> Signature
*/
void printVR(uint8_t *buf)
{
  Serial.println("VR Index\tGroup\tRecordNum\tSignature");
 
  Serial.print(buf[2], DEC);
  Serial.print("\t\t");
 
  if(buf[0] == 0xFF){
    Serial.print("NONE");
  }
  else if(buf[0]&0x80){
    Serial.print("UG ");
    Serial.print(buf[0]&(~0x80), DEC);
  }
  else{
    Serial.print("SG ");
    Serial.print(buf[0], DEC);
  }
  Serial.print("\t");
 
  Serial.print(buf[1], DEC);
  Serial.print("\t\t");
  if(buf[3]>0){
    printSignature(buf+4, buf[3]);
  }
  else{
    Serial.print("NONE");
  }
  Serial.println("\r\n");
}
 
void setup()
{
  /** initialize */
  myVR.begin(9600);
  
  Serial.begin(115200);
  Serial.println("Elechouse Voice Recognition V3 Module\r\nControl LED sample");
  
  pinMode(led, OUTPUT);
    
  if(myVR.clear() == 0){
    Serial.println("Recognizer cleared.");
  }else{
    Serial.println("Not find VoiceRecognitionModule.");
    Serial.println("Please check connection and restart Arduino.");
    while(1);
  }
  
  if(myVR.load((uint8_t)onRecord) >= 0){
    Serial.println("onRecord loaded");
  }
  
  if(myVR.load((uint8_t)offRecord) >= 0){
    Serial.println("offRecord loaded");
  }
}
 
void loop()
{
  int ret;
  ret = myVR.recognize(buf, 50);
  if(ret>0){
    switch(buf[1]){
      case onRecord:
        /** turn on LED */
        digitalWrite(led, HIGH);
        break;
      case offRecord:
        /** turn off LED*/
        digitalWrite(led, LOW);
        break;
      default:
        Serial.println("Record function undefined");
        break;
    }
    /** voice recognized */
    printVR(buf);
  }
}

Step 5: Laser Cutting

The device design is very simple but It was my first time to use the wood bending technique using the laser cutter machine.

This is the most common lattice hinge and the most reliable. Lattice hinges rely on torsion of the material to bend and it's easy to see in this photo. The radius of the bend depends on the length of the cuts, the distance between them and the thickness of the material.

There's a lot of good information about lattice hinges here http://www.deferredprocrastination.co.uk/blog/cat...

which explains the concept and actual physics behind it.

Step 6: Device Assembly

At last the device is ready to use.

Epilog X Contest

Participated in the
Epilog X Contest