Stepper with Endstop

Is it possible to use a stepper with an endstop in ESPHome?

I want to motorise a blind using a stepper. Because we have fairly frequent power issues I would like to set it to a known position at boot. Desired sequence something like:

  • power restored
  • 5S delay
  • stepper slowly moves blind up until top (and only) endstop reached
  • ‘home’ position set

The blind could then work in stepper only mode (by setting target positions) or could use stepper mode down and stop at the endstop for up.

The problem I’m facing is how to stop the stepper when the endstop is triggered, so that the home position can be assigned.

Has anyone cracked this, please?

Thanks.

Richard

The endstop is a binary sensor - automate whatever you like from it.

Thanks, @nickrout - what I meant was how do you stop the stepper moving when it activates the endstop and the target position is still not attained? I’m confused what commands would do this.

I assume you would run https://esphome.io/components/stepper/index.html#stepper-set-speed-action with speed 0.

Figured it!

When the binary sensor makes I use this code snippet:

      then:
        - light.turn_on: led1
        - stepper.report_position:
            id: my_stepper
            position: 0
        - stepper.set_target:
            id: my_stepper
            target: 0

Basically setting the position to 0 and then immediately calling that as a target position.

(edited to fix typo)

1 Like