
Unit Step16 是一款基于 STM32G031G8U6 微控制器的 16 位旋转编码器控制单元。它实时采集旋转编码器的 BCD 值,并通过板载 7 段显示器可视化显示 0-F 十六进制值。 该设备通过 I2C 通信,允许您配置旋转增量方向、显示操作模式、RGB LED 颜色和 I2C 地址,使得多个编码器单元可以在同一总线上使用。 凭借其简洁高效的设计,Unit Step16 提供可靠的物理交互和即时视觉反馈,非常适合智能交互设备(如智能家居控制面板)、控制界面(如音量旋钮、RGB 灯光控制、电机调速)以及 STEAM 教育硬件原型制作和教学。
步骤 1. 创建新设备

步骤 2. 创建设备名称
CONTINUE。
New Device Setup。
NEXT。
步骤 3. 选择设备类型
ESP32。
SKIP。
步骤 4. 开始编辑 YAML 文件
EDIT。我们可以通过 YAML 文件自定义设备功能。
以下是代码的核心部分。下面提供了相关的参考和说明。
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 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:
- 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:
- 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:
- 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;' INSTALL 进行烧录并等待完成。
SAVE 和 INSTALL,然后在弹出窗口中选择 Manual Download。
Factory format (Previously Modern)
CONNECT 连接设备。

INSTALL

Settings -> Device & services 检查设备。
Discover 部分找到相应的设备。

