I took an iterative approach with this project - started with something basic, tested it and slowly added new features until I got me a slick shade controller that I can let my kids use!

Here’s an overview of the steps I’ll cover:

  • Finding a suitable motor and figuring out how to attach it to the shade.
  • Building the circuit and testing it in my balcony.
  • Taking automation to the next level by using NFC (Near-Field Communication).
  • Improving the appearance of the shade controller.
  • Supporting voice commands using Google Assistant.

Note - I wrote a more detailed post about this project in my blog, check it out if you're interested:

http://blog.udinic.com/2021/01/13/automating-balcony-shade-with-nfc/


The Motor

To start, I needed to find a strong motor that can actually move this shade, which weights 8 pounds and is 8 feet long. There are ways to measure the force needed to move the shade (like using a luggage scale), but I ended up consulting my mechanical engineer brother, who helped me pick a motor that should be strong enough for the job. I found a Servo motor that’s strong by itself, but it also comes inside a gearbox that increases its torque (and I could use all the torque I can get!). The gearbox has 2 gears in a 2:1 ratio, which produces half the speed of the original servo motor, but with twice the torque. To close or open the shade we need to rotate the crank 60 times, so with the 31 RPM the motor can do - it’ll take about 2 minutes. That’s reasonable enough.

Since I don't have a 3D printer, I improvised a way to connect the motor to my shade. I used structural components form that I found in ServoCity, a well-organized website that sells parts for projects like this.

Building the Shade Controller Circuit

I started with something basic, just 2 buttons that can move the shade in both directions.

After I got this to work, I switched the Arduino board with an ESP32. It's smaller, more powerful and support WiFi (which I'll need a little later).

The First Prototype

I moved my circuit from a breadboard to a perfboard and created a circuit I can start using in my balcony. Here's a diagram of the connections I made:

I later "installed" it in my balcony:

This worked pretty nicely, here's a demo: 

Supporting Automatic Stops Using NFC

At this point of the project I got the minimal features for a fully working motorized shade, but I wanted to take this a step further. It takes a single button press to start lowering/raising the shade, but I still need to wait and press the button again in order to stop it.

I decided to try an interesting approach - using NFC to read position markers on the shade and know when to stop the motor. I used the PN532 NFC module, which is what you probably have inside your phone right now.

I connected the NFC module using the I2C communication protocol, like this this diagram:

Writing the code to interact with the NFC chip was pretty straightforward using the Adafruit PN532 library. But, I needed to add 2 new API methods in order to support waiting for NFC tags in a non-blocking manner (see my merged Github pull-request for more info). Here's a snippet showing how my code is using the NFC module to control the motor:

// API for the NFC module (PN532 chip)
Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);

// Supported NFC tags for each shade position (0%, 100% etc.)
const uint32_t CARDID_100_PERCENT = 3952824665;
const uint32_t CARDID_0_PERCENT = 913822226;

// ..

void setup() {
  pinMode(PN532_IRQ, INPUT_PULLUP);

  // ...
}

// Main function that loops as long as the controller is powered on
void loop() {
  irqCurr = digitalRead(PN532_IRQ);

  // ...

  // The DOWN button is pressed
  if (btnDownCurr == LOW && btnDownPrev == HIGH) {
    if (raisingShade || loweringShade) {
      stopShade();
    } else {
      lowerShade();

      // Puts the NFC module on a listening mode, a NON-BLOCKING call
 nfc.startPassiveTargetIDDetection(PN532_MIFARE_ISO14443A);
...
Read more »