Creating Component for Waveshare Servo Driver Board with ESP32

I have the LEDs and display working with current ESPHome components, but I think I need to make a component for controlling the serial servos. The Arduino code is all available at GitHub - waveshare/Servo-Driver-with-ESP32: The Web app example for Servo Driver with ESP32., but it is a little above my head. It doesn’t seem like it would take too much for someone that has experience creating ESPHome components. Maybe that is a big assumption. Anyone willing to help?

esphome:
  name: servo-control

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: ********

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "servo-control Fallback Hotspot"
    password: ******************

captive_portal:

# Declare the I2C bus to which the OLED display is connected
i2c:
  sda: GPIO21
  scl: GPIO22
  scan: True

# Declare the LED strip connected to GPIO23 with 2 pixels
light:
  - platform: fastled_clockless
    chipset: NEOPIXEL
    pin: GPIO23
    num_leds: 2
    name: "led_strip_1"

# This was suggested by ChatGPT, but obviously the waveshare_servo platform does not exist.
#output:
#  - platform: waveshare_servo
#    id: serial_servo_1
#    uart_id: uart0
#    baud_rate: 115200
#    servo1_pin: GPIO18
#    servo2_pin: GPIO19

# Declare the OLED display and show the IP address on it
font:
  - file: "fonts/FreeMonoBold.ttf"
    id: free_mono_bold_16
    size: 16

display:
  - platform: ssd1306_i2c
    model: "SSD1306 128x32"
    address: 0x3C
    rotation: 0
    lambda: |-
      it.printf(0, 0, id(free_mono_bold_16), "IP Address:");
      it.printf(0, 16, id(free_mono_bold_16), "%s", WiFi.localIP().toString().c_str());

I got this working using an Arduino sketch and MQTT. I couldn’t figure out how to convert it to ESPHome. But if anyone wants to help I am still interested in using ESPHome for this and making custom components in general. I didn’t find the tutorial very helpful.

1 Like