This project presents the improvements made to my original (and first) instructable, the Automated Solar Powered Horizontal Blinds. The original design posted met the requirements at the time. It operated correctly for nearly 4 months before some design flaws became apparent.
To recap, the purpose of the blinds is to open and close based on light levels, to either let in light or close for privacy. And also the blinds should close when it gets "too hot," which is a completely arbitrary designation.
The new design does the following:
- Open (rotate to 85 degrees) in the morning to let in light
- Close (rotate to 0 degrees - blinds pointed down) in the evening to provide privacy
- Close (rotate to 165 degrees - blinds pointed up, against the sun) if the temperature exceeds a temperature of 30 C (~86 F) - this temperature is arbitrary, your comfort level may vary.
- Perform all of these activities with no external wiring, boxes, devices, etc. In other words, pass the Wife Acceptance Factor.
- Be sustainable enough that I don't abandon the project because I have to replace batteries too frequently.
The reason for these design requirements are that the window for which they were designed is a 2nd floor window over the front door of the house. This window faces South (really, SSE), which means there is a lot of sunlight (and potential warmth) in the winter with the blinds open, but the potential for too much heat in the summer.
As stated, the blinds worked perfectly for about 4 months (January install, they came back down in about June). The flaws discovered were:
- The house does not face due South..... Therefore in winter, the sun is on the window most of the day, only leaving the window late in the afternoon. This provides lots of solar charging during the winter. During the summer, however, the sun goes over the house by noon, which means there is not enough sun to charge for a large portion of the daylight hours. And the solar panel's original placement in the window gets shaded for the first few hours of the day, on top of that. Solution: Better solar panel position.
- The servo motor used to control the blinds draws a continuous 13 mA. This shocked me. In my first attempt, I did not measure current with the servo in place because my multimeter couldn't support the large draw of the servo and provide the accuracy to see that when in "sleep." Solution: High-Side Switch using a PNP Transistor.
- My original design 6V solar panel actually works against the LiPo charging module. The charging module has a rated input of 4.5V to 5.5V. When the panel received full sun and generated 6V or more of electricity, the charging module shut down. I didn't discover this until after the blinds had been installed. Solution: correctly sized panel.
- No logging/telemetry collection. This made it really difficult to diagnose the blinds when they started to malfunction. Solution: EEPROM Logging function.
- There was no way to connect/disconnect to diagnose/fix. This applied to both the solar panel and the battery.Solution: JST Connectors between battery and circuit, solar panel and circuit.
- Measurements (temperature and light) need to be against a solid 5V reference voltage (VCC out on the Arduino), NOT the 5V output of the DC-DC booster. That voltage can vary a bit, which impacts the measurements of the Analog-to-Digital conversion. In my first design, the "5V" line I used was actually the unregulated line coming off the DC-DC booster. Solution: Seems obvious, doesn't it? :) Use the *regulated* 5V output from the Arduino Pro Mini.
So let's get started!
Step 1: Parts List
I chose to use an Arduino for this project. It's what I know. You could use another micro controller, whatever suits you.
You'll notice I buy a lot from SparkFun - they're local to me. What's great about it is that I can place an order in the morning and then go pick it up that afternoon.
Other links you'll see are from banggood.com - they have a lot of cheap components, and a wide variety of electronics parts. If you're comfortable waiting for up to a month or more for your parts, you can get stuff cheap.
And from taydaelectronics.com. If you can buy several things at once, the prices are VERY good. Shipping is quite reasonable. So some of the parts you'll see in my list I actually ordered 5, 10, or 20 items in order to get to an order minimum. Who knows, maybe I'll build several of these...
- Arduino Pro Mini ($10 - SparkFun)
- Arduino Uno, for programming the Mini - you can use special cables, but this setup works for me.
- LM35DZ temperature sensor ($1.23 - Tayda)
- PN2907A PNP transistor ($0.05 - Tayda)
- Light Dependent Resistor (LDR) ($1.24 for a 10pc pack from banggood.com) -
- One (1) 10K-Ohm Resistor ($0.01 - Tayda) - though I bought a resistor pack from SparkFun for $8.
- One (1) 1K-Ohm Resistor
- 5V 1.5W Solar Panel ($4.07 - banggood.com)
- 5V DC-DC Booster ($1.38 - banggood.com)
- Lithium Battery Charging module ($2.89 for a 3pc pack from banggood.com)
- JST Connectors ($3.33 for a 60-pack from banggood.com)
- Rechargeable 3.6V Lithium battery ($15.39 for a 4-pack from Amazon, includes a wall wart charger)
- 18650 battery holder ($1 - SparkFun)
- Servo motor (I used a Hitec HS-325HB that I found at a local hobby store) (Here's an equivalent) I had to take a guess at what kind of torque was necessary. I couldn't find a reasonably-priced torque wrench to make a measurement.
- Servo motor coupling. Because I used a Hitec Servo, I needed this. ($5 - SparkFun)
- 100 uF capacitor ($0.03 - Tayda)
- Assorted hook-up wire (I bought this kit - $17.79 on Amazon)
- PCB ($2.74 for a 10 pack from Amazon)
Step 2: Tools
Useful items to have:
- Soldering Iron
- Wire clippers
- Wire stripper
- Dremel or similar small cutting tool
- Circuit board/Solder breadboard
- Heat-shrink wrap
Step 3: Prototype the Project
OK. So now that you've got all your components and a work area, it's time to throw it all together and see what happens.
In the original project, the first thing I did was hook up two AA batteries to the 5V DC-DC booster and verify I got 5V of output. This time around, I did the same, only with the actual battery, the Lithium rechargeable 3.6V battery. Fully charged, it sits at 4.1-4.2V. According to my multimeter, I get 5.04V out of the booster. Good enough.
The next step I took was to lay out all the components on a solderless breadboard, in order to write the code to control it, as well as take current and voltage measurements.
- Connect the appropriate connectors of the Lithium charging module to the battery and the solar panel (Positive to positive, negative to negative)
- Connect a wire from the panel positive terminal to analog A0 - this provides panel voltage for logging.
- The battery connects to the 5V DC-DC booster as well.
- Connect a wire from the battery positive terminal to analog A1 - this provides the battery voltage for logging.
- The 5V output from the booster goes to the RAW input on the Arduino.
- Ground from the 5V booster is used throughout.
- Connect the Arduino VCC pin to everything that needs regulated 5V.
- The servo can connect to the 5V output of the DC-DC booster, but it will go through the PNP transistor first.
- From the LDR, connect the 10K-Ohm resistor to ground. Connect a wire between the LDR and the resistor to Analog A3 - this is your light detection.
- Connect 5V to the 5V side of the LM35DZ (or your temperature sensor)
- Connect Ground of the LM35DZ to Ground.
- Connect a wire from the middle (or Output) pin of the LM35DZ to A2 - this is your temperature sensing.
- Connect 5V output from the DC-DC booster to the E (Emitter) pin of the PN2907A.
- Connect a 1K-Ohm resistor between the B (Base) pin of the transistor to pin 11 - this is the control to allow current to flow to the servo motor.
- Connect the C (Collector) pin of the transistor to the power pin of the servo motor.
- Connect the Ground pin of the servo motor to Ground.
- Connect the signal pin of the servo to pin 10 - this is the PWM pin you're using to control the servo.
While prototyping, you don't need the solar panel and lithium charging modules connected. The instructions are here for the entire assembly. From this point forward, all the components except for the charging module are in place for all measurements.
Prior to adding the transistor in steps 13-16, the following sequence took place:
Take a look at the idle current without the servo.
Now let's add the Servo motor, and note the current.
What's going on here!? Simply by connecting the servo, we have added 14 mA of idle current to the system. How can we address this? Our good friend the transistor. My original Arduino kit purchase contained some NPN transistors. After doing some reading on them (thanks SparkFun!), I decided I would try a Low Side Switch configuration. However, this did not work. I *still* had a much larger idle current than I expected. I measured the voltages at the Emitter, Base, and Collector pins, and discovered that the Base pin had a voltage when I expected none. I'm not 100% certain what's going on, other than perhaps the internal circuit of the servo is finding a path to ground via the PWM pin used for controlling the motor position? If anyone has ideas, I'm all ears....
So let's try a PNP transistor in a High Side Switch configuration.
Success!!! Now, when the servo is not moving, it looks like there is no servo attached. Hence the use of the transistor in steps 13-16.
Step 4: Programming
Of course, after you lay it out, you have to program the Pro Mini in order to test it. You ARE going to test it first, right?
I tried to use the SparkFun TTL to USB cable, but couldn't get it to work. Maybe I have the wrong cable? So I decided to see if it could be done without....
Well, on this site alone, there are several instructables for programming an Arduino Pro Mini using an Arduino Uno. It's quite simple. For me, the scariest part was removing the IC from the Uno. (This needs to be done because you can't program an Uno as a Pro Mini)
- Remove the IC from the Uno (make a note of which direction the notch is facing, so you can put it back). I did this using a plastic knife-type device, such as you might use for opening an iPhone. I started by gently prying under the IC, alternating from both sides, to avoid bending the pins.
- Connect the Uno 5V pin to the Pro Mini VCC pin.
- Connect the Uno GND pin to the Pro Mini GND pin.
- Connect the Uno TX pin to the Pro Mini TX0 pin.
- Connect the Uno RX pin to the Pro Mini RXI pin
- Connect the Uno RESET pin to the Pro Mini RST pin.
I made myself two sets of wires and connect them to a breadboard. I taped the two ends of the jumper wires together so I didn't have to individually connect the pins, once it had been done. (I'm the type of person who says, if I have to do this twice, I can automate it or make it simpler)
Now when you go into the Arduino IDE, select "Arduino Pro or Pro Mini," and you can program the board directly. I can even reprogram it without removing the whole assembly from the blinds, if I find changes I want to make.
Here's the SmartBlinds sketch I used for this project. I think it's fairly well documented, but if you have questions, feel free to ask. The EEPROM Logging class is also needed, and available in the libraries in my github.
I've also added an attempt at both the breadboard view and the schematic view of the project. Fritzing keeps interfering with me, however, so it may not look great.
Step 5: Begin Assembly
Now that we've got some data about our system, let's start assembling it.
The addition I made this time is to use the JST connectors and solder the solid-core wire to them to give them a little extra range. By default, they're VERY short. Using the connectors has the added benefit of giving you an easy break-in point between the battery and the rest of the circuit.
Note in my first project I must have failed this critical measurement, since I didn't discover the servo motor draws 14 mA all the time.
This is a good time to also solder the solid-core wire to the solar panel. I added about 2 feet of wire to the JST connector in order to position the solar panel in the appropriate location in the window to maximize sun coverage all year long, but minimize visual impact. Keep the short(er) connectors for soldering to the PCB. This minimizes the size of the part the goes into the blind top rail. Also, using solid-core wire to solder it to the PCB seems (for me) to work better than soldering braided wire into the holes. Your mileage my vary.
Cut down the PCB to the size you need for your blinds. The boards I bought are too big by about 3 rows of holes, so I cut it down by that much.
I tried to lay out the circuit as small as possible, and as neat as I could. Pre-cut the wires to the size you need, and put a little bend in it to go through corners, etc. And then down (or up) into the PCB holes. Keep in mind the height of the servo connector pins, and make sure the connector won't interfere with the servo operation within the blinds.
I also scratched off the etched lines on the DC-DC booster leading to the indicator LED. It saves about 1 mA all the time.
Ideally, the temperature sensor would be off by itself, to reduce any potential impact from the servo or other components. I failed to do that, and it's right next to the transistor.
Step 6: Complete Assembly, One Last Reprogram
The last thing I do after completing assembly is to restore the EEPROM logging class. I didn't want to write to EEPROM while prototyping and trying different things, so I had that code commented out. But now that we're ready to deploy, it's time to enable logging. The output of the log is attached.
The Pro Mini has 1024Kb of EEPROM. Based on a size of 22 bytes per entry, plus 2 bytes of "sync pattern", I should be able to get 42 entries in EEPROM before it wraps around. That's less than a month of data, at 2 activities per day. I'd like to get more, but that would require an SD card or bigger EEPROM. Maybe the next rev.
I also take one last current measurement, to make sure I don't have a short someplace. The current I measured is about 1.5 mA. With a 900 mA-hour battery, that should provide about 600 hours of operation without charging. Subtract a bit because it will not always be sleeping, and of course any time it moves, you're draining the battery faster. Using the LowPower library from rocketlabs, it sleeps at 1.5 mA. During execution, it's about 25 mA, and when moving the blinds, it's between 200 mA to about 500 mA, or more. I'd like to make the battery last even longer, but I also like to have LEDs light up when it runs so I know it's working, so that's a tradeoff I'm ok with.
Step 7: Installation
OK, now to install in the blinds.
- First, remove the corkscrew drive for the pull cord (if your blinds have them). They provide too much resistance for the servo motor to work correctly. (I don't have a picture of that because I'm re-using the original blinds and can't find that piece)
- Drill a small hole for the LDR to poke out from (I use the outside-facing side of the blinds)
- Now use a dremel or other cutting tool to cut a square for the size of your servo motor. It needs to fit tight, but you don't want to scratch or otherwise damage the servo (I used the outside-facing side again - I don't want to see it in the house, although it could be covered up by the decorative trim. Just make sure it doesn't interfere with the trim if you choose that side)
- Cover the rough edges with tape or smooth it out somehow.
- Insert the PCB into the blinds, and make sure the light sensor is sticking out the hole you drilled in step 2.
- Now attach the servo motor to the shaft and tighten the set screw down. At this point, the reason for the 90-degree 10-second wait at the beginning of operation should be clear. I start the program, allow the servo to move to 90 degrees, and then disable the battery. I then use that position to attach it to the blinds, which I've manually moved to 90 degrees to match.
- Now get on the ladder and install the blinds.
- I attached the solar panel in about the center pane, in the upper third of the window. I run the wires along the pane separators and tape the panel and the wires in place to minimize visibility.
- Now connect the solar panel to the circuit.
- Connect the battery and quickly slide the blinds into place. They should move to center, then after the 10-second delay, move to the appropriate position. I place the battery holder inside the blind rail prior to connecting.
- Reinstall the decorative trim.
- Have a beer (or in my case, a rum and Coke).
Step 8: Relax and Enjoy!
Enjoy the smooth operation of the blinds as they open and close automatically.
If you make one using my design, please let me know! I'd love to hear about it, and if you made changes or improvements. If you have any questions, ask. This website has been very helpful in learning the many different skills involved with this project, and I'd love to give back.