Using Simblee Bluetooth to improve one's sleep

I've got more microcontrollers lying around my house than I can count. I also have enough development boards and custom MCU boards of my own design to feed a medium-size city hackathon. What I don't have are any of those items in permanent use around my house. Other than computer and mobile phone equipment, the only wireless devices I have in permanent operation are two WeMo AC power switches. Pretty pathetic, if I say so myself. Time to change this.

The inspiration for this project came to me as a bright light (literally) not long ago. I wanted to sleep in on a recent Saturday morning (I always want to sleep in, but on this particular Saturday, I actually had the opportunity). Sadly, my window blinds do a horrid job of keeping the light out. I think they might even amplify the light on its way through. The image below is set to capture the level of brightness as accurately as possible. On the left -- what it is. On the right -- what I'd like it to be.

(Source: Duane Benson)

My solution came with the recent release of the Android version of the Simblee app.
The Simblee, if you aren't familiar, is an Arduino-compatible Bluetooth control system. The Simblee uses the Arduino IDE for programming, coupled with an iPhone or Android app that allows you to easily add sophisticated wireless control to small devices (see Max Maxfield's Simblee article for more details). The Simblee product and iPhone app have been out for quite a while now, but I'm an Android user, so I couldn't try it out until the Android app became available.

The hardware
I'm going to use the Simblee to control a stepper motor connected to a set of black-out blinds. A while back, the Simblee folks gave me a number of chips and breakout boards, so I'm all set there. I also own some Adafruit motor shields. Finally, earlier this year, I designed a Simblee carrier Arduino shield, with 3 volt to 5 volt line level converters, at the request of our esteemed editor Max.

Max is well-aware that, despite the fact he asked me to design the board for him months ago, he's only received one partially functional board without the line-level converters. That was because, in the first iteration of the board, I used open drain line-level converter chips and forgot to include pull-up resistors. Whoops.

This new version uses a more traditional push-pull converter chip (Ti TXB0108) for the digital I/O, and a two MOSFET, four resistor converter on the I2C lines. I've got a third version of the shield in design that will put the Simblee module directly on an Arduino form-factor PC board. That third variant will be useable as a stand-alone Arduino with Simblee Bluetooth control.

The image below shows my test setup. From the top center, clockwise, we see the following:

With regard to the last item, why an Arduino without the microcontroller, you might ask? In fact the Simblee contains its onw 32-bit MCU and I'm using this to perform all of the computation, so I don't need the Arduino. However, since nothing else in the stack has a 5 volt supply, I'm using the Uno board as the power supply. What this has taught me is that my Simblee carrier shield needs to have a power input connector and both three and five volt regulators. It already has the 3.3 volt, but without an external regulated 5 volt source, I'm out of luck unless I use the MCU-less Arduino.

The complete stack-up is as shown below:

(Source: Duane Benson)

The basic operation will be to automatically lower the blinds in the evening, and, raise them at different hours, depending on the day -- early on weekdays to help get me up for work, and 10:00 or 11:00 a.m. for that extra rest on the weekends. The RTC will take care of the timed raising and lowering, while the app on my phone will allow me to raise and lower the blinds all the way, or partially, without my having to get out of bed.

The Simblee communicates to my phone via it's Bluetooth stack. It talks to the motor shield using its I2C interface. The Simblee is also capable of communicating with cloud-based applications and web sites, so once the basics are working, I'll set it up for remote control and scheduling, but that will be a story for a future column; meanwhile...

The software
The Simblee is programmed using the Arduino IDE, both for the microcontroller functionality of the Simblee and for the UI (user interface) on your phone. The microcontroller component is just about identical to and compatible with standard Arduino code. The phone UI is also coded in the Arduino IDE.

For example, here's the code to create the Up Arrow control on my phone:

There are three modules to the Simblee Arduino-compatible code: SimbleeForMobile, which is used to talk to a mobile phone; SimbleeCOM, which is used for Simblee-to-Simblee communications; and SimbleeCloud, which is used for interfacing with the web. At the moment, I'm only using SimbleeForMobile; I will start to use SimbleeCloud when I'm ready to add web-based remote control.

I'm have to say that the Simblee is pretty Arduino compatible. The sample code from Adafruit for the motor shield and RTC worked without modification. I was able to copy and paste the Motor shield and RTC code directly into my Simblee sketch. It doesn't get much easier than that.

The mechanism
The on-wall setup is pretty simple, as you can see in the photo below. I use the standard bracket on one side of a roller blind. On the other side, I'm going to use a small piece of flexible tubing to connect the stepper shaft to the roller blinds; this will serve as the mount and the drive shaft. Finally, I'll use small proximity sensors as limit switches for the blind's travel.

(Source: Duane Benson)

As soon as connect the motor shaft to the blind's roller and mount the light sensors, everything will be ready to go. I also need to change the mounting of the stepper a bit. Right now, when I run it, it resonates through the drywall and sounds like I'm about to be run over by a truck.

If I ever get around to designing custom hardware, the Arduino stack will be much smaller, but for now, it's a bit of an eyesore. On the other hand, this it does add to the geek-cred of the installation.

At some time in the future, I'll add in remote web-based control. I'm also planning on adding a solar panel and lithium battery, thereby making the system completely wireless. I only need enough power in reserve to handle a few up and down cycles, so solar charging should be sufficient. Speaking of which, does anyone know of an easy-to-use chip that will manage Lithium battery charging from a solar panel?