Automated Window Blinds - Spark Core

Thank you @a6pack :+1: Yes, the Photon & mini breadboard are inside the headrail, plenty of room in there (mine are two inch blinds).

Right now I have it hooked up to a 15000 mAh battery. My previous tests on my desk (i.e. not hooked up to blinds) it would run for 6-7 days with 4 open/close cycles a day (that is not where near long enough, so something is sucking power, maybe photon code isnā€™t optimized).

This window blind in the video is really just for testing purposes. I will take this whole setup down in ~week if everything works reliably and go install it on 12 foot wide section of windows (3X Blinds) and likely run a hardwire to it behind drywall. When I take it all down/put back up I will take some better photos.

@keithcroshaw I am also experiencing the buzzing from the servo now periodically in the closed position. Can you help me understand where to put the above code? Is it in the photon code? Thanks.

@jotto - if your using Justinā€™s Photon firmware code, using build.particle.io website, modify the firmware and simply add the following after time it says myservo.write(state);

delay(500);
analogWrite(A4,255);

You can increase the value in the delay. 500 worked for me, but you can increase it - Keith had suggested 3000.

1 Like

@jotto & @a6pack my delays are actually just place holders for how long open or close rotations will take. I donā€™t have them attached to the blinds so I havenā€™t tested it.

A few notes from my tinkering with my blinds this weekend:

  1. Using the vertical servo mount and the InstaMorph, I was able to mount the servos in two blind rails. Overall, the mounts were successful. Looking back, I probably wouldnā€™t use the vertical mounts again. The mounts were too small. They required two washers to be installed at the base to keep the servo at the right height to contact the rod. Additionally, only one of the two holes on the servoā€™s tab were used, again because it was too small. I had to install the servo into the top screw hole rendering it less stable. The InstaMorph solved all that. It filled the space underneath the servo and provided rock-solid stability. I will probably just go with InstaMorph to mount the servos on my remaining window. It is also a fairly clean looking install once it hardens.

  2. I tried to provide the servos with their own 9V DC power source. I was a bit concerned with the ability of the Photon to supply enough current to run two servos at the same time. I used a voltage regulator to set down the voltage from a 9V battery to 5V. It worked greatā€¦ initially. Unfortunately, the battery quickly drained. It was clear that I would not be able to provide enough power to the system using a battery as designed and have gone back to drawing power from the Photon. Iā€™ve not done further testing to determine if the circuit is bleeding current somewhere and causing the battery to drain. Iā€™ll add that to my project backlog and revisit at a later date.
  3. The code modifications as discussed earlier (adding analogWrite(pin,255) has indeed quieted the hum and is working great. I wonder, however, if use of the above command is somehow tied to #2 above. Iā€™ll take a look at the circuit today with a multimeter to verify if, in fact, I am actually cutting power to the servo when it is not opening/closing.
  4. Speaking of power, it is clear that the Photon must be connected to power via USB. The WiFi is always on and seems to be a power hog. Others have tried, and failed, to provide lasting power to the board via battery.
  5. I discovered that no two blinds are alike when it comes to their tilting mechanics. My plan was to control two blinds with one Photon. When both servos were connected to the Photon, the tilt angles of the blinds were not the same. I attempted to manually adjust the coupler that connects the rod to the servo to better align the binds, but it didnā€™t work. It seems that the strings on my cheaply made, faux-wood binds donā€™t behave the same. So, I am modifying the firmware to control the servos independently. I have the blinds opening/closing in unison at the moment, but the programming effort is not yet complete.
    Link to my YouTube video of the blinds opening
  6. I also installed a small switch into the endcap of one of the top rails. That way, I can open and close the blinds in the event that the Internet is down. It works, but because I donā€™t expect this to be a routinely used method, I chose small, unobtrusive momentary switches that are barely noticeable.
    Link to my YouTube video of the momentary switch in operation
  7. Iā€™m also adding a photoresistor to my circuit to measure the intensity of light coming through the window. My intent is to close the blinds when the bright summer sun is streaming inside the house in the late afternoon. This is particularly important in my dining area as it is hard to eat at the table while trying to squint into the bright sunlight. When it is overcast, however, the blinds will remain open. I know a photoresistor isnā€™t the most sensitive way to measure light, but my use case doesnā€™t require precision and I had a few lying around.
2 Likes

My goodness youā€™ve been busy! This is awesome. Good idea with the moldable adhesive. Do you have any code / parts + wiring for the momentary push button? You guys got me started on my project again. I think Iā€™m giving up on mounting my servo to the exterior of the blind housing and going back to the main shaft like I did the first time. @MrSrBeale How did you fix your groovyx.net.http.HttpResponseException: Forbidden error? I started getting that all of the sudden.

@keithcroshaw - Iā€™ll post the info on the switch later tonight. Been busy today dealing with the aftereffects of a mild snowstorm here in the Wash DC area.

Yea same here, thatā€™s why Iā€™m hacking :stuck_out_tongue:

Thanks!

Let me know if anyone wants some 3d prints. I could send some out and see if they work for your frame. Mine work quite nice, but not ā€œallā€ blinds are the same dimensions (many are though). Just message me and I can mail them to you. All of this activity makes me happy. It really is a nice setup once you have it running. Good work on killing off the buzzing. I had that happen on a few servos and had always just gone in and messed with my mapping.

1 Like

Thanks, @jjhtpc. I did find one model you put on your github for the 3D printed servo mounts. I am tempted to send it to a printer just to see the fit.

@keithcroshaw. My wiring is below. It is pretty straight forward. Iā€™m not sure if I need to tie both Grounds together (there is a Ground pin on each side of the board), but it works.

The code is from @jjhtpc with the addition of code from @hawesg for the switch. Just know that the code I have here doesnā€™t reflect that Iā€™m driving two servos using separate PWM pins (A4 &A5) as indicated in the above schematic. Iā€™ll publish that as soon as it is fully tested. Here it is he simple code with the If/Else function to enable the switch functionality:

1 Like

Great work @a6pack . Love the idea of the small switch for ā€˜manualā€™ control w/out the need for internet/phone (I had to take out my blind cord tilt mechanism as it caused too much resistance).

I will take you up on that offer @jjhtpc !

1 Like

Thanks for the quick response. I really got crackinā€™ tonight, I think this pair of windows is pretty much done. Iā€™ve also got it controlling a bunch of 433 mhz switches all out of one Particle Photon. Had some physical hurdles but nothing some electrical tape and a drill couldnā€™t handle.

Pardon the edit:

2 Likes

Great work! I like the addition of the 433 mhz switches. As I am now focused on bringing powering the Photon, Iā€™m assuming you are simply plugging the USB into a nearby outlet? Fortunately for me, most of my windows have outlets nearby. I cover the wire with a wire mold cover. Iā€™d like to make the wiring completely disappear, but donā€™t know what to do about the 5v transformer that the USB must plug into.

Some of the windows in my house have a channel of blank space between the wood trim and the wall that I was able to snake a USB cable through. These windows do not, I drilled a hole in the back corner of the valence where the valence holder had a hole. I purposly bought really long white USB cables plus the curtains hide it well. Iā€™m satisfied. Next step is to add the momentary toggle and maybe a temperature sensor and light sensor. to one of the two I will be installing in this room.

Should also mention I tried solar a while ago and that couldnā€™t even keep just the board itself afloat for more than 3 days.

@keithcroshaw sorry for the delay. Iā€™m tracking for work this week and have limited access to anythingā€¦

I ended up having to delete everything and start over. I also produced a new token in the particle build app.

Sorry so shortā€¦ Hope you get it soon!

Thanks, I think I remember having to do that once myself. Hope it doesnā€™t happen every 6 months that I donā€™t log into the Particle Dev IDE.

I thought Iā€™d share my latest progress on my blind project.
I removed my Photon and the mess of jumper cables from the mini breadboard and soldered everything to a small PCB circuit board. I used one from Radio Shack. Seems to work ok, but my soldering technique is very, very rusty. I had to re-do several of my solder joints.
I included a new option ā€“ a photoresistor to measure the intensity of the sunlight hitting the window. My goal is to have the windows automatically close when the light gets above a threshold. Right now, the circuit works fine. The Photon sees the voltage difference between the two pins of the photoresistor and stores it in a variable which I can see via the Note.js command prompt or the https://api.particle.io/va/devices/deviceID/value?access_tolken=myaccesstolken. My only problem, however, is that I donā€™t know how to get the variable back into SmartThings so I can then trigger other actions. Iā€™ve found a few bits and pieces of information on how to pull the variable out of the cloud and have it available for use in SmartThings, but Iā€™m not that strong of a coder yet to figure out how to make it work. I hope soon that missing piece will be found (like a clean Device Handler example of a Photon controlling another type of sensor, like a thermometer. To get around this for now, I connected my Photon to SmartThings via IFFT. Now, when the light goes above some value (I arbitrarily set it to 3000 right now to test), I have it turning on a light in my living room.
In the meantime, I purchased more Photons, servoā€™s, cables and electronic parts and connectors to begin to install the system on the other blinds in my home. It isnā€™t imperative to have it done now, but I hope to have them all installed before the heat of the summer kicks in.
A few lessons learned:
ā€¢ About variables on the Photo - They can only be 12 characters long. I spend quite a bit of time wondering why my photoresister wasnā€™t registering any data. It was, it was just that variable name I chose was too long and it the value wasnā€™t stored (analogLightValue vs. LightValue).
ā€¢ On Soldering ā€“ check that youā€™ve put the part in the right location before soldering. I was convinced that my pull-down resister for my momentary switch was connect to 5v. Turned out not to be the case. Turns out GND is not 5Vā€¦ who knew?!
ā€¢ On Soldering 2 ā€“ I purchased a Photon without headers. Man, what a mistake that was for me. It was way too time consuming for someone with my limited skill set to have to deal with soldering headers as well. My second attempt was with a Photon with headers and it was a bit easier for me to solder it to the PCB.
ā€¢ PCB screw terminal block connectors are quick and easy ways to connect the servos to the board. Assuming I may need to change out a servo, all it requires is to unscrew the cable at the board. I used the same connector type for the photoresistor (after adding a length of cable to the sensor so I could place it toward the middle of the window to best face the sun).
ā€¢ I purchased Duplex USB Charger/120V-15A Outlets (Leviton T5632-W) to power the Photons. Now, I just have to run a cable along the window casing (or behind it) and plug it directly into the USB charger in the wall. I wonā€™t have a transformer sticking out and taking up one of the outlets.

1 Like

I have installed three photons across 5 windows now and wanted to show the results. Although Iā€™ve mounted all of the servos, I still have some installation work to do of the Photon in my kitchen as well as clean up of the wiring for several of the windows. However, this video should serve as a good demonstration. TODO: I suppose I can work on the delays built into the code so the windows open without as much pause as there is now between them. The delay could also be because Iā€™m using a Routine to open/close the blinds. Havenā€™t experimented yet with other SmartApps to see if I can run them more or less at the same time. I also think I need to develop a SmartApp to capture the data coming from the photoresister as I think SmartThings is unable to do that in a Device Handler.
Anyway, here is the video:
Photon Window Blind Video

5 Likes

Good job! Youā€™ve come a long ways to get here :slight_smile: I have two blinds left to install, I hope I can get around to them soon.

Regarding the delays - do you use Rule Machine? Iā€™m not sure if thatā€™ll fix the delay, but it might. Just have the routine as a trigger but not actually do anything at all. And when Rule Machine detects the routine as a trigger, it will open and close all your blinds simultaneously.

Iā€™m pretty sure the drawing above has the black and white wires reversed, just for anyone following along. Still very helpful though