Smart Window Shade System

Smart Window Shade System demo Smart Window Shade System CAD

Project Overview

A motorized window shade controller built on a Raspberry Pi 4 that drives a NEMA 17 stepper motor via an A4988 driver to raise and lower a curtain hung from a wooden dowel rod. Features soft start/stop ramping, persistent step tracking, and an interactive speed control interface.

How It Works

The NEMA 17 stepper motor is mounted to the curtain rod via a 3D printed bracket. A 1-inch wooden dowel rod (~4 ft) is coupled to the motor shaft and spans the width of the window, holding the curtain. The opposite end of the dowel is supported by a 3D printed bearing bracket attached to the curtain rod.

When blinds.py up or blinds.py down is run, the motor turns the dowel to roll the curtain up or down. The system tracks the absolute step position in ~/.stepper_motor_steps so it always knows where the shade is, even after a reboot. Soft ramp-up and ramp-down logic prevents jerking at start and stop.

Hardware

Bill of Materials

#ItemDescriptionQty
1Curtain RodCOTS standard curtain rod1
2CurtainCOTS curtain1
3NEMA 17 Stepper MotorMotor to drive the dowel rod1
4A4988 Stepper DriverMotor driver for the NEMA 171
5Raspberry Pi 4Main compute board running all software1
63D Printed CaseEnclosure for the Raspberry Pi and A4988 driver1
7Wooden Dowel Rod1 in diameter, ~4 ft long1
83D Printed Motor BracketMounts NEMA 17 to the curtain rod on the motor side1
93D Printed Bearing BracketSupports non-motor end of dowel, mounted to curtain rod1
10Flex/Rigid CouplingConnects the 3D printed motor adapter to the NEMA 17 shaft1

Wiring

The A4988 driver connects to the Raspberry Pi GPIO (BCM numbering). Motor runs in 1/16 microstep mode (MS1, MS2, MS3 all HIGH) for smooth and quiet operation — 1600 steps per revolution.

A4988 PinRPi GPIO (BCM)Purpose
DIR21Direction control
STEP20Step pulse
MS116Microstep select 1
MS212Microstep select 2
MS31Microstep select 3
EN7Enable (active low)

CAD Models

Four 3D printed parts were designed for this project: a motor bracket, bearing bracket, motor adapter, and an enclosure for the Pi 4 and A4988 driver.

NEMA 17 Mount End Bracket Dowel Mount

Software

All scripts are written in Python and interface directly with the Raspberry Pi GPIO pins.

ScriptDescription
blinds.pyPrimary script. Moves shade up or down with soft ramp-up/ramp-down. Enforces step limits (0–23500).
test.pyInteractive test script with live keyboard speed control (arrow keys) and direction switching.
get_steps.pyPrints the current saved step position.
set_steps.pyResets the step counter to 0. Run after manually homing the shade.
disable.pyDisables the motor by setting the EN pin HIGH, releasing holding torque.