@keithcroshaw @Khalid_Abu_Hamza @Olivier974 @mr.sneezy @Drew.B
Hi All,
I’m hoping for some help - I’m trying to control a servo from an esp32 and have followed the guides, but I must be doing something wrong as the servo doesn’t move. I’ve setup esphome and tested with turning on an led via home assistant, which works, so I believe I’m okay for pin numbers etc. I’ve also previously tested controlling the servo directly from the esp32 via micropython and that worked, so I’m pretty happy with my wiring up etc.
I’m using AZDelivery ESP32 NodeMCU Dev Kit C WiFi WLAN CP2102 ESP32-WROOM-32D from Amazon UK. It isn’t listed in the board types. I’ve tried a few, including nodemcu with no luck.
Code in ESPHome - robogarage.yaml
esphome:
name: robogarage
platform: ESP32
board: esp32dev
# 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:
password: "abcdefg"
wifi:
ssid: "xxxxxxxx"
password: "xxxxxxxx"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Robogarage Fallback Hotspot"
password: "xxxxxxx"
captive_portal:
servo:
- id: my_servo
output: pwm_output
output:
- platform: ledc
id: pwm_output
pin: GPIO32
frequency: 50 Hz
Then, in my configuration.yaml I have:
input_number:
servo_control:
name: Servo Control
initial: 0
min: -100
max: 100
step: 1
mode: slider
automation:
- alias: Write Servo Value to ESP
trigger:
platform: state
entity_id: input_number.servo_control
action:
- service: esphome.robogarage_control_servo
data_template:
level: '{{ trigger.to_state.state | int }}'
and finally, the lovelace card:
type: entities
entities:
- input_number.servo_control
If anyone can see ANYTHING obvious (or not so obvious) that I have done incorrectly or misunderstood, I would be incredibly grateful for your thoughts.