Motor on a roller blind - ESPHome version?

So summer is here and even if it’s nice with the sun it’s messing with my GOT on the TV so ofc. I want to automate my blinds! :smiley:
I’ve ordered all the parts for this project https://www.thingiverse.com/thing:2392856 and printed the rest. it uses a 28BYJ-48 stepper motor + ULN2003 driver board and I could just use the .ino file that he includes in the project but I rather use ESPHome so that I can hook up some sensors etc to the same ESP!

I found the instructions for using the ULN2003 driver with ESPhome but how can I set the min/max positions unless I want to use sensors for that? In his software he has some options to set start and stop positions, is that possible in ESPHome?`

8 Likes

I don’t think you can make a web server to do the calibration like that on esphome. But you could certainly manually raise and lower the blind to the min and max position, then set that in your YAML as the min and max positions.

Hi
Did you find the yaml file for your blinds if so would you be able to share it I need help I would be much appreciated I have tried doing it on esp home but motor just gets hot and don’t move thanks nathan

1 Like

Welcome to the forum @Nmcknight20!
And no, I actually talked to the creator of the thingiverse file and he told me I would get the same problem as you.
his message to me was:
"I can warn you that if you are going to use the standard components in ESPHome you will have to cut the power to the steppermotor after you stop it… otherwise it will get to hot and give up in the end.
Create a custom component in esphome instead so you can run it to the start and stop position and then cut the power to the coils in the motor."

1 Like

I found ‘sleep_when_done: true’ option motor sleeping mode so I think esphome can make blind but I don’t know how to make full esphome blind yaml

I wish I can get fullly activate esphome_blind.yaml. : )

1 Like

I have been playing with this for a long time and yesterday i finally figured it out how to get it working.
The only issue i have is that it does not always counts the steps perfect so it changes the start and stop position a little bit.
I have also working on another design for the mounts so it is direct drive and not using gears but i needed to have a 9VDC power supply.
I am sill changing things in the design will post when i am happy with it.

esphome:
  name: huiskamer_rolgordijn_rechts
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: "SSID"
  password: "PASSWORD"

# Enable logging
logger:

web_server:
  port: 80  

api:
  password: 'PASSWORD'
  services:
    - service: control_stepper
      variables:
        target: int
      then:
        - stepper.set_target:
            id: my_stepper
            target: !lambda 'return target;'
 cover:
  - platform: template
    name: "Rol Gordijn Rechts"
    id: rolgordijn
    open_action:

      - stepper.set_target:
          id: my_stepper
          target: 0 
    close_action:

      - stepper.set_target:
          id: my_stepper
          target: 25000
    stop_action:

      - stepper.set_target:
          id: my_stepper
          target: !lambda return id(my_stepper).current_position;      
    optimistic: true   
  
stepper:
  - platform: uln2003
    id: my_stepper
    pin_a: D0
    pin_b: D1
    pin_c: D2
    pin_d: D3
    max_speed: 300 steps/s
    sleep_when_done: true    

    # Optional:
    acceleration: inf
    deceleration: inf
6 Likes

It’s Awesome thx for your code sharing :slight_smile:

@gijsje
I too have been playing around with stepper motors and ESPhome. I’m using a different driver than you - a TB6600 which is similar to the a4988 driver (which I used as the platform) I have it working fine except for one issue.
As long as my target position is a positive number, the motor will move to the correct position. But if I input a target of a negative number, the motor will rotate back to only to the -8 step. Doesn’t matter what the value is (-2000,-100,-15, etc) it won’t go past the -8 step. if I input -1 thru -7, it will position to the correct step.
I’m not a C++ coder, but looking at the esphome files for a4988 and stepper, I don’t find anything (I think…)that would be sending the wrong target values, etc…

Can you possibly try in your setup to send a negative target value and see what happens?

Thanks

1 Like

I also did try first to add as a switch and the i also did try negative numbers and it just did go the other way then positive numbers

1 Like

Does your configuration work?
Can I see your configuration.yaml for working with uln2003?

I am taking my first steps with ESPHome.

1 Like

This is what i have

esphome:
  name: huiskamer_rolgordijn_rechts
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: "SSID"
  password: "PASS"

# Enable logging
logger:

web_server:
  port: 80  
  
# Enable Home Assistant API
api:
  password: 'PASS'
  services:
    - service: control_stepper
      variables:
        target: int
      then:
        - stepper.set_target:
            id: my_stepper
            target: !lambda 'return target;'
            
            
ota:
  password: 'PASS'
  
binary_sensor:
  - platform: gpio
    pin:
      number: D5
      mode: INPUT_PULLUP
      inverted: True
    name: "Omhoog Knop"
    id: omhoog_knop
    on_press:
      - cover.open: rolgordijn
    
  - platform: gpio
    pin:
      number: D6
      mode: INPUT_PULLUP
      inverted: True
    name: "Stop Knop"   
    id: stop_knop
    on_press:
      - cover.stop: rolgordijn    
    
  - platform: gpio
    pin:
      number: D7
      mode: INPUT_PULLUP
      inverted: True
    name: "Omlaag Knop"  
    id: omlaag_knop
    on_press:
      - cover.close: rolgordijn   
          
                    
cover:
  - platform: template
    name: "Rol Gordijn Rechts"
    id: rolgordijn
    open_action:

      - stepper.set_target:
          id: my_stepper
          target: 0 
    close_action:

      - stepper.set_target:
          id: my_stepper
          target: 25000
    stop_action:

      - stepper.set_target:
          id: my_stepper
          target: !lambda return id(my_stepper).current_position;      
    optimistic: true   
          

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

    # Optional:
    acceleration: inf
    deceleration: inf  
2 Likes

Thanks for your reply. It worked for me!

esphome:
  name: stepper
  platform: ESP8266
  board: d1_mini

wifi:
  networks:
  - ssid: "xxx"
    password: "xx"
  - ssid: "xxx"
    password: "xxx"

# Enable logging
logger:

# Enable Home Assistant API
api:
  services:
    - service: control_stepper
      variables:
        target: int
      then:
        - stepper.set_target:
            id: my_stepper
            target: !lambda 'return target;'

ota:

web_server:
  port: 80 

cover:
  - platform: template
    name: "Жалюзи"
    id: window_1_1

    open_action:
      - stepper.set_target:
          id: my_stepper
          target: -700

    close_action:
      - stepper.set_target:
          id: my_stepper
          target: 700

    stop_action:
      - stepper.set_target:
          id: my_stepper
          target: !lambda return id(my_stepper).current_position;      

    optimistic: true  

stepper: #https://community.home-assistant.io/t/motor-on-a-roller-blind-esphome-version/116179/11
  - platform: uln2003
    id: my_stepper
    pin_a: D1
    pin_b: D2
    pin_c: D3
    pin_d: D4
    max_speed: 250 steps/s
    sleep_when_done: true    

    # Optional:
    acceleration: inf
    deceleration: inf

2 Likes

I have office blinds. Added buttons for manual initial setup:

esphome:
  name: window_1
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: "ххх"
  password: "ххх"

# Enable logging
logger:

# in Home Assistant 
api:
  services:
    - service: control_stepper
      variables:
        target: int
      then:
        - stepper.set_target:
            id: my_stepper
            target: !lambda 'return target;'

ota:

web_server:
  port: 80 

# physical connection
stepper: #https://community.home-assistant.io/t/motor-on-a-roller-blind-esphome-version/116179/11
  - platform: uln2003
    id: my_stepper
    pin_a: D0
    pin_b: D5
    pin_c: D6
    pin_d: D7
    max_speed: 250 steps/s
    sleep_when_done: true    
    acceleration: inf
    deceleration: inf

i2c:

sensor:
  - platform: bh1750
    name: "Window lighting"
    address: 0x23
    update_interval: 40s

# items for Home Assistant 
cover:
  - platform: template
    name: "Venetian blinds"
    id: window1

    open_action:
      - stepper.report_position:
          id: my_stepper
          position: 0
      - stepper.set_target:
          id: my_stepper
          target: -1700

    close_action:
      - stepper.report_position:
          id: my_stepper
          position: 0
      - stepper.set_target:
          id: my_stepper
          target: 1700

    stop_action:
      - stepper.set_target:
          id: my_stepper
          target: !lambda return id(my_stepper).current_position;      
    optimistic: true  

# for manual adjustment of the initial setting position
switch:
  - platform: template
    name: "Step minus"
    turn_on_action:
      - stepper.report_position:
          id: my_stepper
          position: 0
      - stepper.set_target:
          id: my_stepper
          target: -200
  - platform: template
    name: "Step plus"
    turn_on_action:
      - stepper.report_position:
          id: my_stepper
          position: 0
      - stepper.set_target:
          id: my_stepper
          target: 200

4 Likes

Haven’t actually hooked it up to my blinds but this seems to be working nicely, thanks. Any chance you have posted your direct-drive mounting solution to Thingiverse or elsewhere to share. I am currently looking to implement pgote’s “Motor on a roller blind solution” from Thingiverse. Cheers.

1 Like

I have just uploaded them but thingiverse is not the fast with creating the pics.
You can find all the files under thing files

1 Like

Thanks for sharing the code! I was able to get it up and running surprisingly quick and the blind was detected in home assistant automatically.

This is the motor I got: https://www.amazon.co.uk/dp/B01DM8N9HW/ref=cm_sw_em_r_mt_dp_U_AwGsDbVFZ3778

But it’s not powerful enough. Does anyone know motors are interchangeable? or have any recommendations of motors for use with uln2003?

I’m thinking about this: https://www.amazon.co.uk/UsongShine-Stepper-Stepping-Printer-insulated/dp/B07GLKQYWJ/ref=sr_1_4 but it has 4 wires not 5 so unsure how/if this would work.

Thanks!
Pete

1 Like

Try running the ones you have at 9v. I do and have no issues with the 90cm blinds I use.
I created a little board, used a buck converter to step down to 5v for the esp8266, but the power wires to the stepper run at full 9v. Running at 9v gives them more torque, but they do get warm :wink:
Buck I used is https://www.amazon.co.uk/gp/product/B01GJ0SC2C/ref=ppx_yo_dt_b_asin_title_o07_s00?ie=UTF8&psc=1
Rik

2 Likes

Thanks for this, I got a chance to test this out and actually connected up a 12V power supply. You’re right it does have more torque but unfortunately still not enough. My blinds are about 90cm wide by 180cm high so pretty long/heavy. Even though the material is pretty light weight they are just too big. So the motor in 12v mode was able to move the blind both ways but after a minute or two it just started slipping, when I touched the case to see if it was hot I almost burnt myself!

So still need to figure out, how to connect up a more powerful stepper motor to ESPHome! Alternatively I could connect up a second motor on the other end, but I think that’s going to get messy with wiring and ideally I should just get a more powerful stepper motor.

1 Like

Or use the one with a gear that is on thingiverse

Indeed I could also do that, although it would mean buying a 3D printer :grimacing: hmmm