Door / window open sensor ・ 门窗开关检测
ホール効果センサーでドアや窓の開閉を検知し、通知します。
この構成をエディタで開く・編集する →| 部品 | 役割 | ポート | リンク・価格 |
|---|---|---|---|
| AtomS3 | Controller | grove_i2c, i2c, spi, gpio, usb_c | official page — $15.5 |
| Unit Hall | Magnetic sensor (Hall effect) | grove_analog | official page — $5.95 |
M5Stack AtomS3とUnit Hall(ホール効果センサー)で作る、ドアや窓の開閉を検出する装置です。磁石が近づくとセンサーが反応し、開閉状態をAtomS3の画面に表示します。Wi-Fi経由で通知を送ることもできます。
# M5Stack AtomS3 + Unit Hall (door/window open/close detector)
# Wiring: Unit Hall -> AtomS3 black Port.B (analog/digital GPIO)
import time
from machine import Pin
from m5stack import lcd
# Port.B on AtomS3: GPIO pin 1 (Grove black port)
hall_pin = Pin(1, Pin.IN, Pin.PULL_UP) # Hall sensor outputs digital signal
while True:
state = hall_pin.value() # 0 = magnet near (closed), 1 = magnet far (open)
lcd.clear()
if state == 0:
lcd.print('Closed', 10, 20)
else:
lcd.print('Open', 10, 20)
time.sleep(0.5) # check every 0.5 seconds
この作り方はAIが構成から生成したものです(未検証)。通電前に配線とコードをご確認ください。
この構成はAIが実在するM5Stack部品から設計し、ポート互換をサーバで検証したものです。編集・共有できます。
エディタで開く →UnitKit は M5Stack® 製品向けの非公式ツール。作りたいものを書くと、部品リストと配線図が出ます。