Showing posts with label #garagedoor. Show all posts
Showing posts with label #garagedoor. Show all posts

Sunday, January 1, 2017

alexa and the garage door

Quite some time ago, I had the goal of hooking Alexa up to my garage door without buying an off the shelf IoT product. The purpose was really to understand connecting Alexa and IoT better. So here .... the the result of my quest so far. 


So I started down the path of using a microcontroller and I documented that here. In a nutshell, the main obstacle was security and wifi. So the Netduino I got didn't have wifi and I wasn't looking to wire up ethernet from the garage, nor was it capable of doing security in the standard HTTPS fashion. So I started looking at other microcontrollers. 


Then I fell in love .... with the ESP8266. Unbelievable! Quite possibly the coolest gadget ever. You can read more about the microcontroller here - but basically it has a 32bit RISC CPU and the capabilities for 2.4Ghz wifi.

Pictured here is a HiLetgo New Version NodeMCU LUA WiFi Internet ESP8266 Development board. It cost $9.00. Seriously! $9.00. It's breadboard friendly, has a usb to serial converter and a usb micro controller. I also bought like a 4 pack of the ESP8266 chip itself for about $4.00/piece for future projects.


I flashed the board using this instruction. Pretty straight forward - had no issues, it worked like a charm. 

Then ... using the Arduino IDE, I followed this information to add the ESP8266 as an addon. Again, worked great .... had no issues. Now I can program the ESP8266 using the Arduino IDE. In the Boards Manager, I choose the NodeMCU 1.0. I played around with the Example sketches for the ESP8266 and TA-DA. I had it connecting to my wifi.

O.M.G.

OK, so at this point, I got my ESP8266 Dev board connecting to our wifi.

Next challenge ....how to connect securely to my endpoint?


So the next step was to investigate how to connect to a Amazon endpoint. I've been looking at AWS Iot for some time and quite frankly I was really confused by it. I played with it and deleted stuff and played again.

Eventually I stumbled on MQTT, which is a really lightweight connectivity protocol perfect for IoT. Super lightweight and not as blotted as HTTP. THEN .... I ran into this. Genius!

Seriously, I almost cried. Thank you Fábio Toledo!

Fábio explains it the best by saying, "We cannot use AWS MQTT service directly because of the lack of support for TLS 1.2, we need to use the websocket communication as a transport layer for MQTT through SSL (supported by esp8266)

This way we can change the state of your esp8266 devices in realtime, without using the AWS Restful API and busy-waiting inefficient approach."

It took a little while to work out the kinks, but finally I got it to connect, subscribe, and send messages. I was soooo geeked!


Next, was to set up the Lambda event using AWS, and this article really helped me. So this really tied everything together for me and just really took the confusion out of AWS IoT. I've done Alexa Skills before - so it wasn't long before I was communicating using Alexa, the ESP8266, AWS IoT, and AWS Lambda. I did have some security issues, but once I figured those out ... I was golden.

Last challenge, I really needed help with this .... How to hook up the ESP8266 to the garage door opener remote I purchased?

Heavy sigh .....

Luckily I have an awesome husband who understands electronics a little bit more than me. Together we headed off to Radio Shack and bought this Reed Relay. It was a guess really, what type of relay we actually needed.


I really wanted to use the garage door opener remote because I didn't want to mess with the electronics of the garage door - so if I accidentally fried something - it would be just the remote.

So on New Years Eve, after a dinner and movie - Burke and I sat down and finished off the wiring. This part was all him.


We got power to the breadboard using the ESP8266, and then hooked up the relay. Once we got power to the relay, we hooked up the LED.  I wrote a small program that basically would use turn on the LED. Once I could run the program and light up the LED, we hooked up the button and .....

a few minutes past midnight on New Years eve - 2017, it worked.

This morning, I finished putting it all together ....



Quite possibly the best week off work and New Years a girl could ask for.

I.love.my.life.


Thursday, October 20, 2016

alexa, netduino, and the garage door

In the raffle at the Christmas party of 2015, I won a Netduino Plus 2. I was super excited because I was thinking about my next smart home project - (dun dun dun), the garage door opener! A developer and systems engineer by day .... this would be my first experience with micro controllers, electronics, and embedded software.



My goal in this project is to a) talk to the garage door with Alexa and my phone, b) secure the endpoint against intruders with SSL and any other means I can think of, c) monitor whether my door is open or closed, d) actually open and close the garage door.

Isn't it cute?!


I need to think more about using Alexa as this would mean I would have to expose my little web server to the world and get a public ip address and DNS record. Not sure if I want to do that. You can check out Amazon's requirements for hosting your own web service here. I've had public web servers running in my house before, it's not a big deal. It's just a pain .... to keep it up and secure.

I looked around for resources on the outer webs (aka Google) and started with this post. I bought a trusty garage door remote that I wanted to use as my relay and synced it to my garage door system. It was super easy. I climbed up to the garage door opener and pushed the button and then pushed the button on the remote and VIOLA! The garage door opened.



Next, I went to install the development requirements on my MacBook Air and found that while you can do it - from what I read .... it seemed tricky. I mean NETMF is a Microsoft framework, so I brought out my Surface 1 and began setting it up.

First I had to clean my Surface up - lots of old development environment, so I took some time to remove any existing frameworks and IDE's. I started with this post from Greg Zimmer, which by the way I think he's my new hero. He has several articles on his garage door project too. While the article is written in 2011 ....  it was super helpful.



Here's what I did for the Dev Environment:
- Microsoft Visual Studio Community 2015 (I saw posts were people were able to get the professional version of VS working, but since I was using my small Surface - I went with the Community version. You can find it here.

- Next was the most up to date .NET Microsoft Framework (NETMF), which I found to have been moved to CodePlex. You can find SDK v4.3 (QFE2-RTM) which is the most current at this date, here.

- Then the .NET Micro Framework project system which essentially is a plug in for Visual Studio.

- And lastly, the Netduino SDK, which can be found here.

FINALLY, starting my first project.

I followed Greg's blog post found here on completing just a simple program and deploying it to the Netduino. When I deployed, I received the message,

" Cannot deploy the base assembly 'mscorlib' or any of his satellite assemblies to device - USB: Netduino twice. "

Why is the base assembly a he? So, it looks like the the project contains a newer version than what's on the Netduino, so time to look for a firmware upgrade.

I found this YouTube video on upgrading the firmware which looked good enough. Then I went out to www.netduino.com/downloads to look for the most recent update, which was 4.3.2.1 at the time of this writing. Finished deploying the firmware update - redeployed the app and my deployment was successful. I had a blinking light. Yay! (Boooo ... forgot picture of said blinking light).

Now here's where it got interesting. Next I wanted to put a web service on the Netduino so I can get Alexa to send/receive requests. So I started with Greg's post on putting a webservice on the Netduino. That was easy enough and was working quickly.

Now thinking about getting Alexa to hit the web service. At this point I haven't done anything to the Hello World Web Server example. I started looking at small json libraries that could return a response.



And this is where I stopped. First, the Netduino Plus 2 doesn't have wifi capabilities so I would have to run a cable from the garage to my router or find some sort of wifi adapter (sad face). While I was willing to do that, the next point was a stop and think point.

Reviewing the Amazon documentation, Alexa won't talk to any endpoint that does not have a SSL cert and the Netduino Plus 2 does not have that size capability to house one. This post sums it all up.

While one of my goals was to have Alexa talk to my garage door, maybe it's time to review my hardware architecture. I could continue on and complete my mission without Alexa, but I still want to secure my endpoint with something more than a password.

Time to do some more research ..... hello Google.