Sparkcore Smart Garage


Sparkcore Smart Garage

Sparkcore Smart Garage with battery backup, testing new software, easily deployed from the web IDE

I had previously done an IOT garage door opener with the Arduino and the CC3000 shield from Adafruit and it worked, but had issues maintaining a reliable connection without constant polling.

I decided to upgrade the idea with my favorite new IOT device: the Sparkcore from http://spark.io/. The Sparkcore is perfect for this because it abstracts away the whole task of connection maintenance and allows you to focus on the code of your application.  As long as it has power and proper credentials, it is always connected.

3D Printed case and wall mount

3D Printed case and wall mount. USB power, with front panel removed

I added a nice I2C OLED from http://Wide.HK to display the status of the Garage Door and added an LCC120 Digital relay to emulate the garage door button being pressed.  The power for the device comes from a USB power supply (from a phone) that I have plugged into the wall.

I switched the normal cyan breathing on the RGB LED to be an ultra dim green. It turned a red if the device lost cloud connectivity. I have only ever seen it turn red once when the router was being rebooted. The rest of the time it gently suggests that Wifi is working with a dim green, without becoming distracting.

 

The Hardware: PCB Board and External Connections


The parts needed to made this module are the following:

  1. Sparkcore
  2. Pebble Smartwatch (not required)
  3. OLED Screen
  4. LCC 120 digital relay
  5. Reed Switch (used for windows)
  6. screw terminals
  7. protoboard
  8. pull down resistor
  9. wire
Reed Sensors from AliExpress

Reed Sensors from AliExpress

I made a custom board for the Sparkcore that had spots to connect the OLED and the connections for the Reed Sensor and the digital relay to operate as the “button press” on the on the original button. The Reed Sensor are those window sensors that used to signal when a window has been open like these to the left.

 

Reed Sensor attached to the door with glue gun

I wired a line from my SmartGarage to the door, so that the Sparkcore would always know if the door was open or closed.   The Reed Switch is wired from the 3.3v line to an analog input pin and set that pin to be a digital input.  That way I can ask the pin if it was open or closed (1 or 0).

The line went to an unoccupied spot on the door. I used a glue gun to attach both parts of the Reed Switch so that it was held tight but would be easy enough to remove later (see right pic).

The board (think “shield” for the Sparkcore), was made from a simple proto-board with the traces from connecting square pads with solder on the board to make traces. The Sparkcore plugs right into the 2 rows of headers. You can see in the diagram that it can be done as a single-sided PCB.  I worked it out on paper until I could get something that was single-sided.

The digital relay allows me to emulate the button being pressed without connecting the Sparkcore directly to the garage door circuitry.  Applying power to 2 pins on the relay connects the 2 pins that are attached to the garage door button.   The other 2 screw terminals are used to attach the Reed Switch to the A0 pin (used as a digital input) and 3v.

What I am connecting in these pictures is the Sparkcore to the OLED screen, the LCC 120 digital relay, and a bunch of connectors for the Sensors and the LED’s. If you are making one yourself the diagram lists all of the pins of each of the components.  I also made sure to color code the wires as best as possible.  Using the 3 images above you should be able to understand the wiring and the lines to solder.

 

Operation of the SmartGarage with Pebble Steel


Pebble Steel Smartwatch

Pebble Steel Smartwatch running SmartGarage

To operate it remotely and check on its status I use my Pebble Steel smartwatch. I wrote a quick application in javascript (called SmartGarage) that allows me to query the status of the door (using the RESTful services of the Sparkcore). Because the Pebble can run Javascript applications it can easily make AJAX requests when buttons are pressed.

 

SmarkGarage showing CLOSED

SmarkGarage showing that the door is closed

When I hit the middle button it sends a secure command to the Sparkcore and asks the doors status. It allows you to press a button to open (top) and close it (bottom).  The Pebble app and the Sparkcore are tied by the Device ID and the Auth Token located in the Pebble app, so they have a one-to-one relationship.

 

A Pebble Smartwatch is not really a requirement for this project.  You can execute the “door open” command using a web application just as easily.  The RESTful interface means that any device or application (such as a smartphone app) that can execute HTTP request can operate the garage door.   I just thought that the Pebble was a nice add on and since I already had one I wanted to see if it could be integrated into this application.

 

 

The Code for the Sparkcore and the Pebble Smartwatch


The code for the Sparkcore to run the SmartGarage module is available here:

https://github.com/contractorwolf/SparkcoreSmartGarage

The code for the Pebble.js app that will run on the Pebble Smartwatch.  You only need to switch the Device ID and Access Token to match your account.  It can be easily deployed on CloudPebble.com is available here:

https://github.com/contractorwolf/PebbleSmartGarage

The code is open source and freely available to all. You can modify it as much as you need to fit your project or design.  Just give me some attribution if you use it and please send me a link to your project.  Send me a pull request on GitHub if you find something that I forgot that you think should be included.

 

3D Printed Case for the Sparkcore SmartGarage


I designed a three part 3D printed case for the SmartGarage in SketchUp so anyone can 3D print the parts for this project. The first part is the main case that holds the circuit, the OLED and the Sparkcore. The PCB slides in and locks in place with the USB port pointing down. The screen then mounts on top of that. The front panel slides its tabs under the section that holds the OLED and locks in place. The wall mount should be attached with drywall anchors and then the main case with the front panel installed should both be slid into the wall mount.

I have the SketchUp file that contains all 3 parts freely available on my Google Drive here:
SmartGarage Case SKP file (SketchUp Design file)

3D Printed Case Parts

SmartGarage Case SketchUp Design files – SKP 3D Printed Case Parts

If you need just the individual parts for printing I also have the STL files available for download as well:

SmartGarage – Wall Mount STL

SmartGarage – Main Case STL

SmartGarage – Front Panel STL

 

If you are trying this project yourself simply leave any questions you have in the comments below. You can also contact me on Google Plus here: http://google.com/+jameswolf


 

 

 

 

Link Image Gif’s


Sparkcore SmartGarage

26 Responses to Sparkcore Smart Garage

  1. Pingback: Sparkcore SmartGarage with with OLED screen in a 3D printed case | ContractorWolf.com

  2. Pingback: Sparkcore SmartGarage with OLED and 3D printed case | ContractorWolf.com

  3. dillon1337 says:

    Awesome project! I’m working on a Spark-powered lamp switcher and planned to do a web app for my iPhone. I’ll definitely have to look into a Pebble app too – that’s something I haven’t thought of before.

    • james wolf says:

      Dillion, yeah I have the code for both on Github so you have somewhere to start from. The code is really simple, button presses on the watch execute an AJAX request. The only thing that caught me up for a bit was figuring out how to pass the arguments to the Sparkcore, but it turned out to be pretty simple. Let me know if you have any questions about my code.

  4. Pingback: Smart Garage with Spark Core | MAKE

  5. jmooney5115 says:

    Hey. I’ve wanted to do this for almost a year and just got a Spark Core for Christmas. Do you worry about someone hacking your house and opening the door?

  6. jmooney5115 says:

    Do you worry about your house being hacked? I’ve wanted this since I heard of the Core but this make me nervous although the connection with the Core is secure.

    • james wolf says:

      Jmooney5115 I don’t worry about that because the only way that someone could hack you device was if they were able to guess your Device ID and your Auth Token. You can even change your Auth Token whenever you want. All communication is done over SSL as well, so even someone watching traffic on your home network wouldn’t be able to see them. I wouldn’t say that it is impossible, because I have heard that the NSA can crack SSL, but I would say that it was at least as secure as the lock on your front door.

  7. jaysettle says:

    I’m now inspired to buy a Pebble watch thanks! How ever I’m also a little confused. Does the Pebble watch have a wifi transceiver to make HTTP request?

    • james wolf says:

      @jaysettle, no the Pebble Watch has a bluetooth transceiver that communicates with your phone which allows it to easily make outgoing HTTP requests using AJAX. The watch app is written in javascript, check it out (github repo above) and you will see how easy it is. The Spark Core has a RESTful interface so the two work together nicely.

  8. Tin says:

    Hi! We would like to feature this project on EEWeb.com. If you are interested, kindly drop me a message on my business e-mail: [EMAIL ADDRESS HIDDEN]. I’ll be looking forward to your response! Thanks.

  9. jacob says:

    Liked that video shared for sparkcore garage hardware details. Helpful in knowing the machine in detail. Thanks sharing this post.

  10. Pingback: Pebble Control for the Garage | BlackDevBlog

  11. allin says:

    Does it matter what kind of garage door you have? When I hook it up to my garage door button, nothing happens. I even tried closing the circuit myself (with a piece of wire) and nothing happens.

    • james wolf says:

      Allin,
      I would check how the button is wired. The button itself should have just 2 terminals, if you connect them the button should operate the door. As long as this is the kind of garage door you have, a momentary connection of the 2 terminals with wire should be all you need.

  12. Bill says:

    This looks great, going to give it a try. Just out of curiosity, you show two LED’s (indicator red + blue) in your plan but I don’t see them in the final project at all….did you use them?

    • james wolf says:

      Bill, thats funny, I had completely forgotten about them. I think one was to indicate if the door was open or closed. That lower board was made before I had decided on attaching the screen and the functionality of the LED’s wasn’t needed after the screen. I had the JST connectors so it would be easy to use them or not. Hopefully that clears it up.

  13. Pingback: DIY智能手表监控大门,从此再也不怕忘钥匙 | Nokia 108

  14. Tharindu says:

    Hey can i know the value of the resistor you used for this project ?

    • james wolf says:

      I think you are talking about the pull down resistor which should be something like 10k, it doesnt need to be exactly 10k, just something around 10k

  15. thari911 says:

    Hey can i know the resistor value you used?

  16. Hey. I already got the 3d prints printed and the thing is that the pieces don’t fit into place. Can you please tell me what specs to use when printing this like the number of microns or anything if they have an affect on it.

    Thanks.

    • james wolf says:

      Thanks for the comment. There is certainly many differences in 3D printers and the quality that they are able to achieve, so I am not really surprised that the designs that I made wont necessarily work for every printer the same way. If you look at the SketchUp files that I have you can see that my designs measure to fit with zero tolerance between. This just happens to work with my Up Plus 2 printing at normal quality (150 microns or 0.15mm layer height), the pieces have a snug fit and lock into place. I will send you an email to see if I can help you directly. Thanks!

  17. Michele Berionne says:

    Thank you very much for this project and nice instructions online!

    I was looking for a nice project for the Pebble and this inspired me to do something similar.

    Anyway, I decided to make a few changes and I’m posting them here, in case they are of interest for someone.

    First of all, I used a wireless controller to open/close the door: I took an old remote, removed plastic case, desoldered the button and connected that to the digital relay. In this way, the project can be hidden somewhere in the garage.

    For the Pebble integration, I developed a native application. I considered using the JavaScript approach described here, but was not happy with the result. The native application looks great and is very responsive, and only took a couple of days (well… nights). At this time, the code is not publicly available yet (because I hardcoded the device id and the authentication token), but I plan to make it so in the future. If anyone is interested in it, let me know (responding to comment).

    I also developed an Android application for it. As a matter of fact, I chose to use PhoneGap for the development, so that the same application could be deployed on any platform. The interest for a phone application was to give the same also to my wife and others, as needed. This application does not hardcode device id and authentication token, so I was able to make it available for free here:
    https://github.com/mberionne/garageopener

    (Minor note: the URLs used in my apps are slightly different than in this project. The reason is that I only used it as inspiration, but then used my own code.)

    Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s