Low-cost Home Automation with Voice Control


STORY


Background

Today's home automation systems are expensive and often require the ability to install or modify existing hardware in the home. These two barriers to entry prohibit low-income individuals from joining the world of home automation.


My solution was to create an open source node.js server on a Raspberry Pi 2 running Windows 10 IoT Core for controlling preexisting hardware in the home without needing to make any permanent modifications. As a proof of concept, I have set up a basic home automation system in my dorm room using this node.js server.






RGB LED Strip Control

This circuit is used to control the RGB LED strip. The circuit uses N-channel MOSFETs to change the color pins of a 5050 Common anode LED strip (depicted by a single LED in the diagram). A 12v power supply is attached to the barrel connector. The resistors attached to the gate pins of the MOSFETs are 330Ω each.
Rgb%20strip
Door Lock
Download
A continuous rotation servo winds and unwinds a cable to move the door handle. To unlock the door, the servo winds the cable until a magnet on the door handle trips the reed switch (magnet sensor). To lock the door, the servo unwinds the cable for 2 seconds.
Door%20lock
Light Switch
Download
A generic servo motor that rotates to one angle for turning the light switch on and another angle for turning the light switch off.
Light%20switch

Photon code used to control the door lock, overhead lights, and the LED strip







C/C++
This code should be uploaded to your Photon board. It matches the pins from the circuits in the schematics section.
#include "rgb-controls/rgb-controls.h"
#include "SparkJson/SparkJson.h"
using namespace RGBControls;

Servo servo;
String method = "";
Color c1(0, 0, 0);
Color c2(0, 0, 0);
Led led(D0, D1, D2);
bool is_locked = true;
bool switch_on = true;

void setup() {
  RGB.brightness(16);
  Spark.function("method", color_method);
  Spark.function("lock", lock);
  Spark.function("switch", mainLight);
  Spark.variable("is_locked", &is_locked, BOOLEAN);
  Spark.variable("switch_on", &switch_on, BOOLEAN);
  
  pinMode(D5, INPUT);
  pinMode(D7, OUTPUT);
  pinMode(WKP, OUTPUT);
  pinMode(RX, OUTPUT);
}

void loop() {
    if (method.equals("fade")) {
        led.fade(c1, c2, 5000);
    }
    
    if (digitalRead(D5) == HIGH) {
        is_locked = false;
        delay(100);
        servo.detach();
    } else {
        is_locked = true;
    }
    digitalWrite(D7, digitalRead(D5));
}

int lock(String state) {
    if (state.equals("lock")) {
        if (!is_locked) {
            is_locked = true;
            servo.attach(RX);
            servo.write(150);
            delay(2000);
            servo.detach();
        }
        return 1;
    } else if (state.equals("unlock")) {
        servo.attach(RX);
        servo.write(30);
        return 0;
    } else {
        return -1;
    }
}

int mainLight(String state) {
    if(state.equals("on")) {
        servo.attach(WKP);
        servo.write(10);
        delay(1200);
        servo.detach();
        switch_on = true;
        return 1;
    } else if(state.equals("off")) {
        servo.attach(WKP);
        servo.write(70);
        delay(1200);
        servo.detach();
        switch_on = false;
        return 0;
    } else {
        return -1;
    }
}


int color_method(String command) {
    char json[100];
    command.toCharArray(json, 100);
    StaticJsonBuffer<512> jsonBuffer;
    JsonObject& root = jsonBuffer.parseObject(json);
    
    if (!root.success())
        return -1;
    
    method = root["method"];
    if (method.equals("fade")) {
        c1 = Color(root["c1"][0], root["c1"][1], root["c1"][2]);
        c2 = Color(root["c2"][0], root["c2"][1], root["c2"][2]);
    } else if (method.equals("set")) {
        c1 = Color(root["c1"][0], root["c1"][1], root["c1"][2]);
        led.setColor(c1);
    }
    
    return 0;
}
Home Automation Backend code
This is the repository for the node.js backend code that runs on the Raspberry Pi 2

michael-gillett / home_automation

5 3
No description — Read More
Latest commit to the master branch on 9-21-2015

8 comments:

  1. This is surely a very good blog, thanks a lot for sharing such nice information here.24 hour locksmith Atlanta

    ReplyDelete
  2. I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post. Open Mic

    ReplyDelete
  3. amazing article, it turned into exceptionally obliging! I understandably began in this and i am becoming greater acquainted thinking about it bigger! Cheers, store conflict extraordinary! control4

    ReplyDelete
  4. First thing we chose to do was have a house security systems strategy positioned in our residence. Ahead of, we didn’t know a good deal about home security systems organizations because we in no way actually possessed to be concerned with these kinds of problem. We requested law enforcement that we have to get in touch with plus they recommended Vivint Protection.

    ReplyDelete
  5. This post is so informative and makes a piece of very nice information on the topic in my mind.I am visited to your blog first time and I found information which I needed. Thanks.If you are looking for Self Cleaning Door Pads in UK, then, Nanoselfclean is good choice for you.

    ReplyDelete
  6. Wonderful post for us. The information you provided is very useful. Thanks for posting it and I am waiting for a more informative post like this. professional cleaning services Dublin

    ReplyDelete
  7. Lawmakers have for years pushed sports betting within the Green Mountain state, however efforts to legalize haven’t gained much traction. Oklahoma gaming is dominated by Native American entities and most appear disinclined to comply with sports betting until other key issues with the state authorities are resolved. Two tribes struck sports betting offers in 2020, however those had been later invalidated, part of a bigger battle between competition gaming interests and 온라인 카지노 the government. At one point Missouri seemed like the surest bet to pass a sports betting bill in 2022, as lawmakers overtly competed with their counterparts in Kansas to get there first. The tribes, which maintain a big lobbying presence within the statehouse, have for years opposed any laws that wouldn’t give them a monopoly on sports betting.

    ReplyDelete

Thank You , For Immediate Assistance Plz Put Email Copy to Deviceporting@gmail.com