ESPhome Stepper motor yaml issues

Greetings everyone.

I would like your help on an issue I am facing with integrating a stepper motor to my home assistant through esphome.
The Idea is to utilize it as a ‘’switchbot’’ component to press a button on an old air conditioner and learn through the prosses.

The issue I am facing is that although I thing I have followed the esphome instructions for the setup I am missing something I cannot think about.

This is the code I have written in the yaml file:

esphome:
  name: esp-step-motor
  friendly_name: ESP step motor

esp8266:
  board: nodemcuv2

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "aMSilZzisTYbAiZiOjG8hJYWo03LiZVZH2gyhhLElm0="

ota:
  password: "77d955594eb5f5c11f7de45ea3d7fff7"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp-Step-Motor Fallback Hotspot"
    password: "asfsdgsjdty"

captive_portal:

stepper:
  - platform: uln2003
    id: my_stepper_switch
    pin_a: GPIO5
    pin_b: GPIO4
    pin_c: GPIO14
    pin_d: GPIO12
    max_speed: 250 steps/s
    sleep_when_done: true #Puts the stepper to sleep to reduce power consumption and heat
    acceleration: inf
    deceleration: inf

number:
  - platform: template
    name: Stepper Control
    min_value: -100
    max_value: 100
    step: 1
    set_action:
      then:
        - stepper.set_target:
            id: my_stepper_switch
            target: !lambda 'return x;'
button:
  - platform: template
    name: "Stepper Press"
    on_press:
      then:
          - logger.log: Button Pressed
          - stepper.report_position:
              id: my_stepper_switch
              position: 0          
          - stepper.set_target:
              id: my_stepper_switch
              target: 500

I have performed the wiring as following:

I am getting these entities in home assistant:

Unfortunately, the motor is not moving at all.

The only thing I can think of is that may I need to change this part of the code

stepper:
  - platform: uln2003
    id: my_stepper_switch
    pin_a: GPIO5
    pin_b: GPIO4
    pin_c: GPIO14
    pin_d: GPIO12

with the following

stepper:
  - platform: uln2003
    id: my_stepper_switch
    pin_a: d1
    pin_b: d2
    pin_c: d5
    pin_d: d6

Although I did change, I had no luck.

To verify that have an operational stepper motor and uln2003 board, I have connected them to an Arduino uno I have around and tested is successfully with one of the examples. I have also tested the setup with a different nodemcu v2.1 esp8266.

Any help is much appreciated.

Thank you for your time in advance.

D1 and GPIO5 are the same thing and either is fine. What do the logs say? Its probably a blessing the stepper isnt working anyway. There are far better ways to make it “smart” and a stepper motor pushing a button is at the bottom of the list.

Why not pop off the cover and wire a relay to the wires that for the AC button? Much simpler, reliable, cleaner looking than having all that mess right on the control area of the AC.

Thank you for your time!

Unfortunately, the house is a rental home, and I cannot pop the cover. The best solution is to replace the Aircon with a new one, but this is not an option as well (owner’s responsibility).

In the end I will use the Arduino for the stepper control and connect a relay contact on the esp as an Arduino input to execute the move.

I have a whole weekend ahead.

I completely understand that. Im sure you wont like or want to hear but, its not a great idea to modify someone else’s property in a rental and for several reasons where you could potentially be personally liable for damage, fire, or god forbid something worse. Just be careful…

1 Like