This tutorial will introduce how to use the Unit Step16 16-bit rotary encoder control unit integrated into Home Assistant to achieve knob value and light control.
In this tutorial, the firmware is compiled and uploaded using ESPHome 2026.1.2. If you encounter compilation/upload issues, please consider switching ESPHome to this version.
CONTINUE.
New Device Setup.
NEXT.
ESP32.
SKIP.
EDIT. We can customize device functions through the YAML file.
The following is the core part of the code. Related references and instructions are provided below.
Add External component:
external_components:
- source: github://m5stack/esphome-yaml/components
components: unit_step16
refresh: 0s
unit_step16:
id: my_step16
i2c_id: bsp_iic
address: 0x48 i2c:
- id: bsp_iic
scl: GPIO32
sda: GPIO26
scan: True Add Sensor component:
sensor:
- platform: unit_step16
unit_step16_id: my_step16
name: "Encoder Value"
update_interval: 100ms
on_value:
then:
- logger.log:
format: "Encoder value changed to: %.0f"
args: ["x"] Add Output component:
output:
- platform: unit_step16
id: led_brightness_output
unit_step16_id: my_step16
channel: led_brightness
- platform: unit_step16
id: rgb_brightness_output
unit_step16_id: my_step16
channel: rgb_brightness
- platform: unit_step16
id: rgb_red_output
unit_step16_id: my_step16
channel: rgb_red
- platform: unit_step16
id: rgb_green_output
unit_step16_id: my_step16
channel: rgb_green
- platform: unit_step16
id: rgb_blue_output
unit_step16_id: my_step16
channel: rgb_blue Add Light component:
light:
- platform: rgb
id: step16_rgb_light
name: "Step16 RGB Light"
red: rgb_red_output
green: rgb_green_output
blue: rgb_blue_output
restore_mode: ALWAYS_ON
default_transition_length: 0s
- platform: monochromatic
id: step16_led_display
name: "Step16 LED Display"
output: led_brightness_output
restore_mode: ALWAYS_ON
default_transition_length: 0s Add Number component:
number:
- platform: template
name: "RGB Brightness"
min_value: 0
max_value: 100
step: 1
optimistic: true
initial_value: 50
on_value:
then:
- output.set_level:
id: rgb_brightness_output
level: !lambda "return x / 100.0;" SAVE and INSTALL in the top right corner, then select Manual Download in the pop-up window.
Factory format (Previously Modern).
CONNECT to connect the device.
INSTALL.
INSTALL to upload.
Settings -> Device & services to check the device.
Discover section.