Hi i want to control sg90 servo with esp32 via home assistant. I have this code bellow which is not working. Any help aprecieated.
esphome:
name: esp32-servo
board: esp32-s3-devkitc-1
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.0.123
gateway: 192.168.0.1
subnet: 255.255.255.0
api:
web_server:
port: 80
output:
- platform: ledc
pin: D2
id: servo_output
servo:
- id: my_servo
output: servo_output
min_level: 2%
max_level: 12%
sensor:
- platform: template
name: "Servo Angle"
id: servo_angle
lambda: |-
return id(my_servo).target;
update_interval: 1s
number:
- platform: template
name: "Servo Position"
id: servo_position
min_value: 0
max_value: 180
step: 1
set_action:
then:
- servo.write:
id: my_servo
level: !lambda 'return x / 180.0;'
- platform: template
name: "Move Servo"
optimistic: true
min_value: 0
max_value: 180
step: 10
set_action:
then:
- lambda: |
id(my_servo).write(x / 180.0);