Monthly Archives: January 2016

Thinger.io to the rescue

I got stubborn and wanted to have a way to send data from my sensor to a Google script and then have the Google script update a Google Sheet.  The problem I ran into was that Google was looking for an HTTPS connection to act like a good secure internet citizen.  I could not figure out how to call my Google Script directly from the NODEMCU.  There are some libraries being worked on to support HTTPS, but it was way beyond my programming and patience.

So, I found Thinger.IO and tried the HTTP Endpoint.  Although it did not work at first, Alvaro was great and helped to get it working.  Google is still very fragile in how it wants to handle JSON data coming through this path, but we can pass the required data.

The other advantage of linking into thinger.io is that with the other endpoints I can connect in many other capabilities that should be fun.  Who new a garage door opening and closing could be so exciting.

I’ll get the code loaded somewhere when I get a chance.

Thinger.IO to the rescue

Thinger.IO to the rescue

Protoboard Connections

There are several pieces to this portion of the project.

  1. Get the project running on my breadboard to make sure all of the pieces worked.
  2. Design and create a box to hold the protoboard so I can mount it in the garage.
  3. Figure out a 5V power supply.
  4. Position all of the components on the board.
  5. Solder it all up.
  6. Debug and replace a blown diode (loads of fun)
  7. Test and document.

Here’s the Solidworks model I created. I plan to screw it to the ceiling near to power for the garage door and then run the wires to the sensors and the opener.

Solidworks model of module assembly

Solidworks model of module assembly

I found a 5Volt 1Amp USB charger around the house and opened it up to see the inside.  I removed the USB connector and the hooked up some 18Ga wire to the output.  While I was at it I replaced the input wires as well as they were really small and seemed to be acting up a bit. The result is a nice compact little power supply.  I think I may add some silicone to the opening to seal it up a bit.

Hack a USB charger for IoT

Hack a USB charger for IoT

I added a 2 conductor plug so it’s easy to disconnect.

ProtoboardLayout

Here’s the layout of the protoboard.  I have not decided if I’m going to bother with an external connector for the sensors and opener wires or not.  I can pull the NODEMCU board out and replace with another one to update software or at some point I may add over the air software update capability.

Installed_PBoard

Board mounted in the case.

Bottom_PBoard

Bottom of the board. Not real pretty, but functional.

Top_PBoard

Tried to use Red for power, Black for ground, Yellow for signals.

Breadboard and testing

I’ve actually been testing this for a while.  I use the Arduino IDE 1.6.5 with the NODEMCU board and then just connect with USB. Works well and I can use the serial port for debugging and learning.
The switch test fixture has made it really easy to test this out. As with the other stuff, I just modeled in Solidworks and then printed the pieces.
In the picture it is powered by a hacked USB powercube. This shouldn’t need much power to operate.
I’m using a 2N2222 to switch a 5V relay. The NODEMCU handles the conversion to the 3.3V the ESP8266 needs and I’m using that logic level to control 5V to the relay through the transistor.
I know it’s pretty simple, but still a lot of parts to get working.

IMG_1022
The next step is to connect this up on a proto-board so I can mount it in the garage. I’ve created a box with holes for leads and LEDs to be visible from the outside. I’m starting the positioning of the key components.IMG_1064

The 6 wire header at the bottom is for the 2 sensors and the relay connection to the opener. The power will connect to the connector just above the relay.

State Diagram for the garage door

I’ve been trying to figure out how to characterize and check for the states and transitions that I want to monitor and control.  It’s making my head hurt since I’ve not done this type of stuff in a while.

Here’s what the state of the door looks like over time.

StateOverTime

The information I am gathering is the status of the Open and Closed sensor and time.

Building on this, here’s the chart

stateTransitionChart

So now, I need the code to interpret the sensors so I can respond and control the door.

OK and Notify is when I want to update the spreadsheet that the door has opened or closed. Time Check is when the door will be auto-closed after a period of time (15 minutes?, maybe 5 minutes in winter).