pdf-icon

Unit Step16 Home Assistant Integration

Introduction

Unit Step16 is a 16-position rotary encoder control unit based on an STM32G031G8U6 microcontroller. It collects the BCD value of the rotary encoder in real time and visualizes the 0–F hexadecimal value via the on-board 7-segment display. The device communicates over I2C and allows you to configure the rotation increment direction, display operating mode, RGB LED color, and I2C address, enabling multiple encoder units to be used on the same bus. With its concise and efficient design, Unit Step16 provides reliable physical interaction and instant visual feedback, making it ideal for smart interactive devices (e.g. smart-home control panels), control interfaces (e.g. volume knobs, RGB lighting control, motor speed regulation), and STEAM education hardware prototyping and teaching.

Preparation

Tip
In this tutorial, the firmware is compiled and uploaded with ESPHome 2026.1.2. If you encounter compile/upload issues, consider switching ESPHome to this version.

Step 1. Create New Device

  • Click the green button in the lower right corner to create a device.

Step 2. Create Device Name

  • Click CONTINUE.

  • Click New Device Setup.

  • Enter the name of the device and click NEXT.

Step 3. Choose Device Type

  • Click ESP32.

  • Click SKIP.

Step 4. Start Edit YAML File

  • Click EDIT. We can customize device functionality through YAML files.

Device Setup

The following is the core part of the code. Relevant references and explanations are provided below.

External Components Configuration

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 Configuration

i2c:
  - id: bsp_iic
    scl: GPIO32
    sda: GPIO26
    scan: True

Sensor Configuration

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' ]

Output Configuration

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

Light Configuration

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  

Number Configuration

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;'

Firmware Build

  • Click INSTALL again to flash and wait for it to complete.

  • After making changes, click SAVE and INSTALL in the top-right corner, then choose Manual Download in the popup.

  • After the firmware compilation is complete, click Download and select Factory format (Previously Modern)

Tip
Click Unit Step16 to view the complete example configuration. The first build may take a while, depending on the performance of the Home Assistant host and network quality.

Firmware Upload

  • Connect the device to your host via a USB Type‑C cable. Open ESPHome Web and click CONNECT to connect to the device.

  • Locate the corresponding serial port number

  • Click INSTALL

  • Select the previously compiled firmware to upload.

Tip
Please note that after the download is completed, the device must be reset.

Home Assistant Integration

  • Click Settings -> Device & services to check the device.

  • We can find the corresponding device in the Discover section.

  • After adding the device, the data will be displayed correctly.

  • Finally, we add these entities to the Dashboard, and the following shows their display results.

On This Page