Pages

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.


No comments:

Post a Comment