Motor on a roller blind - ESPHome version?

Hi Rik,

Thank you so much for sharing the 3D part of the project.
I will see if they fit my blinds (mine aren’t from Ikea), but even they don’t I will adjust the endcaps as needed.

I am just a little curious to see if this little stepper motor will handle my 95cm x 195cm blinds. I would be very happy if it does.

Thanks :slight_smile:

Hi Miguel,
My blinds are not Ikea - it was just the base I used and edited the stl files from.
You will notice that there are 2 inserts - they are 2 different sizes. You can easily make a new one if neither fit your blinds.
I have the steppers running (60cm wide x 180cm long) and (90cm wide x 180cm long) blinds without issues. Running them at 9v instead of 5v gives the extra torque.
If the blinds are a little too heavy, you can always run a stepper on each end controlled by the same esp8266 - just wire one 1234 and the other 4321 as they will the opposite way round :wink:
Rik

There is also a design here https://www.thingiverse.com/thing:2392856

Here is my cheap automation: https://github.com/empenoso/diy-cheap-automated-blinds

Thought I’d share my config, I’ve done things a little differently. I set up a template cover in home assistant and used that to control the esphome stepper, rather than using a template cover in esphome.

This config gives me open, close and a slider for position. I can also set position with google home (or any other automation).

I worked out, by a bit of trial and error, that it’s 11000 steps from fully closed to fully open. So all values passed from the ha template cover, which has a range of 0 - 100, are multiplied by 1100. A sensor is configured in esphome which stores the position and ha uses that as the position_template in ha. This keeps the position accurate if ha is restarted.

To keep the position accurate when the esp device is restarted, I’ve set it to move 11000 steps towards 0, wherever it is, when it hits the actual 0 position the motor stalls (which I understand is not a problem for steppers, although time will tell). So, when it’s finished it’s definitely at 0 and I can safely set that as the current position.

Anyhow here’s the HA config for the template cover:

cover:
  - platform: template
    covers:
      boxroom_blind:
        friendly_name: "Boxroom Blind"
        position_template: "{{ states('sensor.boxroom_blind_position') }}"

        open_cover:
          service: esphome.boxroom_window_control_blind
          data:
            target: 0

        close_cover:
          service: esphome.boxroom_window_control_blind
          data:
            target: 100

        set_cover_position:
          service: esphome.boxroom_window_control_blind
          data_template:
            target: "{{ position }}"

and here’s the esphome config:

esphome:
  name: boxroom_window
  platform: ESP8266
  board: d1_mini

  on_boot:
    priority: 80
    then:
    - stepper.set_target:
        id: my_stepper
        target:  -11000
    - delay: 20s
    - stepper.report_position:
        id: my_stepper
        position: 0
    - stepper.set_target:
        id: my_stepper
        target:  0
    - sensor.template.publish:
        id: position
        state: 0

wifi:
  ssid: xx
  password: xx

ota:
logger:

api:
  services:
    - service: control_blind
      variables:
        target: int
      then:
        - stepper.set_target:
            id: my_stepper
            target: !lambda 'return target * 110;'
        - sensor.template.publish:
            id: position
            state: !lambda 'return target;'

sensor:
  - platform: template
    name: "Boxroom Blind Position"
    id: position

stepper:
  - platform: uln2003
    id: my_stepper
    pin_a: D2
    pin_b: D1
    pin_c: D4
    pin_d: D3
    max_speed: 500 steps/s
    sleep_when_done: true

I don’t know if there are simpler / better ways of doing this, but it works :slight_smile:

9 Likes

If you dont have endstops and have no way of confirming the position of the blind the state may be lost on boot (i think I had this problem).
I had intermitent times where the roll up blinds would assume a state of open (when accually closed) and the roller blinds (from ikea) would unravel, which would require me to spend 1 min fixing.
I think I have mitigated this by creating a global variable for the stepper motor position (see below)

globals:
  - id: ${stepper_1}_global
    type: int
    restore_value: yes
#    initial_value: '0'
################# cover 1 ##########################
# items for Home Assistant 
cover:
  - platform: template
    name: $display_name_1
    id: ${stepper_1}_cover
    device_class: shade

    open_action:
      - stepper.set_target:
          id: $stepper_1
          target: 0
      - delay: 180s
      - stepper.report_position:
          id: $stepper_1
          position: !lambda return id($stepper_1).current_position; 
      - globals.set:
          id: ${stepper_1}_global
          value: !lambda return id($stepper_1).current_position; 
      - cover.template.publish:
          id: ${stepper_1}_cover
          state: OPEN

    close_action:
      - stepper.report_position:
          id: $stepper_1
          position: !lambda return id($stepper_1).current_position; 
      - stepper.set_target:
          id: $stepper_1
          target: 49000
      - delay: 180s
      - stepper.report_position:
          id: $stepper_1
          position: !lambda return id($stepper_1).current_position;
      - globals.set:
          id: ${stepper_1}_global
          value: !lambda return id($stepper_1).current_position; 
      - cover.template.publish:
          id: ${stepper_1}_cover
          state: CLOSED

    stop_action:
      - stepper.set_target:
          id: $stepper_1
          target: !lambda return id($stepper_1).current_position;     
      - globals.set:
          id: ${stepper_1}_global
          value: !lambda return id($stepper_1).current_position;  
#    optimistic: true  
2 Likes

I have been trying this example, using the ULN driver - but the stepper turns the same way on either up or down action - WHY??

I’ve got the same issue, did you manage to figure this out? Tried all variations of the wires, I’m sure they are right as the motor turns really smoothly.

Got it sorted, for anyone else struggling, there seemed to be an issue when using “Digital Pins” in the config, once I manually changed them to use GPIO pins it started working. Not sure why, because when I started up ESP using the Digital pins, it did list the GPIO pins correctly.

Hi, thanks for sharing. I too tried to use your code with nema 17 and driver A4988. But I don’t see the controls to move the engine. From the web page I don’t see any of it to move forward or behind. Some idea?

1 Like

I like this global variable approach but I’m having a bit of trouble figuring out how the position is suppose to be used to restore the state. Any chance you could provide a full file example?

Hi @gijsje, I am trying to build a similar thing. How exactly did you connect D5, D6 & D7 buttons as INPUT_PULLUP:

D5—3k3 Resistor----switch-----3.3 V ?

The INPUT_PULLUP is done within the ESP, you don’t have to use resistors. Since this is using PULLUP I would say that the gijsje is connecting the other side of the switch to ground.

Yes, thnx
D5----switch-----Gnd :+1:

That is it

1 Like

Did a bit of an upgrade over the weekend :slight_smile:

I replaced my 12V 48BYJ-28 (modded to bi-polar with an A4988 stepper driver) to a NEMA 17 (17HS4401). The 48BYJ-28 was a bit underpowered for the blinds I have (blackout blinds; 210cm wide, have to unroll 180cm => quite heavy as you can imagine) and the 48BYJ-28 did the job; but very slowly with a 3:1 reduction planetary gearbox :stuck_out_tongue:
With the new stepper it’s able to roll up/down the blinds in ~20sec, with the 48BYJ-28 it was ~8min…

But, that’s not the reason I’m posting here!
Since I was updating the system, I went from ESPHome 1.4.3 to a 1.5.0-dev branch for shits and giggles and found a new neat little feature. So, you can expect this to work when ESPHome 1.5.0 drops :slight_smile: It’s currently undocumented (even in the beta/next documentation of ESPHome) but it’s there and it works.
The cover template now has a new action: position_action. So I got it all set up and working, ESPHome is reporting the position back to Home Assistant and when I set the position in the HA cover it’s correctly interpreted by ESPHome.

The only minor annoyance, it’s not setable directly from the frontend :frowning: You have to click the cover entity in HA to get to the position slider:
blinds_position

I found a thread from a few years ago that describes the same problem. I’m gonna see how I tackle this cause I want to keep my configs clean and simple. So if I can do it without any extra input & automation that would be perfect :slight_smile:

2 Likes

Never mind, minor annoyance gone!
Blinds_lovelace

With a little help of slider-entity-row :slight_smile:

1 Like

Very nice.
Still need to hang my blinds tho
I had the problem that with the nemo steppers the blinds would not stay up because of the weight.
What did you do about that?

You got 2 options: don’t use sleep but then the stepper will constantly be adjusting. This was something I didn’t want.
So I did a mix-and-match. The original cord-system of the blinds were unusable but I still had the mounting brackets from an old Ikea Isdans (old model) so I used the spring-loaded side of that one (and attached the chain, just in case the elctronics fail) and put the motor on the other side. I did have to make a new 3:1 gear reduction planetary gearbox for the NEMA since it didn’t have enough torque to overcome the springs tension…

So (like some others in this thread have done aswell) you can just use the spring-loaded side of the blinds you are using. Depending on the model, you can bend the spring or if it has multiple springs just remove some. I went with the planetary gearbox because I had do use the full tension of the spring to hold my heavy blinds in place.

what config are you using?