I have esp32 and MG9666 servo that I cannot get to work together. I have read the espHome pages on Servo and ledc. LEDC and all of the similar threads on the community… nine of which give clear resolution.
- The esp32 is connected via USB to my computer.
- The Servo has independent 5 V power supply.
- The esp32 ground, the independent 5v ground and the Servo ground are all connected together
- The Servo Signal cable is connected to GPIO23 ( I have also tried it in other GPIO pins just in case).
- I have followed the code and guidelines (although these are no many years old) provided by @Sitek Servo Example and used successfully by many (although most seem to use D1Mini and the 8266 platform)
- I have zero response from the Servo.
One of you - far smarter than me - will probably spot my basic error, I hope you can as it is driving me nuts!
My Servo.yaml file is:
esphome:
name: blast-gatea1
friendly_name: blast-gateA1
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "For me to know"
services:
- service: control_servo
variables:
level: float
then:
- servo.write:
id: my_servo
level: !lambda 'return level / 100.0;'
ota:
password: "also for me to know"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Blast-Gatea1 Fallback Hotspot"
password: "still a secret"
captive_portal:
servo:
- id: my_servo
output: pwm_output
auto_detach_time: 2s
output:
- platform: ledc
id: pwm_output
pin: GPIO23
frequency: 50 Hz
In my main configuration.yaml I have added:
input_number:
servo_control:
initial: 0
min: -100
max: 100
step: 1
mode: slider
and in my automations .yaml I have added:
- id: '1688163524437'
alias: slider
description: ''
trigger:
- platform: state
entity_id:
- input_number.servo_control
condition: []
action:
- service: esphome.blast_gatea1_control_servo
data_template:
level:'{{ trigger.to_state.state | int }}'
mode: single