Connect various UART devices over a multipoint/multidrop interface such as RS485 to an ESP8266 or ESP32 using the ESPHome framework.
- Control devices from and poll state updates to Home Assistant.
- State updates of default 500ms interval between devices.
- ESPHome 1.18.0 or greater
- All RS485 devices connected on the same bus must be using the same baud rate
This library should work on most ESP8266 or ESP32 platforms. It has been tested with the following MCUs:
- Generic ESP-01S board (ESP8266)
- WeMos D1 Mini (ESP8266)
- Generic ESP32 Dev Kit (ESP32)
- Chenyang RS485 Window Opener CP12, CP14, CP16, CP31, CP95
- Dooya Curtain RS485 Motor DT82TV
- Dooya Shade RS485 Motor DM35EQL/J & DM45EQL/J
- GM40 RS485 Curtain Motor
Connect the RS485 devices and microcontroller together. You can use a UART-RS485 board such as the SP3485 to interface the microcontroller to the RS485 devices.
The code in this repository makes use of the external components feature in the 1.18.0 version of ESPHome.
v1.1.0 and above requires ESPHome 2025.5.0 or higher.
Add the uart_multi component along with the devices you need to your ESPHome config:
external_components:
- source: github://loongyh/esphome-rs485
components: [ uart_multi, chenyang, dooya, ... ]Define the UART pins your UART-RS485 board is connected to, as well as the baud rate of the RS485 devices:
uart:
tx_pin: 17
rx_pin: 16
baud_rate: 9600Chenyang:
cover:
- platform: chenyang
name: Chenyang Window
address: 0xFF
device_class: window
# Optional binary sensor for when window position is unknown on startup.
# An automation can be triggered to open and close the window to initialize the positioning.
binary_sensor:
- platform: chenyang
name: Chenyang Window Unknown Position
# Optional setting entities to configure the window opener on the frontend.
button:
- platform: chenyang
type: get_status
name: Chenyang Window Get Status
- platform: chenyang
type: factory_reset
name: Chenyang Window Factory Reset
- platform: chenyang
type: restart
name: Chenyang Window Restart
number:
- platform: chenyang
type: speed
name: Chenyang Window Speed
- platform: chenyang
type: torque
name: Chenyang Window Torque
switch:
- platform: chenyang
type: led_indicator
name: Chenyang Window LED Indicator
- platform: chenyang
type: invert_direction
name: Chenyang Window Invert Direction
- platform: chenyang
type: pull_to_start
name: Chenyang Window Pull to Start
- platform: chenyang
type: close_on_power_on
name: Chenyang Window Close on Power On
- platform: chenyang
type: open_on_power_on
name: Chenyang Window Open on Power On
- platform: chenyang
type: rain_sensor
name: Chenyang Window Rain Sensor
- platform: chenyang
type: rain_invert_direction
name: Chenyang Window Rain Invert Direction
- platform: chenyang
type: lock
name: Chenyang Window Lock
- platform: chenyang
type: power_off_unlock
name: Chenyang Window Power Off UnlockDooya:
cover:
- platform: dooya
name: Dooya Curtain
address: 0xFEFE
device_class: curtain
# Optional binary sensor for when curtain position is unknown on startup.
# An automation can be triggered to open and close the curtain to initialize the positioning.
binary_sensor:
- platform: dooya
name: Dooya Curtain Unknown Position
# Optional setting entities to configure the curtain on the frontend.
button:
- platform: dooya
type: get_status
name: Dooya Curtain Get Status
- platform: dooya
type: clear_positioning
name: Dooya Curtain Clear Positioning
- platform: dooya
type: factory_reset
name: Dooya Curtain Factory Reset
switch:
- platform: dooya
type: invert_direction
name: Dooya Curtain Invert Direction
- platform: dooya
type: pull_to_start
name: Dooya Curtain Pull to StartGM40:
cover:
- platform: gm40
name: GM40 Curtain
address: 0x00
device_class: curtain
# Optional binary sensor for when curtain position is unknown on startup.
# An automation can be triggered to open and close the curtain to initialize the positioning.
binary_sensor:
- platform: gm40
name: GM40 Curtain Unknown Position
# Optional setting entities to configure the curtain on the frontend.
button:
- platform: gm40
type: get_status
name: GM40 Curtain Get Status
- platform: gm40
type: factory_reset
name: GM40 Curtain Factory Reset
- platform: gm40
type: restart
name: GM40 Curtain Restart
number:
- platform: gm40
name: GM40 Curtain Speed
switch:
- platform: gm40
type: invert_direction
name: GM40 Curtain Invert Direction
- platform: gm40
type: led_indicator
name: GM40 Curtain LED IndicatorOn ESP8266 you'll need to disable logging to serial because it conflicts with the UART:
logger:
baud_rate: 0On ESP32 you can change hardware_uart to UART1 or UART2 and keep logging
enabled on the main serial port.
Below is an example configuration which will include wireless strength
indicators and permit over the air updates. You'll need to create a
secrets.yaml file inside of your esphome directory with entries for the
various items prefixed with !secret.
substitutions:
name: rs485test
friendly_name: Test RS485
esphome:
name: ${name}
platform: ESP8266
board: esp01_1m
# Boards tested: ESP-01S (ESP8266), Wemos D1 Mini (ESP8266); ESP32 Wifi-DevKit2
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${friendly_name} Fallback Hotspot"
password: !secret fallback_password
captive_portal:
# Enable logging
logger:
# ESP8266 only - disable serial port logging, as the HeatPump component
# needs the sole hardware UART on the ESP8266
baud_rate: 0
# Enable Home Assistant API
api:
ota:
# Sync time with Home Assistant.
time:
- platform: homeassistant
id: homeassistant_time
external_components:
- source: github://loongyh/esphome-rs485
uart:
tx_pin: 17
rx_pin: 16
baud_rate: 9600
uart_multi:
update_interval: 500ms
cover:
- platform: dooya
name: Dooya Shade
address: 0xFEFE
device_class: shade
- platform: chenyang
name: Chenyang Window
address: 0xFF
device_class: window
- platform: gm40
name: GM40 Curtain
address: 0x00
device_class: curtain- hardware_uart (Optional): the hardware UART instance to use for
communcation with the multipoint bus. On ESP8266, only
UART0is usable. On ESP32,UART0,UART1, andUART2are all valid choices. Default:UART0 - baud_rate (Required): Serial BAUD rate used to communicate with the multipoint bus.
- update_interval (Optional, time): The delay polling for state updates between each device, in milliseconds. Smaller values at the expense of a busier bus and more collisions. Larger values at the expense of slower state updates. Default: 500ms
Happy to accept contributions of new multipoint devices.