Stepper Motor with ESPHome wont work

Hello Everyone,

Im using ESPHome for the first time and I want to connect a stepper motor to it. The blue LED on the ESP8266 flashes when I move the slider in HA but the motor does not rotate. All it does is get hot. Below is my setup, code, and troubleshooting. Any advice would be greatly appreciated. Thanks.

Setup:

  • ESP8266 connected to a rpi using USB
  • ESP8266 connected to ULN2003
    • Pin D0 to IN1
    • Pin D1 to IN2
    • Pin D2 to IN3
    • Pin D3 to IN4
  • ULN2003 connected to transformer (12v DC, 1A)
  • ULN2003 has jumper (the 2 pins next to the power in)

Code in HA config:

input_number:
  stepper_control:
    name: Stepper Control
    initial: 0
    min: -1000
    max: 1000
    step: 10
    mode: slider
automation 3:
  - alias: Write Stepper Value to ESP
    trigger:
      platform: state
      entity_id: input_number.stepper_control
    action:
      - service: esphome.main_bedroom_main_window_shade_curtain_control_stepper
        data_template:
          target: '{{ trigger.to_state.state | int }}'

Code in ESPHome config:

esphome:
  name: main_bedroom_main_window_shade_curtain
  platform: ESP8266
  board: nodemcuv2
wifi:
  ssid: "Not showing"
  password: "Not showing"
# Enable logging
logger:
# Enable Home Assistant API
api:
  services:
    - service: control_stepper
      variables:
        target: int
      then:
        - stepper.set_target:
            id: left_shade
            target: !lambda 'return target;'
ota:
stepper:
  - platform: uln2003
    id: left_shade
    sleep_when_done: false
    pin_a: D0
    pin_b: D1
    pin_c: D2
    pin_d: D3
    max_speed: 50 steps/s
    # Optional:
    acceleration: inf
    deceleration: inf

I have also setup ESPHome in the integration section.

Troubleshooting and observations:

  • If I connect the ULN2003 to power with the jumper on without it being connected to the ESP8266 the motor gets hot. If I take the jumper off the motor does not get hot. This is the same result when the ESP8266 connected to the ULN2003.
  • The ULN2003 is getting the 12v DC.
  • When the ULN2003 is connected to the ESP8266 and the blue LED is flashing the ULN2003 does not flash any of the 4 red LEDs it has.
  • If the ULN2003 is connected to the 12v DC and the jumper is on and I put a meter on the pins where the motor connects I get 12v DC on all the pins at the same time non stop. (pin 1 with pin 2, pin 1 with pin 3, pin 1 with pin 4, and pin 1 with pin 5).

Hello Everyone,

Any ideas. Does this look correct even?

I don’t know if I am so late, did you get it work? I was trying yesterday the stepper component with the ULN2003 driver. My configuration is pretty much the same as yours, but:

  • ULN2003 connected to transformer (5v DC, 800mA)
  • At first, trying to connect a NodeMCU 8266 to the same transformer, but later I separated it because I experienced some issues (perhaps 800mA not enough for both).

Finally I made it work, but the motor gets extremely hot, so I decided to try this config of the stepper:

sleep_when_done: true

Now the motor temperature is normal and it seems disconnected when not using, which is good.

Still having some issues with the correct movement of the stepper when I use the HA slider, but that’s another issue.

1 Like

Hello I also same experience, but motor doesn’t move and a little noisy, I just use esp32 vcc power, should I use another power? I am very confused why my configuration is not working

I would try with a separate power supply for the stepper, I told that here (Stepper motors not working).

I also tried and gave up on this. I am not able to see the service esphome.xxxxx.control_servo under dev/services in Home Assistant.
No errors whatsoever.
image

Same issue here but with the A4988 driver. My hardware is tested working (using an arduino sketch to move the stepper before flashing back to esphome). I followed the steps in the tutorial to add the stepper config to the ESP, then added the input_number and automation sections to the HA config.

The HA log shows calling the Write stepper value to ESP script, but nothing happens. The esp log shows no record of the event. I can set up and use the switch function with an led, but I can’t get the stepper function to work on the same device.

Has anyone been able to get a stepper to work at all? If so, can you post your config?

Hey Puneit_Thukral
Have the same issiue as you. Cant find the “service” in HA. Have you found a solution?

Regards
Daniel

Hey Daniel,
I gave up the project as had hit a roadblock. Can try again this weekend and report.
Regards
Puneit

Thanks for your fast reply.
That would be nice. I would try it this evening as well one more time.

Regards
Daniel

1 Like

Hey @Puneit_Thukral
I have found the “service” :slight_smile: I forgot to integrate my ESPhome-Device. After i integreated the ESPhome-Device manually i was able to find the Service under the Devolepement-Tab.

Now i can call the service. Next step: Integrate the Service in Scripts/Automations.

Regards
Daniel

1 Like

Thanks for the update. While I didn’t find an opportunity to work on it, my friend @easwaran83 had success with it couple of days back. He is not able to use the service in automations in HA but he is able to do it on Nodered.

1 Like

I’m also stuck with an a4988. I followed the set-up, wired it up with separate power, all good. at first, it would move almost a full rotation but as I tried the slider, now I only get small moves and the a4988 makes a light humming sound. Would love to hear from any who has this working. It looks neat!

Hello
I am trying to install Nema 17 with ESP8266 12-E NodeMCU.
The idea is to use ESPHome for HA but does not make it work by using the function call service id (my_stepper) .set_target (250);

Has anyone succeeded?

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

stepper:
  - platform: a4988
    id: my_stepper
    step_pin: D0
    dir_pin: D1
    max_speed: 250 steps/s

    # Optional:
    sleep_pin: D2
    acceleration: inf
    deceleration: inf