Servo don't work

Hi,
I try to use my servo motor to esphome.io but it’s dont move
I followed esphome.io doc but servo don’t work.

My config:

Configuration YAML
# Home Assistant configuration
input_number:
  servo_control:
    name: Servo Control
    initial: 0
    min: -100
    max: 100
    step: 1
    mode: slider
 
 
Automation YAML
- alias: Write Servo Value to ESP
  trigger:
  - entity_id: input_number.servo_control
    platform: state
  action:
  - service: esphome.servo_moteur_control_servo
    data_template:
      level: '{{ trigger.to_state.state | int }}'
 
Esphome 
 
esphome:
  name: servo_moteur
  platform: ESP8266
  board: nodemcuv2
 
wifi:
  ssid: "my_SSID"
  password: "my_password"
 
 
 
captive_portal:
 
# Enable logging
logger:
  
 
# Enable Home Assistant API
api:
  services:
    - service: control_servo
      variables:
        level: float
      then:
        - servo.write:
            id: my_servo
            level: !lambda 'return level / 100.0;'
 
ota:
# Example configuration entry
servo:
  - id: my_servo
    output: pwm_output
   
 
# Example output platform
# On ESP32, use ledc output
output:
  - platform: esp8266_pwm
    id: pwm_output
    pin: D8
    frequency: 50 Hz

Regards
Giloris

1 Like

@giloris Did you ever get this working? I’m trying to control a servo but not having any luck

1 Like

Hi
I didnt found solution and anybody answer and help me !
What is your project ?
Regards
Giloris

1 Like

Hello no solution?
@giloris @Erickk

Hello! What version of ha are you running?
I am using the Servo setup on esp with ha 107 and it’s working…

1 Like

Hi
My version is 0.107.7
Can you send me your differents files (yaml and on esphome ) ?
Regards
Giloris

1 Like

Hi… this is my esphome.yalm

esphome:
  name: 'robotarm'
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: 'wifi-ssid'
  password: 'password'
  
  manual_ip:
    static_ip: 192.168.100.176
    gateway: 192.168.100.2
    subnet: 255.255.255.0

api:
  services:
    - service: control_servo
      variables:
        level: float
      then:
        - servo.write:
            id: my_servo
            level: !lambda 'return level / 100.0;'
web_server:
  port: 80

logger:

output:
  - platform: esp8266_pwm
    id: pwm_output
    pin: D4
    frequency: 50 Hz
servo:
  - id: my_servo
    output: pwm_output

And in home assistant i have this in configuration.yalm

# Servo Control     
input_number:
  servo_control:
    initial: 0
    min: -100
    max: 100
    step: 1
    mode: slider

and the automation to control it in automations.yalm

- id: '1588946703480'
  alias: Write Servo Value to ESP
  description: ''
  trigger:
  - entity_id: input_number.servo_control
    platform: state
  condition: []
  action:
  - data_template:
      level: '{{ trigger.to_state.state | int }}'
    service: esphome.robotarm_control_servo
2 Likes

Hi
Thank you for your help. Files and configuration are similar
I use an ESP8266 nodemcu V2 board and i m connecting to Pin 8 (pwm)
I will try another Pin and test it. How do you connect servo to your board ?
Your servo use 3,3V or 5V and what power pin do you use ?
Regards
Giloris

1 Like

I use male to female 30cm pin cables to connect it on the wemos d1 mini pins.
I use 5v pin because my servo is a big one 5v Servo but when I was doing tests it also worked with 3.3v.

1 Like

Hi
How is your Battery power ?
USB 5v or indépendant power battery 5v or more
Regards
Giloris

1 Like

It’s a wall plug to usb, 5v 2A with 1m usb to micro usb cable.

1 Like

Hi
Thank You to your help
I will try it
Regards
Giloris

1 Like

Hi
I have same problem. Can you send me a short video or a picture ?
Regards
Giloris

Can you take a picture of how you connected it all, or draw a schematic of the circuit?

Hi
When i connect servo it comes at max and i hear a noise ,when i move slider it dont move. Need i change a parameter ? Could you see my configuration at the top of the page ?
I use ESP8266 nodemcu V3 and i connect servo to
VCC 5V --> RED cable
GND --> BROWN cable
D4 (for PWM) --> Orange cable
Regards
Giloris

hi
This is my config

input_number:
  servo_control:
    name: Servo Control
    initial: 0
    min: -100
    max: 100
    step: 1
    mode: slider

Esphome config :

esphome:
  name: servo_moteur
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: "xxxxxx"
  password: "xxxxxxx"





# Enable logging
logger:
  

# Enable Home Assistant API
api:
  services:
    - service: control_servo
      variables:
        level: float
      then:
        - servo.write:
            id: my_servo
            level: !lambda "return level / 100.0;"




# Example configuration entry
servo:
  - id: my_servo
    output: pwm_output
   

# Example output platform
# On ESP32, use ledc output
output:
  - platform: esp8266_pwm
    id: pwm_output
    pin: D4
    frequency: 50 Hz
Automation :
- id: 6209852ff5b8426d9992076a6052c814
  alias: Write Servo Value to ESP
  trigger:
  - entity_id: input_number.servo_control
    platform: state
  condition: []
  action:
  - data_template:
        level: '{{ trigger.to_state.state | int }}'
    service: esphome.servo_moteur_control_servo 

Regards
Giloris

So you use the VCC pin of the 8266? That won’t work.
You need to get the 5 volts before the 8266.

The 8266 has a limited output and no matter how large the USB charger/power supply is the VCC pin can only output the limited mAh.
If you instead have the 8266 and the servo in parallel then the servo will be able to get all the current it needs (and you offload the 8266).

Hi
I use ESP8266 extension board with 5v (4,67v around) before ESP8266
My servo is Connect to 5v pin and gnd
Only signal is Connect to d4 on ESP8266 nodemcu.
Do you see
My home assistant config ?
Regards
Gilorisimage

No. That picture is very small…

image