Unit Encoderは、I2Cバスを介してエンコーダ値、ボタン状態、RGB LED 制御を提供します。
| 項目 | 情報 |
|---|---|
| 製品名 | Unit Encoder |
| SKU | U135 |
| 主な機能 | エンコーダ値、ボタン状態、RGB LED 制御 |
| 通信インターフェース | I2C |
| デフォルトI2Cアドレス | 0x40 |
| ESPHomeコンポーネント | m5unit_encoder(外部コンポーネント) |
| ESPHomeバージョン要件 | 2026.4.5 以降 |
YAMLファイルにExternal Componentsの設定を追加して、Unit Encoderコンポーネントを読み込みます。
external_components:
- source: github://m5stack/esphome-yaml/components
components: [m5unit_encoder]
refresh: 0s Sensorを追加してエンコーダのカウント値を読み取ります。このidは、ボタンおよびLEDのOutputコンポーネントから参照できます。
sensor:
- platform: m5unit_encoder
id: unit_encoder_1
name: "Encoder Value" デフォルト単位はsteps、デフォルトの更新間隔は100ms、デフォルトのI2Cアドレスは0x40です。
主なパラメータ:
| パラメータ | 説明 |
|---|---|
| id | 他のUnit Encoderコンポーネントから参照するコンポーネントID。 |
| ame | Home Assistantに表示するエンティティ名。 |
Binary Sensorを追加してエンコーダボタンの状態を読み取ります。m5unit_encoder_idには、Sensorコンポーネントで定義したIDを指定してください。
binary_sensor:
- platform: m5unit_encoder
m5unit_encoder_id: unit_encoder_1
name: "Encoder Button" Outputを追加し、赤・緑・青のLEDチャンネルを個別の出力に割り当てます。これらの出力をLightコンポーネントから参照します。
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 主なパラメータ:
| パラメータ | 説明 |
|---|---|
| m5unit_encoder_id | 関連付けるSensorコンポーネントのID。 |
| led_index | LEDインデックス。0または1。 |
| channel | カラーチャンネル。 |
| ed、green、blueのいずれか。 | |
| id | Lightコンポーネントから参照する出力 ID。 |
Lightを追加し、3つのカラーチャンネルを1つのRGBライトエンティティにまとめます。
light:
- platform: rgb
name: "Encoder LED 0"
red: led0_red
green: led0_green
blue: led0_blue 主なパラメータ:
| パラメータ | 説明 |
|---|---|
| ame | Home Assistantに表示するライトエンティティ名。 |
| ed | 赤チャンネルのOutput ID。 |
| green | 緑チャンネルのOutput ID。 |
| blue | 青チャンネルのOutput ID。 |
external_components:
- source: github://m5stack/esphome-yaml/components
components: [m5unit_encoder]
refresh: 0s
i2c:
sda: GPIOXX
scl: GPIOXX
scan: true
sensor:
- platform: m5unit_encoder
id: unit_encoder_1
name: "Encoder Value"
binary_sensor:
- platform: m5unit_encoder
m5unit_encoder_id: unit_encoder_1
name: "Encoder Button"
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
light:
- platform: rgb
name: "Encoder LED 0"
red: led0_red
green: led0_green
blue: led0_blue
- platform: rgb
name: "Encoder LED 1"
red: led1_red
green: led1_green
blue: led1_blue