Using the Unit RF433R ・ 使用 Unit RF433R
M5StackのUnit RF433Rをコントローラーに接続する最小構成。配線とBOMつき。
この構成をエディタで開く・編集する →| 部品 | 役割 | ポート | リンク・価格 |
|---|---|---|---|
| ATOM Lite | Controller | grove_i2c, i2c, gpio | official page — $7.5 |
| Unit RF433R | unit | grove_analog | official page — $4.5 |
M5Stack ATOM LiteとUnit RF433Rで作る、433MHz無線信号の受信機です。RF433Rユニットがリモコンなどの信号を受信し、ATOM Liteがそのデータを読み取ります。スマートホームのトリガーや、リモコン信号の学習・中継などに使えます。
# M5Stack ATOM Lite + Unit RF433R (433MHz receiver)
# Wiring: Unit RF433R -> ATOM Lite Grove port (analog/GPIO)
# The RF433R outputs a digital signal on the Grove data line (GPIO 26 on ATOM Lite)
import time
from machine import Pin
import neopixel
# ATOM Lite built-in RGB LED on GPIO 27
np = neopixel.NeoPixel(Pin(27), 1)
# RF433R data pin connected to ATOM Lite Grove port (GPIO 26)
rf_pin = Pin(26, Pin.IN)
def pulse_in(pin, level, timeout_us=100000):
"""Wait for a pulse of given level, return duration in microseconds."""
start = time.ticks_us()
while pin.value() != level:
if time.ticks_diff(time.ticks_us(), start) > timeout_us:
return 0
start = time.ticks_us()
while pin.value() == level:
if time.ticks_diff(time.ticks_us(), start) > timeout_us:
return 0
return time.ticks_diff(time.ticks_us(), start)
print("RF433R receiver ready. Press a button on your remote.")
while True:
# Wait for a falling edge (signal start)
if rf_pin.value() == 0:
# Measure low pulse (sync)
low = pulse_in(rf_pin, 0)
if low == 0:
continue
# Measure high pulse (data)
high = pulse_in(rf_pin, 1)
if high == 0:
continue
# Print pulse widths (microseconds)
print("Low: {} us, High: {} us".format(low, high))
# Blink LED blue to indicate reception
np[0] = (0, 0, 50)
np.write()
time.sleep_ms(100)
np[0] = (0, 0, 0)
np.write()
else:
# Idle: slow breathing LED (green)
for i in range(0, 50, 5):
np[0] = (0, i, 0)
np.write()
time.sleep_ms(50)
for i in range(50, 0, -5):
np[0] = (0, i, 0)
np.write()
time.sleep_ms(50)
この作り方はAIが構成から生成したものです(未検証)。通電前に配線とコードをご確認ください。
この構成はAIが実在するM5Stack部品から設計し、ポート互換をサーバで検証したものです。編集・共有できます。
エディタで開く →UnitKit は M5Stack® 製品向けの非公式ツール。作りたいものを書くと、部品リストと配線図が出ます。