Building a Voice Controlled Home Automation Model — Part 1 — Overview
I’ve always wanted to build Jarvis.
Sometime last year, I was looking for something to build for a school project when I found this tutorial on how to build an Arduino controlled home automation model.
The writer of that tutorial, wrote another one, that explains more of the creation process here. (Thank you Ian Jennings).
Anyway, I decided to build something that does pretty much exactly the same thing but with an added feature; Voice Control (over the internet) — and build it, I did.
This post (Part 1) shall serve as a sort of high level overview of the project, elucidate all the moving parts; why they’re here and how they work.
Prerequisite Knowledge
In the world of IoT & Electronics, this is a beginner level project. But without the right background knowledge, the only outcome is being entirely lost. Here is the (non-exhaustive) list of things you might wanna read up on before diving in.
- You have to have a basic understanding of circuits; how to light up an LED with a resistor and some batteries.
- You need to know the different parts of a bread board and how to hook one up.
- You might also want to know how to solder circuit components on PCBs. I had a friend help with this, he’s more experienced in the field; so taking my circuit diagram (and breadboard prototype) and turning it into a very compact PCB circuit was a piece of cake.
- To build the Android application that does voice control, you need to have a good understand of Java (or some OOP language) and the Android SDK.
- Also, you need some form of experience with writing basic programs for the Arduino.
Things you need to have
The following is a list of apparatus and components that are required for the circuit prototype project in various quantities, dimensions and configuration. They’ll link to places you can get them where possible:
- Arduino Yún Micro-controller
- LEDs (Linrose BCMD333UWC-5PK Brite White T1–3/4 LED), and mounting clips
- Servos (HOSSEN Mini SG90 Micro 9g Servo)
- Battery Holder (Philmore Four AA Battery Holder w/ Snap Connector)
- Jumper cables, headers, more headers and even more jumper cables
- Breadboard(s)
- Prototype Paper PCB
- Resistor set
- AA Batteries
- Some thick cardboard, glue and all the types of paper you might need to create your fancy little house.
I bought way more stuff than I needed because getting stuff to Nigeria from stores like Amazon and FRYS.com takes so long and can be (more) expensive if you have to do it multiple times instead of in one go.
High Level Architecture
Below is an abstract sketch of the whole setup. Pardon my atrocious hand-writing.
Let’s take a quick look at each of the “modules”.
1. House Circuitry
This is pretty much the brain of the entire operation. The LEDs, servo motors and Arduino shall all be connected together in this circuit. The Arduino Yún has an in-built Wifi support, so it’s relatively easy to connect it to the internet.
The Arduino will be programmed to listen on a particular (Pubnub) channel for instructions and to turn on/off whatever LED when necessary.
The above diagram is exactly how all these components should be connected together with the exception of the 9V battery — I simply plugged my Arduino in using a regular USB cable.
2. PubNub
“PubNub is a secure global Data Stream Network (DSN) and easy to use API that enables developers to build, scale, and manage realtime functionality for their applications and IoT devices.”
What that means is that PubNub is a service that lets you send realtime messages over the internet between clients with relative ease. PubNub uses the pubsub pattern; a client can publish to a channel, while others can subscribe to that channel to receive messages.
This means that we can make the Arduino in our home subscribe to our channel and then send messages to it, using our android application.
3. Android Application
We’re going to build an Android Application with one view that takes in the user’s speech, translates it into meaningful Intents and Entities (using Wit.ai’s Speech To Text & NLU).
The application will take these Intents & Entities and use them to construct a message that will be published to the PubNub channel for the Arduino to pick up.
4. Wit.ai
Wit.ai is a FREE speech-to-text, Natural Language Processing API. Basically, you send Wit your user’s text or speech input and they can convert it to meaning for you; Intents & Entities. I’m doing another series that is heavily focused on Wit’s API and building chatbots. You can check that out here.
We’ll use Wit’s API to translate our user’s voice commands into useful information and then use that to send instructions to our PubNub channel.
What’s next
- In the next article in this series, we would be taking a closer look at the model’s circuitry and it’s components. We’ll build this on the breadboard and write a bit of code to see that our Arduino can turn stuff on and off.
- In the third article, we shall write more code for the Arduino to make it listen for instructions and perform the right actions, like opening the doors and turning on the lights.
- In the fourth article, we’ll build the Android application with Wit and Pubnub’s APIs.