eBits Academy

Make your roller blind smart with ESP32 and Home Assistant

Keep your existing roller blind and let a small yellow gear motor pull its bead chain. With a 3D-printed sprocket, a motor driver, and an ESP32, you can open, close, and stop the blind from Home Assistant. The motor in the MakeUseOf project cost about $4. This build uses the same type of motor with a DRV8833 driver from eBits. Read the original MakeUseOf project.

Parts for the project

Swipe to see all columns ↔

Image Component and purpose
Yellow TT gear motor, 3–6 V Yellow TT gear motor, 3–6 V
1 unit. The same type of gear motor as in the original project. Best suited to a chain that moves freely.
DRV8833 motor driver DRV8833 motor driver
1 unit. The H-bridge drives the two-wire motor in both directions. Use one of the module’s two channels.
ESP32 DevKit DOIT ESP32 DevKit DOIT
1 unit. Runs ESPHome and connects the blind to Home Assistant over Wi-Fi.
Dupont jumper wires Dupont jumper wires
1 set for the control signals during prototyping. Choose female-to-female leads if both modules have male headers.

For prototyping. A mini breadboard is useful for the control signals. Use suitable wires directly for the power supply and motor. Use secure connections and strain relief for the permanent installation.

Also needed. A regulated 5 V motor supply, a Micro-USB data cable for the ESP32, a sprocket, and a rigid bracket that fits your blind. For permanent installation, you’ll also need screws and a guard for the sprocket.

1. Measure the chain and test the sprocket by hand

Measure the bead diameter and cord thickness. Measure from the center of the first bead to the center of the eleventh, then divide by ten to get the bead pitch. Measure the motor shaft across its flats and at its widest point. TT motor shafts vary, so design the hub to fit the motor you have.

The chain in the MakeUseOf project had a pitch of about 5.5 mm, while the original sprocket was designed for about 5.9 mm. The mismatch adds up with every bead that engages and can make the chain skip. Print a test piece and check that the beads enter and leave their pockets smoothly and that the chain connector passes through.

Mount the motor so the chain runs straight into and out of the sprocket. The bracket must keep the motor in place as the blind rises. With power disconnected, check that the chain moves freely. A small TT motor is best suited to a light blind. If it stalls, cut power and check whether the chain is binding before trying again.

2. Wire the ESP32, DRV8833, and motor

Power the ESP32 over USB and the driver from a regulated 5 V supply that can handle the motor’s startup current. Connect the ESP32, driver, and motor supply grounds so the control signals have a common reference. Disconnect power before changing any wires.

Swipe to see all columns ↔

From To
ESP32 GPIO25 DRV8833 IN1
ESP32 GPIO26 DRV8833 IN2
ESP32 GND and motor supply negative DRV8833 GND
Motor supply +5 V DRV8833 VCC
The motor’s two wires DRV8833 OUT1 and OUT2

Check the labels on your module and make sure the driver is out of sleep mode. If the direction is reversed, disconnect power and swap the two motor wires. Check that the motor’s startup and stall current are within the module’s current and cooling limits. TI’s DRV8833 datasheet.

3. Add the blind to ESPHome

Add the example to a working ESPHome configuration with Wi-Fi and the ESPHome API. If your configuration already has a switch: or cover: section, append the entries under the corresponding section. The example uses GPIO25 and GPIO26 on the ESP32 DevKit DOIT. The software interlock switches off the active direction before turning on the other. Test power-up and reboot with the motor disengaged from the chain. eBits’ introduction to ESPHome.

switch:
  - platform: gpio
    id: motor_op
    pin: GPIO25
    internal: true
    restore_mode: ALWAYS_OFF
    interlock: [motor_ned]
    interlock_wait_time: 300ms
  - platform: gpio
    id: motor_ned
    pin: GPIO26
    internal: true
    restore_mode: ALWAYS_OFF
    interlock: [motor_op]
    interlock_wait_time: 300ms

cover:
  - platform: time_based
    name: "Roller blind"
    device_class: shade
    assumed_state: true
    open_duration: 12s
    close_duration: 10s
    open_action:
      - switch.turn_on: motor_op
    close_action:
      - switch.turn_on: motor_ned
    stop_action:
      - switch.turn_off: motor_op
      - switch.turn_off: motor_ned

12 and 10 seconds are example timings. Add the device in Home Assistant and try the open, close, and stop buttons with the motor disengaged from the chain. Reconnect the chain and time the travel from fully closed to fully open and back. Stay beside the blind and stop it before the mechanism strains. Enter the measured timings, then test several complete cycles, a reversal, and an intermediate position. ESPHome documentation for time-based cover control.

4. Calibrate the blind before automating it

Home Assistant estimates the position from the motor’s run time. If the chain slips or the blind is moved by hand, the displayed percentage can drift. Two reed switches and magnets can give ESPHome a physical signal at fully open and fully closed. Place the sensors so the blind triggers them before the mechanism strains. KY-021 reed switch at eBits · ESPHome endstop configuration.

Keep the blind’s chain safety device in place, keep the loop out of children’s reach, and cover the sprocket. Test the stop function and both end positions at the blind, and check that the blind stays put when the motor is off. From there, you can have Home Assistant close the blind at sunset. Home Assistant cover automation examples.