Having problems getting a servo to work

hi All,

I’m trying to get a servo to work with a D1 mini, ultimately it will control the tilt on my blinds should I get it to work.

to the best of my ability I have followed the instructions and tutorials found both on here and on youtube (Dr Zzzs) but I can’t get the servo to move.
all and any help is greatly appreciated…

my D1 mini has this…

  name: blind-servo
  friendly_name: Blind Servo
  platform: esp8266
  board: d1_mini

# Enable logging

# Enable Home Assistant API
    - service: control_servo
        level: float
        - servo.write:
            id: stairs_tilt
            level: !lambda 'return level /100.0;'

  password: "*************"

  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
    ssid: "Blind-Servo Fallback Hotspot"
    password: "****************"


  - id: stairs_tilt
    output: 'pwm_output'

  - platform: esp8266_pwm #this is for the servo
    id: 'pwm_output'
    pin: GPIO2 #D4
    frequency: 50 Hz

in my configuration.yaml I have …

    name: Stair Blind
    initial: 0
    min: -100
    max: 100
    step: 1
    mode: slider

and in an Automation I have

id: 'stairblindtiltservoinput123459'
alias: stair blind tilt servo input
initial_state: true
- platform: state
  entity_id: input_number.stair_blind
- service: esphome.blind_servo_control_servo
    level: "{{ trigger.to_state.state | int }}"

I’ve added a slider to my dashboard using input_number.stair_blind

My Wireing is as follows

D1 mini connected to USB for power with cable on D4 to orange cable on servo, gnd is connected to gnd (brown) on servo and negative on external power 6.99v.

12v 3a power supply is connected to a buck stepdown converter set to 6.99v positive of the 6.99v is connected to (red) positive of Servo, negative of 6.99v is connected to GND on D1 mini and GND (brown) of servo.

when I try to move the slider on HA the servo does not move… any help?

I’ll try to do a diagram of the wiring to make it easier to understand

thank you in advance

The servo component seems to expect -1.0 -> 1.0 but you send -100 -> 100

Thank you Koying,

all the examples I could find had it -100 → 100 but I’ve changed it to -1.0 → 1.0 at steps of 0.01 and there is no difference.

My mistake. I didn’t notice you divided by 100.0 in the esphome yaml.

thats ok, it was worth trying as everything I’ve tried hasn’t worked :wink:

I doubt it’ll make any difference, but you’re sending int from HA while expecting float in esphome.

Is your led (d1 mini has led on gpio2) pulsing when you try to move servo?

No, No pulsing. I assume that means its not getting a signal.

Is it d1 mini like defined??
What you get in log?
What if you change initial to 50, does it move once at reboot?

I tried making them both the same, int and float but nothing changed

You could try just with esphome.
Remove completely HA api section:

then add this after line board: d1_mini

  priority: 600
  - servo.write:
      id: stairs_tilt
      level: 70.0%
 - servo.write:
      id: stairs_tilt
      level: -70.0%

It should move servo at reboot even without connection to HA


For some reason (must be somethign I done), HA thought the D1 mini was encrypted so as the encryption code it was using wasn’t working it wouldn’t comunicate with the D1 mini.
I deleted the D1mini device under integrations and had HA re-find it. once it had done that everything works perfect!

now to sort what I though was the hard bit… conecting it to the blind and fitting the blind lol

thank you for all your help :grinning: