Hello all,
I currently switched from Tasmota to ESPHome so I am quite new to ESPHome.
Today I wanted to set up an ULN2003 Stepper motor with ESPHome but it is sadly not working as expected. I was following the official tutorial.
I have connected the esp and the motor to separated power sources. The ESP is running on 5V 1A and the motor on 5V 10A.
pin connections are:
- d0 -> IN1
- d1 -> IN2
- d2 -> IN3
- d3 -> IN4
This is the motor part from the esphome yaml:
# Enable Home Assistant API
api:
services:
- service: control_stepper
variables:
target: int
then:
- stepper.set_target:
id: my_stepper
target: !lambda 'return target;'
ota:
# Example configuration entry
stepper:
- platform: uln2003
id: my_stepper
pin_a: D0
pin_b: D1
pin_c: D2
pin_d: D3
max_speed: 250 steps/s
sleep_when_done: true
# Optional:
#acceleration: inf
#deceleration: inf
this is the part from the Home Assistant configuration.yaml:
input_number:
stepper_control:
name: Stepper Control
initial: 0
min: -1000
max: 1000
step: 1
mode: slider
automation:
- alias: Write Stepper Value to ESP
trigger:
platform: state
entity_id: input_number.stepper_control
action:
# Replace livingroom with the name you gave the ESP
- service: esphome.my_stepper
data_template:
target: '{{ trigger.to_state.state | int }}'
I already looked at the other thread but I cannot figure out what I am doing wrong here. The Esp is showing up in HA but when I drag the slider around nothing happens…
What could I be doing wrong?
Any help is greatly appreciated!!
So after further investigation I can say that the hardware is not the problem.
I tried the “OneStepAtATime” example from the “default stepper motor” library and here everything works as expected.
When using this example the led’s on the driver board also light up correctly and do not just flicker dimly.
I don’t really know how to use ESPHome but maybe anybody has now a clue on this?
I am still investigating this problem.
Any help is still very appreciated!
I now have changed the esp pins to: D5,6,7,8. My ESP home config now looks like this:
esphome:
name: esp8266_dario_curtain
platform: ESP8266
board: d1_mini
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_pwd
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp8266 Dario Curtain"
password: "fVG5TdIBQuyE"
captive_portal:
# 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:
stepper:
- platform: uln2003
id: my_stepper
pin_a: D5
pin_b: D6
pin_c: D7
pin_d: D8
max_speed: 250 steps/s
sleep_when_done: true
# Optional:
#acceleration: inf
#deceleration: inf
After this step one led on the steppers driver board was constantly lit up and no led’s were flickering. But the motor was heating up so I added the ‘‘sleep_when_done’’.
And I figured out that I had to move the ‘‘automation’’ part to the ‘‘automations.yaml’’
The Home Assistant configuration.yaml now contains this:
...
#Curtain stepper
input_number:
stepper_control:
name: Stepper Control
initial: 0
min: -1000
max: 1000
step: 1
mode: slider
and the automations.yaml this:
...
# stepper motor control
- alias: Write Stepper Value to ESP
trigger:
platform: state
entity_id: input_number.stepper_control
action:
# Replace livingroom with the name you gave the ESP
- service: esphome.esp8266_dario_curtain
data_template:
target: '{{ trigger.to_state.state | int }}'
But I always get following error from Home Assistant(taken from the logs):
Error while executing automation automation.write_stepper_value_to_esp. Service not found for call_service at pos 1: Unable to find service esphome/esp8266_dario_curtain
I am clueless. Why does it not find the ESP? I have integrated it in Home Assistant. Or do I use the wrong name?