Close

Does this project spark your interest?

Become a member to follow this project and don't miss any updates

Sci-fi grade Home Automation

A system that ties some home automation with various APIs and hardware hacks.

Similar projects worth following
This project is submitted for

This project was created on 03/12/2014 and last updated 4 months ago.

Description
The goal of the sci-fi grade home automation system is to address a couple things I don't like about existing systems:

Commercial systems tend to focus on three things: lights, cameras and thermostats. There's nothing wrong with that, but it is a very small scope compared to what modern technology can do. I usually don't need to see a real-time video of my apartment wall, and outlet switches are only moderately convenient, not life-changing.

I decided to make something inspired by Corning's "A Day made of Glass" videos. That system focused on displaying interesting information, and it was awesome. Existing systems don't do that, for reasons I don't really understand.

The other problem I wanted to address was the cost. In addition to being overpriced, commercial systems tend to do as much as possible to lock you into their platform. This system combats both problems by being open-source and being designed from the ground up to integrate with multiple low-cost platforms.
Details

The system can be broken down into several large sections, which are detailed in the design document below:

The central server talks with the nodes either over Wi-Fi or off-the-shelf RF interfaces. Most of the core software runs here. It contains:

A web interface and database (really an ASP.NET page with a static dictionary, but it works the same way)

A windows service that mediates all of the various communications

Speech recognition using SAPI and some microphones hidden behind the couch

It talks to two Arduinos over USB. Those handle the outlet switches, RF, and living room blinds.

An AutoHotkey (I know, right?) script that triggers the morning and evening routines.

Other nodes are the TVs, a couple old androids running the unity app, and a spark core that deals with detecting the switch state.

The system communicates with our Fitbits over the API (for getting sleep data, health data, and other user vitals).

Components
  • 1 × Arduino Mega I'm using the Seeduino model, but it really doesn't matter. It acts as the base station
  • 1 × Arduino Nano (per switch, outlet detector node, or blind minder) This provides communication with the base over basic RF
  • 1 × RF Transmitter (Per switch or outlet detector node) I used https://www.sparkfun.com/products/10535.
  • 1 × RF Receiver (per base station and blind minder) I used https://www.sparkfun.com/products/10533. If you want meshing, you need one of these for each node that you want to be able to re-transmit as well
  • 1 × IR Detector (per IR node) These are cheap and can be trivially attached to any node with an arduino and a transmitter. I used a bunch because they come in packs of ten
  • 1 × Wireless outlet controller (per controlled outlet) I used http://www.amazon.com/Etekcity%C2%AE-Self-learning-Programmable-Christmas-Batteries/dp/B00ENY9TFQ . The separate on/off switches are important because it removes the step of checking to see if the light is on for a toggle
  • 2 × 5V wall wart (per outlet detector) One of these serves as power for the transmitter and processor, one serves as the power detector
  • 1 × Server This can be any old computer. The only requirement is that it be able to connect with the Arduino over USB
  • 1 × Microphone (per speech recognition node) I have these on a bunch of computers, each of which runs the SAPI software in the background. This gives good coverage of the apartment without significant investment
  • 1 × TV (for the FitBit dashboard node) Self explanatory. Anything will work, but I prefer wall-mounted in the bedroom

See all components

Project logs
  • Laundry Tracker

    4 months ago • 0 comments

    After I accidentally left my laundry to rot in the washing machine one too many times, I decided to permanently fix the problem with a Spark Core. I rigged it to cheap door sensors (http://www.amazon.com/Wireless-Doors-Windows-Security-System/dp/B00CDCIP00) on the washer and dryer doors, and used some simple code to figure out which one is being loaded at any given time.

    The code for the core is at the end of this post (it's so short, I'm not even sure I'm adding it to the GitHub). I'm not sharing the server-side code because practically the entire thing is access tokens, and I don't want to bother sanitizing it. Spark provides a pretty dead-simple JSON api though, so it shouldn't be hard to work out how the thing translates the variables into something usable as an email.

    Things to note:

    Those sensors are incredibly delicate. They're essentially just two almost-touching wires and a magnet to pull them together. If you touch them, prepare to spend the next half-hour or so re-calibrating them. That's also why the code has different conditions for the two sensors (they give completely different readings, almost like completely distinct models of sensors). I recommend polling each sensor a few dozen times in each state to figure out what its readings will be.

    The sensors are compatible with the 5V output of the core, which stops you from having to worry about the internal batteries. I de-soldered the speaker and replaced it with a wire between the signal pin (the one going to the blob IC in the center of the board) and the core. I removed the can-looking thing (oscillator?) that was between the PCB and the speaker, as it made the signal harder to read from the core.

    Code:

    int washerDoor = 0;
    int dryerDoor = 0;
    int washerFull = 0;
    int dryerFull = 0;
    int washerLastClosed = 0;
    int dryerLastClosed = 0;
    int washerLastOpen = 0;
    int dryerLastOpen = 0;
    int washerOpenTime = 0;
    int dryerOpenTime = 0;
    
    //This is for the washer sensor, which isn't as reliable
    int consecutive2k = 0;
    
    
    void setup() {
        Serial.begin(9600);
        Spark.variable("washerDoor", &washerDoor, INT);
        Spark.variable("dryerDoor", &dryerDoor, INT);
        Spark.variable("washerFull", &washerFull, INT);
        Spark.variable("dryerFull", &dryerFull, INT);
        Spark.variable("washerLast", &washerLastOpen, INT);
        Spark.variable("dryerLast", &dryerLastOpen, INT);
        pinMode(A1, INPUT_PULLUP);
        pinMode(A2, INPUT_PULLUP);
        
    }
    
    void loop() {
        
        int t = Time.now();
        
        //Update open/close variables
        
        //This sensor seems to report a high incidence of zeroes if and only if it is closed, so that's what this checks for
        if(analogRead(A1) > 2000)
        {
            consecutive2k++;
            if(consecutive2k > 5)
            {
                washerLastClosed = t;
                washerDoor = analogRead(A1);
            }
        }
            
        //This sensor reports a value of 2500(ish) if closed, and 3500(ish) if open, so that's what this checks for. Your calibrations may (and likely will) vary significantly
        if(analogRead(A0) < 3000)
        {
            dryerLastClosed = t;
            dryerDoor = 0;
        }
        
        if(washerLastClosed < (t-2))
        {
            washerDoor = 1;
            washerOpenTime = (t-washerLastClosed);
        }
        else
        {
            washerDoor = 0;
            washerOpenTime = 0;
        }
        
        if(dryerLastClosed < (t-2))
        {
            dryerDoor = 1;
            dryerOpenTime = (t-dryerLastClosed);
        }
        else
        {
            dryerDoor = 0;
            dryerOpenTime = 0;
        }
        
        //Do some logic on the results
        //The time requirement means that momentary opening and closing won't change anything, and the time between opening the machines for transfer is negated
        
        //If the washer door and dryer door are both open, that means that the washer is being loaded into the dryer
        if(washerOpenTime > 10 && dryerOpenTime > 10)
        {
            dryerLastOpen = t;
            dryerFull = 1;
            washerFull = 0;
        }
        
        //If only the washer door is open, that means that it's being loaded
        if(washerOpenTime > 30 && dryerDoor == 0)
        {
            washerFull = 1;
            washerLastOpen = t;
        }
        
        //If only the dryer door is open, that means it's being unloaded
        if(dryerOpenTime > 30 && washerDoor == 0)
        {
    ...
    Read more »

  • Echo and Pebble connected

    5 months ago • 4 comments

    I added a bunch of new features, and finally got around to writing an update:

    Voice recognition moved from SAPI to Amazon Echo. This was done with a Chrome extension that attaches to the Echo management page's WebSockets connection and forwards all relevant commands on to the home automation server. The code for that should be up on Github soon. The only drawback of this is that the voice says "I didn't understand that" as the lights are turning off. It does require an instance of Chrome that is constantly running, but that's fine to have on the server.

    Echo is easily the best voice recognition platform I've ever seen. It's reliable at 20 ft (assuming you don't put it on top of something that's vibrating), and really quick. Much better than SAPI, which makes a lot of sense given the age difference and compute power being thrown at the problem.

    I also mounted old Androids to two of the walls in the apartment, which allows easier control with the app. Between Pebble and Echo though, I'm using them less and less. I think that, with another Echo, the voice commands could replace the rest of the interface except for relatively rare circumstances.

    Finally, I've started work on a device that will tell me if there's laundry waiting in the washer (I often forget and have to re-run the load a few times to get rid of the smell). I'm using some off-the-shelf magnetic door sensors hooked up to a spark core, but I'm running into trouble interpreting the alarm audio. I'll have more info on how do do that once my new scope probes come in. The code is more or less done though, so once that's fixed I should start getting push notifications on my phone (maybe even played through the Echo).

    As a bonus, I added Pebble integration with the Pebble Tasker app. This is pretty straightforward, it just has tasks set up to CURL the relevant API endpoints mapped to the Pebble's buttons. I plan to link my old Pebble (with the infamous screen sync problem) to one of the panels in the apartment to get a non-backlit control surface for the bedroom, but I haven't gotten around to that yet. The goal with that is to replace the hard buttons with touch switches built into the bedside table.

    All in all, the system is becoming much more usable, and I'm starting to think about ways of integrating sensors into the mix. Currently, everything is driven off of user input, but that's obviously not ideal.

  • Finishing up

    11 months ago • 0 comments

    In preparation for the final submission deadline tonight, I wanted to talk about some of the most recent changes I've made to the platform:

    First: I have re-factored the database to pass results back either as a simple string or as JSON, instead of as javascript. This made the code across the board much more legible, and let me make the daemon a lot more sophisticated without a ton of text parsing

    Second: I added TCP bulbs and the blind minder into the final build. The TCP integration is described in the GitHub repository, and the blind minder is in the build log.

    Third: I created an AutoHotkey script to run a proper good morning and good evening routine (along with some new dashboards to go with them). That should also be in the repo.

    Fourth: I cleaned up the interface look and feel to fit more with the modern aesthetic of the rest of the apartment. The Tron nods are more subtle now (except for in the mobile app), but I think the system looks better for it.

    As far as future development goes, I have a bunch of ideas for things to do:

    First and foremost: more control surfaces are a must. I have some old droids to re-purpose into light switches using the app, and another spark core is on the way for an outlet switch in the bedroom

    Second, I would like to clean up the 3-D printed parts with some sanding and re-forging so they look a bit more solid. Right now they look very printed, mostly because they were all done on a mostly-stock Printrbot Simple with lousy calibration, and barely touched up afterwards.

    Third, I would like to look into more systems to talk to. The Phillips Hue seems like a good candidate, and maybe some more traditional (X10, etc) systems would be good fits as well.

    Finally, I want to experiment with more information sources than Reddit and Fitbit. Taking some leaves out of the "A Day Made Of Glass" playbook, calendars, messaging, and other more social data streams could be integrated smoothly to add an extra personal touch.

View all 12 project logs

Build instructions
  • 1

    Step 1: Source the parts. This shouldn't be hard, they're mostly from Amazon and Sparkfun.

  • 2

    Build the base station using the following simple steps:

    Disassemble the outlet controller remote and throw away the plastic casing

    Solder wires between the +5v line on the Arduino and the positive battery terminal on the remote.

    Do the same with the ground line and the negative battery terminal

    De-solder the buttons from the remote.

    For each button, solder a wire between the non-power side and a pin on the Arduino Mega. In my setup, they are ordered as (starting with pin 2):

    1-on 1-off 2-on 2-off (etc.)

    Plug the wireless receiver into the Arduino. Follow the guidelines at http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Wir...

    Attach an antenna (I'm using a 9-inch piece of wire) to the antenna pin of the receiver.

    Finish up by uploading the base station program to the Arduino (after making any needed pin adjustments)

    Images are in the logs below

  • 3

    Set up the server to handle IO with the base station by doing the following:

    Install IIS and the ASP.NET handlers on the server (Yes, I'm a horrible person for not using Node.JS or something like that)

    Copy the web site files (coming soon) into the C:/inetpub/wwwroot folder

    If you're comfortable installing windows services, install the duinodaemon service on the same server. Otherwise, set the duinodaemon console app to run at startup and start it up.

    Set up the server to have a static IP on your local network (If you're not using a droid, you can skip this step, I'll talk about why in a blog post here).

See all instructions

Discussions

conradcn wrote 20 days ago point

The GitHub link on the left should work. I need to revamp the TCP connector (I switched it over to their cloud system because they removed the web interface, but it causes delay and occasional lost commands), but the rest of it should work (I haven't had too many problems with it).

Are you sure? [yes] / [no]

ronissim wrote 20 days ago point

As far as I understand you plan on making this open source. I would really like to pitch in and eventually impement this in my home. Could upload the code to a repo and provide a link? thanks!

Are you sure? [yes] / [no]

conradcn wrote 8 months ago point
Thanks for all of the comments, skulls, etc. It's flattering to get this much traffic all of a sudden.

In no particular order:
The wifi bulbs are there because I wanted to use the existing electrical system, so I needed something really compact to go into the hall light sockets (I'm going to try to get some of my deposit back, so no messing with the writing). It also ended up being dimmable, so I use one in the bedroom for sunrise simulation before my alarm clock goes off. The server interfaces with the lighting controller, so it still presents to the user as an integrated web page and app.

I didn't integrate with x10 or many other commercial systems because I didn't have a huge toy budget at the time, and the sockets that do the bulk of the work came out to about five bucks each.

I picked Windows as the server just because I had a win8 media machine already running, and I speak asp.net.

I actually scrapped the voice control because it was not reliable at all. Looking into interfacing with the Amazon echo (instead of sapi) when I eventually get one of those.

There actually is a video on the side bar. I might post an update when I get more features in, but I've gotten distracted by game development and haven't done much work on this since I posted the last one. Just added some more el wire in the bedroom, tablets in the walls for easy access, and that sunrise thing.

Are you sure? [yes] / [no]

Bubba198 wrote 8 months ago point
Great work; I think it is especially unique that Windows platform is used for anything like that - ping Microsoft for a case study :) In all seriousness I did not see any x10 integration? Is that in the works. Those devices are super cheap and very handy. Also Xbee? Dallas 1 wire? I second the You Tube idea -- yes do make or even start a channel to post video updates as the system evolves. In summary -- great work!

Are you sure? [yes] / [no]

physiphile wrote 8 months ago point
I like where you are going but I think voice control is a waste right now until its more elegant, even my xbox one gets annoying and its superior to previous voice recognition software I've used.

Why are you using wifi bulbs? I say we take an adruino and have not only light coming from the LED but information to turn off your receivers and all the devices controllable by an ir remote.

Are you sure? [yes] / [no]

conradcn wrote 10 months ago point
OK, finally posted a video. Thanks to everyone for your patience.

Are you sure? [yes] / [no]

conradcn wrote a year ago point
My game got greenlit, so this project is on hold until that's released. Sorry again for the slowness on the video.

Are you sure? [yes] / [no]

conradcn wrote a year ago point
I apologize for the unforgivably slow progress on the video front. There was a sudden surge of interest in my game on Greenlight (hit #6) and I had to manage that. I'll do what I can to get a video out in the next couple weeks.

Are you sure? [yes] / [no]

conradcn wrote a year ago point
That's a good point. I didn't realize until your comment that this would be really easy to fake. I'll try to get a video posted tonight. No promises though, I have other plans for most of the evening.

Are you sure? [yes] / [no]

davedarko wrote a year ago point
You should make a Video for the reading-lazy people ;) Nevermind the ugliness, when you can show it actually works as expected. I like your case!

Are you sure? [yes] / [no]

Similar projects