Using the Module13.2 4In8Out ・ 使用 Module13.2 4In8Out
M5StackのModule13.2 4In8Outをコントローラーに接続する最小構成。配線とBOMつき。
この構成をエディタで開く・編集する →| 部品 | 役割 | ポート | リンク・価格 |
|---|---|---|---|
| M5Stack Core2 | Controller | grove_i2c, grove_analog, grove_uart, mbus | official page — $46.9 |
| Module13.2 4In8Out | module | mbus, i2c, terminal_block | official page — $16.95 |
M5Stack Core2とModule13.2 4In8OutをM-Busで接続し、8チャンネルのMOSFET出力と4チャンネルの接点入力をI2C制御するための最小構成の配線ガイドです。Module13.2はCore2の底面のM-Busポートに直接スタックして使用します。
# M5Stack Core2 + Module13.2 4In8Out (M-Bus stack)
# Wiring: Module13.2 stacked on Core2 via M-Bus (I2C)
# Module13.2 I2C address: 0x27 (default)
import time
from machine import Pin, I2C
from m5stack import lcd
# Initialize I2C on Core2's M-Bus (Port A pins: 21=SDA, 22=SCL)
i2c = I2C(0, scl=Pin(22), sda=Pin(21), freq=100000)
# Module13.2 I2C address
ADDR = 0x27
# Register addresses (from datasheet)
REG_INPUT = 0x00 # read 4-bit input state
REG_OUTPUT = 0x01 # write 8-bit output state
REG_CONFIG = 0x03 # configure I/O direction (0=output, 1=input)
# Configure all 8 outputs as outputs (0x00 = all outputs)
i2c.writeto_mem(ADDR, REG_CONFIG, bytes([0x00]))
lcd.clear()
lcd.print('Module13.2 Demo', 10, 10)
while True:
# Read input state (4 bits, lower nibble)
input_state = i2c.readfrom_mem(ADDR, REG_INPUT, 1)[0] & 0x0F
lcd.print('Inputs: %04b' % input_state, 10, 40)
# Toggle output channel 1 (bit 0)
i2c.writeto_mem(ADDR, REG_OUTPUT, bytes([0x01]))
time.sleep(1)
i2c.writeto_mem(ADDR, REG_OUTPUT, bytes([0x00]))
time.sleep(1)
この作り方はAIが構成から生成したものです(未検証)。通電前に配線とコードをご確認ください。
この構成はAIが実在するM5Stack部品から設計し、ポート互換をサーバで検証したものです。編集・共有できます。
エディタで開く →UnitKit は M5Stack® 製品向けの非公式ツール。作りたいものを書くと、部品リストと配線図が出ます。