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.
ESPHome YAML:
api:
services:
- service: control_servo
variables:
level: float
then:
- servo.write:
id: beer
level: !lambda 'return level / 100.0;'
servo:
- id: beer
output: pwm_output
idle_level: 0
transition_length: 0s
min_level: 3%
max_level: 12%
restore: true
output:
- 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
input_number:
servo_control:
name: Servo Control
initial: 0
min: -100
max: 100
step: 100
mode: slider
automations.yaml
- id: beer
alias: Beer Me
trigger:
platform: state
entity_id: input_number.servo_control
action:
- service: esphome.beer_control_servo
data_template:
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
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!!