Introduction: Smart Blinds

Picture of Smart Blinds

Hello!

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:

  1. Open (rotate to 85 degrees) in the morning to let in light
  2. Close (rotate to 0 degrees - blinds pointed down) in the evening to provide privacy
  3. 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.
  4. Perform all of these activities with no external wiring, boxes, devices, etc. In other words, pass the Wife Acceptance Factor.
  5. 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:

  1. 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.
  2. 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.
  3. 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.
  4. No logging/telemetry collection. This made it really difficult to diagnose the blinds when they started to malfunction. Solution: EEPROM Logging function.
  5. 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.
  6. 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

Picture of 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...

  1. Arduino Pro Mini ($10 - SparkFun)
  2. Arduino Uno, for programming the Mini - you can use special cables, but this setup works for me.
  3. LM35DZ temperature sensor ($1.23 - Tayda)
  4. PN2907A PNP transistor ($0.05 - Tayda)
  5. Light Dependent Resistor (LDR) ($1.24 for a 10pc pack from banggood.com) -
  6. One (1) 10K-Ohm Resistor ($0.01 - Tayda) - though I bought a resistor pack from SparkFun for $8.
  7. One (1) 1K-Ohm Resistor
  8. 5V 1.5W Solar Panel ($4.07 - banggood.com)
  9. 5V DC-DC Booster ($1.38 - banggood.com)
  10. Lithium Battery Charging module ($2.89 for a 3pc pack from banggood.com)
  11. JST Connectors ($3.33 for a 60-pack from banggood.com)
  12. Rechargeable 3.6V Lithium battery ($15.39 for a 4-pack from Amazon, includes a wall wart charger)
  13. 18650 battery holder ($1 - SparkFun)
  14. 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.
  15. Servo motor coupling. Because I used a Hitec Servo, I needed this. ($5 - SparkFun)
  16. 100 uF capacitor ($0.03 - Tayda)
  17. Assorted hook-up wire (I bought this kit - $17.79 on Amazon)
  18. PCB ($2.74 for a 10 pack from Amazon)

Step 2: Tools

Picture of Tools

Useful items to have:

  1. Drill
  2. Soldering Iron
  3. SolderWire
  4. Wire clippers
  5. Wire stripper
  6. Multimeter
  7. Dremel or similar small cutting tool
  8. Circuit board/Solder breadboard
  9. Heat-shrink wrap

Step 3: Prototype the Project

Picture of 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.

  1. Connect the appropriate connectors of the Lithium charging module to the battery and the solar panel (Positive to positive, negative to negative)
  2. Connect a wire from the panel positive terminal to analog A0 - this provides panel voltage for logging.
  3. The battery connects to the 5V DC-DC booster as well.
  4. Connect a wire from the battery positive terminal to analog A1 - this provides the battery voltage for logging.
  5. The 5V output from the booster goes to the RAW input on the Arduino.
  6. Ground from the 5V booster is used throughout.
  7. Connect the Arduino VCC pin to everything that needs regulated 5V.
  8. The servo can connect to the 5V output of the DC-DC booster, but it will go through the PNP transistor first.
  9. 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.
  10. Connect 5V to the 5V side of the LM35DZ (or your temperature sensor)
  11. Connect Ground of the LM35DZ to Ground.
  12. Connect a wire from the middle (or Output) pin of the LM35DZ to A2 - this is your temperature sensing.
  13. Connect 5V output from the DC-DC booster to the E (Emitter) pin of the PN2907A.
  14. 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.
  15. Connect the C (Collector) pin of the transistor to the power pin of the servo motor.
  16. Connect the Ground pin of the servo motor to Ground.
  17. 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

Picture of 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)

  1. 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.
  2. Connect the Uno 5V pin to the Pro Mini VCC pin.
  3. Connect the Uno GND pin to the Pro Mini GND pin.
  4. Connect the Uno TX pin to the Pro Mini TX0 pin.
  5. Connect the Uno RX pin to the Pro Mini RXI pin
  6. 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

Picture of 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

Picture of 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

Picture of Installation

OK, now to install in the blinds.

  1. 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)
  2. Drill a small hole for the LDR to poke out from (I use the outside-facing side of the blinds)
  3. 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)
  4. Cover the rough edges with tape or smooth it out somehow.
  5. Insert the PCB into the blinds, and make sure the light sensor is sticking out the hole you drilled in step 2.
  6. 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.
  7. Now get on the ladder and install the blinds.
  8. 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.
  9. Now connect the solar panel to the circuit.
  10. 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.
  11. Reinstall the decorative trim.
  12. 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.

Comments

diy_bloke (author)2016-08-23

Great instructable. always wanted to do something like that but always stranded on the mechanical side of it :-)
High
Side switching with a PNP transistor I presume takes a high on the base
to switch off the motor. Although that will likely be much less than
the 13 mA of the servo it still will cost some current.
You tried Low Side switching with an NPN, I presume having the motor in the collectorline. You may try high side switching with an NPN (yes, an emitter follower circuit) that will take less current in rest (pin Low) and may alleviate yr earlier problem

Froz3nArcher (author)diy_bloke2016-08-25

Thanks! Everything done in this instructable (well, the previous one) was a new skill for me, minus the software.

You are correct regarding the PNP and NPN configurations I tried. I did try an NPN in an emitter follower circuit, but everything I read seemed to indicate it was rare. Not knowing why it was rare, I figured I'd stay with a more traditional use of the transistors. I didn't measure down to the sub-mA level when I tried it, sadly. At the mA level, it was the same current, but what you say makes sense - it seems like it should be lower.

I've looked at some of your other projects, I like what you've done with the attinys. Seems like a good way to reduce current even further.

diy_bloke (author)Froz3nArcher2016-08-26

Thanks. True, the emitterfollower us rare for such use, that is why I initially hsitated too. I am using an emitter follower to switch current to moisture pins and there is no current when it is OFF.
Now technically, if it were just a traditional low side switch NPN (load in the collector) as you tried, if configured ciorrect also shldnt have any current flowing when off, but transistors are not always ideal switches, maybe your transistor was not up to spec or maybe there was something else as you already suggested. Main thing is it works

Froz3nArcher (author)diy_bloke2016-09-07

I tried more than one NPN and got the same results. I don't think it was a bad transistor however, as I wasn't getting voltage on the emitter pin - I was able to measure voltage (decreasing over time) on the base pin. As in, it started at 5V during execution, and while sleeping slowly crept towards 0V over the course of several seconds. I didn't like that, couldn't explain it, but it felt wrong. Was able to eliminate that issue using the PNP high-side.

diy_bloke (author)Froz3nArcher2016-09-08

That is odd, cant think of any reason for it. I use low side switching with an NPN to switch voltage on a soil moisture measuring pin (to avoid excess corrosion) and that switches it off completely (as far as I could measure).
I think I used an old VP140 transistor for that
Anyway, it was just a suggestion, stick to whatever works for you :-)

Froz3nArcher (author)diy_bloke2016-09-08

I'm sorry - I said that wrong. I measured a slope from 5V towards 0V on the PWM pin, NOT the base pin. So I measured voltage going BACK to the Arduino.

The successful low-side switch configurations I've seen all used a 2-wire motor or device. Since the servo is a 3-wire device, could that be the difference?

diy_bloke (author)Froz3nArcher2016-09-10

not sure. Ofcourse if there still is a a pwm command active that explains the voltage.

But then it shldnt make any difference whether u use PNP or NPN down the line.
Anyway, it works for you and that is good

ÁkosB5 (author)diy_bloke2016-09-05

low side switching with npn is possible, zero consumption, BUT you need a diode on the signal wire of the servo, otherwise the servo pin on the arduino drains some current.

Froz3nArcher (author)ÁkosB52016-09-07

In discussing this with a friend who has an electrical background, he thought the diode would interfere with the PWM signal. That'd be something to try to see if it's true.

diy_bloke (author)Froz3nArcher2016-09-08

that was my fear too

ÁkosB5 (author)Froz3nArcher2016-09-07

Thanks for the feedback! I was afraid of this, too, but tested and worked OK, driving a small servo. May depend on the application.

diy_bloke (author)ÁkosB52016-09-06

you could be totally correct. I havent tried that. it may vary per motor and maybe also makes a difference what motor one uses and whether the signal pin is HIGH or LOW. Not sure if a diode would interfere with the PWM signal

armorer243 (author)2016-08-23

It would be pretty simple to replace the arduino with an ESP8266 and make it controllable by wifi. I am thinking this would make an excellent OpenHAB system addition. Thanks for the write up!

Froz3nArcher (author)armorer2432016-08-25

If you do that, I'd love to see it, and hear what your sleep/idle current is. Part of the challenge of this was reducing the battery usage in order to handle several days of overcast. I don't have an ESP8266, so can't measure it. I should just go get one.

diy_bloke (author)Froz3nArcher2016-09-08

given the fact that you have an active wifi signal, it might be a challenge to feed it off a battery, but yes would love to see that too.
@froz3nArcher. If you have size considerations (like for building it into yr blinds) the 8266-01 is the smallest and you still have 4 I/O pins. If you have good eyes and a steady hand then pin 14 is also 'easily' made available.
Frankly, the ESP8266 is a great device

ÁkosB5 (author)2016-09-05

you use 3 pcb-s. one is the pro mini, one is the 5v dc-dc, what is the 3rd one?

Froz3nArcher (author)ÁkosB52016-09-07

The third one is the Lithium battery charging module. Part number 10 in the list.

ÁkosB5 (author)Froz3nArcher2016-09-07

Thanks!

About This Instructable

7,347views

135favorites

License:

Bio: Software Engineer by trade, new to Arduino.
More by Froz3nArcher:Smart BlindsAutomated Solar Powered Horizontal Blind Controller
Add instructable to: