Monday, May 15, 2017

Automated blinds with Smartthings and NodeMCU

I came across this post on the Smartthings community forums and decided to give it a try:

The code works well with a few minor tweaks. I could not get the default Wifi module to work so I went with WifiMulti from the example code in the Arduino IDE. I also could not get the script to get a DHCP lease or use the fixed IP code. I had to run the example WifiMulti script to get an IP assigned to the MAC and then flash the code above.

Since I have a 3d printer I decided to sketch a quick coupler for the blinds. It can be found on Thingiverse here

The blinds I used are from Home Depot and come in a wide variety of sizes.

Connect the red wire to the Vin pin and the black wire to the GND pin next to it. The white wire is connected to D3.

I am using a 5000mAh solar rechargeable battery. Right now it only lasts about 3 days on solar alone. I have disabled the USB UART as explained in this post but have not seen much improvement. I don't think the sleep function would work either as Smartthings would not be able to send commands while the NodeMCU is asleep. This part is still a work in progress.

I have done a few more tests and am ready to conclude that solar power may not work for me, at least not with the combined battery/solar panel combo. I rewrote a lot of the code and added OTA updates (since the device requires a ladder to install) and a sleep mode that would last for 8 hours. The thinking behind it was to sleep the device after sunset when there would be no need to re-open the blinds. I used a CoRE routine to close the blinds and set a sleep switch in the device handler. This passed a new command to the NodeMCU of 'sleep' in addition to the existing 'close' and 'open' commands.

The issue here is that the battery turns off for anything below 50mA so if you sleep you cannot wake up and if you reduce power consumption by removing power to the USB UART you get random shutoffs the power draw drops below 50mA.

NodeMCU with original code posted here ~ 80mA
NodeMCU with refactored wifi code in STA mode ~ 70mA
Wemo D1 with refactored wifi code in STA mode ~ 70mA
NodeMCU with refactored wifi code in STA mode and USB UART disabled ~ 50mA

Parts list:
Cut-to-Width blinds from Home Depot
Futaba S3003 servo
White micro USB Cable (no longer used, replaced with longer cable for direct power)
16.5ft white USB cable
NodeMCU Module
5000mAh Solar Power Bank

Remove blind gears.

With the servo mount still on the servo would sit off-center.

Cut off servo mount.

The servo should now sit dead center to the shaft.

Print and attach the adapter to the servo. 

Cut off the ends of the screws.

Feed the USB cable through the hole left by the gears that were removed.

Attach the NodeMCU inside the blind channel with double sided tape.

Put the solar battery in the window, connect the USB cable and install the blinds.