Pressure presence mat ・ 压力坐垫
体重計(ロードセル)と圧力センサ(チューブ圧力)の両方で在席を検知します。
この構成をエディタで開く・編集する →| 部品 | 役割 | ポート | リンク・価格 |
|---|---|---|---|
| M5Stack CoreS3 | Controller | grove_i2c, grove_analog, grove_uart, mbus, usb_c, sdcard | official page — $59.9 |
| Unit PaHub2 | I2C Hub | grove_i2c | official page — $7.95 |
| Unit Mini Scales | Weight Sensor | grove_i2c | official page — $6.95 |
| Unit Tube Pressure | Tube Pressure Sensor | grove_analog | official page — $7.95 |
M5Stack CoreS3とPaHub2、Mini Scalesユニット、Tube Pressureユニットを使って、重量と圧力から人の存在を検知する装置です。CoreS3がI2C経由で2つのセンサーを読み取り、重量変化や圧力変化を監視します。PaHub2を使うことで、1つのI2Cポートに複数のI2Cユニットを接続できます。
# M5Stack CoreS3 + PaHub2 + Mini Scales (I2C addr 0x2C) + Tube Pressure (I2C addr 0x30)
# Wiring: CoreS3 Port.A (red) -> PaHub2 IN, PaHub2 CH0 -> Mini Scales, PaHub2 CH1 -> Tube Pressure
import time
from machine import Pin, I2C
# Initialize I2C on CoreS3 Port.A (pins: SDA=2, SCL=1)
i2c = I2C(0, scl=Pin(1), sda=Pin(2), freq=100000)
# PaHub2 TCA9548A address (default 0x70)
PAHUB_ADDR = 0x70
# Mini Scales I2C address (default 0x2C)
SCALES_ADDR = 0x2C
# Tube Pressure I2C address (default 0x30)
PRESSURE_ADDR = 0x30
def select_channel(channel):
"""Select a channel on PaHub2 (0-5)."""
i2c.writeto(PAHUB_ADDR, bytes([1 << channel]))
def read_scales():
"""Read weight from Mini Scales (returns grams as int)."""
select_channel(0)
# Mini Scales command: read weight (register 0x01, 4 bytes)
i2c.writeto(SCALES_ADDR, bytes([0x01]))
data = i2c.readfrom(SCALES_ADDR, 4)
weight = int.from_bytes(data, 'big')
return weight
def read_pressure():
"""Read pressure from Tube Pressure (returns kPa as int)."""
select_channel(1)
# Tube Pressure command: read pressure (register 0x01, 2 bytes)
i2c.writeto(PRESSURE_ADDR, bytes([0x01]))
data = i2c.readfrom(PRESSURE_ADDR, 2)
pressure = int.from_bytes(data, 'big')
# Convert to kPa (assuming 0-20000 corresponds to -100~200 kPa)
# Adjust based on actual sensor calibration
return (pressure * 300 / 20000) - 100
while True:
try:
weight = read_scales()
pressure = read_pressure()
print('Weight: {} g, Pressure: {:.1f} kPa'.format(weight, pressure))
except Exception as e:
print('Error:', e)
time.sleep(1)
この作り方はAIが構成から生成したものです(未検証)。通電前に配線とコードをご確認ください。
この構成はAIが実在するM5Stack部品から設計し、ポート互換をサーバで検証したものです。編集・共有できます。
エディタで開く →UnitKit は M5Stack® 製品向けの非公式ツール。作りたいものを書くと、部品リストと配線図が出ます。