Continuous Servo Motor Will Not Go Counter Clockwise

Hello all! My first post – I’ve gotten so much value from the forum so far!

I’ve setup a continuous servo motor on a NodeMCU board following instructions from the Servo Component section of ESPHome.

I have the automation and slider working and log data shows I’m able to send values of -1, 0, and 1 to my continuous servo just fine.

The problem is the servo itself will only turn clockwise when on either -1 or 1 values, and stops at 0.

I have also tested the servo and written some boring script in ArduinoIDE to ensure I can indeed turn the motor clockwise, stop it, counter clockwise, etc.

But I’d much rather have the whole thing live within Home Assistant/ESPHome.


    - service: control_servo
        level: float
        - servo.write:
            id: beer
            level: !lambda 'return level / 100.0;'

  - id: beer
    output: pwm_output
    idle_level: 0
    transition_length: 0s
    min_level: 3%
    max_level: 12%
    restore: true

  - platform: esp8266_pwm
    id: pwm_output
    pin: D4
    frequency: 50 Hz
    min_power: 0
    max_power: 0.09

Trigger (note: because it’s a continuous motor, only values -100, 0, and 100 are used):

#servo controller
        name: Servo Control
        initial: 0
        min: -100
        max: 100
        step: 100
        mode: slider


- id: beer
  alias: Beer Me
    platform: state
    entity_id: input_number.servo_control
    - service: esphome.beer_control_servo
        level: "{{ trigger.to_state.state | int }}"

ESPHome log:

[10:39:48][D][servo:062]: Servo new target: 1.000000
[10:39:48][D][servo:050]: Servo reached target
[10:39:49][D][servo:062]: Servo new target: 0.000000
[10:39:49][D][servo:050]: Servo reached target
[10:39:50][D][servo:062]: Servo new target: -1.000000
[10:39:50][D][servo:050]: Servo reached target
[10:39:51][D][servo:062]: Servo new target: 0.000000
[10:39:51][D][servo:050]: Servo reached target

The project is to create a servo-lifted platform to rise up and give me a beer when I’m in my sauna :smiley:

What’s working: turn clockwise on input value 100 (translated to 1 on ESPHome log), 0 to stop.
What’s not working: turn counter-clockwise on input value -100 (translated to -1 on ESPHome log), which simply moves the servo clockwise.

Anyone have any suggestions? Thank you!!

I would suspect that it is a code difference between the Arduino servo library and the ESPHome implementation for a continuous rotation servo.

I have noticed that there is some sensitivity to the duty cycle for the min level on an SG90 servo (this is an absolute servo, though). Have you experimented with reducing the min_level from 3%? I suspect that if the min_level is too large for your servo, it will just interpret the -1 value as a 0 (i.e. the -1 pulse is too wide). Also, is there a long wire length between the ESP and the servo?

Hi, no solution for you so far, but a question. How do you signal the servo that it should stop if it reaches top or bottom? Do you use two seperate limit switches or do you count the amount of circles your ESP did?