OK Google, Open Sesame

By creating an app called "Sesame" it is possible via Google Now features to yell "OK Google, Open Sesame" at your Android Wear smartwatch to launch the app. All we need now is the (trivial) hardware to actually open the door.


This an exceedingly simple project but I describe it here for instructional purposes. We use a vanilla Arduino Uno, HC-05 Bluetooth module, and HS-311 servo. Note that the serial connection to the Arduino will prevent it from being programmed, so you will need to unplug the Bluetooth module every time you program it.


Basic Arduino code

Here's a barebones Arduino framework to read commands from the HC-05 Bluetooth Module and write them to the servo. You should add some form of authentication of your choice.

#include <Servo.h>

#define SERVO_PIN 9

Servo servo;

void setup() {
  Serial.begin(9600);
}

void loop() {
  char inputLine[200];
  int bytesRead;
  String argv[10];
  char* i;
  
  if (Serial.available()) {
    bytesRead=Serial.readBytesUntil('\n',inputLine,200);
    inputLine[bytesRead]=0;
    if(inputLine[bytesRead-1]=='\r') inputLine[bytesRead-1]=0;
    
    argv[0]=strtok_r(inputLine," ",&i);
    argv[1]=strtok_r(NULL," ",&i);
    
    if(argv[0]=="ping") {
      Serial.write("pong\r\n");
    } else if(argv[0]=="write") {
      servo.attach(SERVO_PIN);
      servo.write(argv[1].toInt());
      delay(2000);
      servo.detach();
    }   
  }
}

Android code

Here's an exceedingly barebones Android application that outputs commands over Bluetooth.


Featured on
Time magazine | Make magazine | CNET | Mashable | Hackaday