This tutorial uses the Unit Encoder rotary encoder with an Atom Lite controller and integrates it into Home Assistant to enable knob value reading, button detection, and RGB LED control.
CONTINUE.
New Device Setup to enter the device creation wizard.
NEXT.
Use recommended settings, then select ESP32. In the details panel, find and select Unit Encoder, then click NEXT.
SKIP to skip the encryption key setup.
EDIT to open the YAML configuration page and customize the device.
Add the External Components configuration to the YAML file to load the Unit Encoder driver.
external_components:
- source: github://m5stack/esphome-yaml/components
components: [m5unit_encoder]
refresh: 0s Add the I2C component and configure the communication pins between the Unit Encoder and Atom Lite.
i2c:
sda: GPIO26
scl: GPIO32
scan: true Add the Sensor component to read the encoder rotation value.
sensor:
- platform: m5unit_encoder
id: unit_encoder_1
name: "Encoder Value" Add the Binary Sensor component to detect encoder button press events.
binary_sensor:
- platform: m5unit_encoder
m5unit_encoder_id: unit_encoder_1
name: "Encoder Button" Add the Output component to map each color channel of the two SK6812 RGB LEDs as individual outputs for use by the Light component.
output:
- platform: m5unit_encoder
m5unit_encoder_id: unit_encoder_1
led_index: 0
channel: red
id: led0_red
- platform: m5unit_encoder
m5unit_encoder_id: unit_encoder_1
led_index: 0
channel: green
id: led0_green
- platform: m5unit_encoder
m5unit_encoder_id: unit_encoder_1
led_index: 0
channel: blue
id: led0_blue
- platform: m5unit_encoder
m5unit_encoder_id: unit_encoder_1
led_index: 1
channel: red
id: led1_red
- platform: m5unit_encoder
m5unit_encoder_id: unit_encoder_1
led_index: 1
channel: green
id: led1_green
- platform: m5unit_encoder
m5unit_encoder_id: unit_encoder_1
led_index: 1
channel: blue
id: led1_blue Add the Light component to control the two built-in SK6812 programmable RGB LEDs on the Unit Encoder.
light:
- platform: rgb
name: "LED 0"
red: led0_red
green: led0_green
blue: led0_blue
- platform: rgb
name: "LED 1"
red: led1_red
green: led1_green
blue: led1_blue Key parameter descriptions:
| Parameter | Description |
|---|---|
m5unit_encoder_id | Links to the corresponding m5unit_encoder sensor instance ID |
led_index | LED index, 0 or 1, corresponding to the two SK6812 LEDs |
channel | Color channel: red, green, or blue |
SAVE in the top-right corner to save the configuration, then click INSTALL.
Manual Download.
Download and select Factory format (Previously Modern) to save the firmware locally.
CONNECT.
INSTALL.
Settings > Devices & Services to open the integration management page.
Discovered section, find the online Unit Encoder device, click CONFIGURE, and follow the prompts to complete the setup.
