Self Discovering IoT System

I’ve been working for a couple years now to automate my RV using a combination of Particle.io Photon micro-controllers, an iOS app, and an Alexa skill. This has been fairly easy to do, due mostly to the ease of using the Particle.io API. Over the next year, in addition to adding additional functionality and more Photons, I hope to add Apple TV and Watch apps. This got me to thinking about how to make the system easier to configure and extend.

Since I’ve written all the software pieces myself (iOS app, Alexa skill, Particle sketches), up until now I’ve taken the expedient route of just hard coding the names of each controller into both of the apps. With only a single iOS app and Alexa smart home skill, this meant updating those two programs every time I added a new Photon, or extended one of the existing Photons. Not a big deal, albeit somewhat inconvenient.

However, recently I created an additional iOS app to allow using older iPhones to be mounted to the wall and used as control panels. Hard coding the names of the controllers into the apps means that I have to manually update each device whenever there is a micro-controller change. Now this is becoming a much bigger inconvenience.

So I’ve converted each micro-controller to be self registering with the system:

  1. Each Photon publishes several variables that list the device names it implements, in addition to what ‘events’ it listens for. These variables are exposed by the particle.io API and used by both the Alexa and iOS app to dynamically configure themselves.
  2. All applications use this information, instead of having to hardcode a list of commands.
  3. This functionality is built into a published IoT particle library, so copy/paste is minimized.

So now instead of needing to reprogram the Alexa skill and iOS control panel apps whenever I add a new controller, I just need to expose the data about that controller as described above, and all the applications pick it up.

I’ve posting the Photon and iOS code to Github, so please take a look and let me know what you think.

MyRvApp

MyRvApp is an iPhone app that I’ve been working on to control my Arduino-equipped RV. The concept is pretty simple:

  • Display the floor plan of the RV
  • Controllable lights have circles overlaid to show their location
  • Tapping on a circle turns the light on or off
  • The color or alpha of the circle changes to reflect on/off state

Lights are controlled by Arduinos. These in turn communicate with each other over a simple RF24 radio network. One of the Arduinos is also connected to WiFi and Particle.io and serves as a bridge for all of the Arduinos.

Initially, lights will be hardcoded into the app. Going forward though, I’ll want the Arduinos to self publish information about their location and capabilities. This differs from HomeKit in that units are configured within each’s Arduino code. I’m doing this because I want to distribute the intelligence of the system across all of the units, instead of locating it all within a single point of control. I believe that this will result in a more robust, and eventually more intelligent system.

I’ll be creating a Github repo for this code and will be posting links here.

How to connect Echo’s Alexa to an Arduino

Introduction

As mentioned in my last post, I have connected my Echo to interface with my Arduino controlled RV lights. And thanks to the Particle.io Photon, this was quite easy. Perhaps the toughest part about this process has been getting past all the unfamiliar language used by Amazon, such as “Lambda functions”, “Skills”, and so forth. The actual implementation was fairly quick and easy, as I’ll explain in this post and the accompanying GitHub project.

Who is Alexa, and what is an Echo?

In a nutshell, the Amazon Echo is a small electronic device that you can interact with using spoken natural language. It has directional listening capability that allows it to hear you talk even in a noisy environment; for example when you’re playing the TV or stereo. It responds to you after you speak the work “Alexa”.

Requirements for connecting Alexa to your Arduino

You don’t have to own an Amazon Echo to get started. You can design and build a voice controlled interface, and test it using the Alexa Skills Kit (ASK) Service Simulator. The simulator allows you to type in what you would speak, and responds exactly as the Echo device would.

You’ll need to join the Amazon developer program, and setup an Amazon account to handle the backend. Both of these things can be done for free.

I’ve posted all the details on Github. I’ll warn you though; the instructions appear quite long. But don’t be deterred. None of the steps are particularly difficult, and the results are amazing!

I’ve been sharing tips and ideas with my buddy Don. He’s setup his Echo to control his pipe organ clocks. You can check out his work on facebook or at donholmberg.com. There’s also a blog article on Mutual Mobile’s website talking about some of our Arduino projects before connecting them to the Amazon Echo.

I’m having a blast working with all this new technology, and its fun to be able to use it to enhance my RV lifestyle!