Using the Atom Socket ・ 使用 Atom Socket
M5StackのAtom Socketをコントローラーに接続する最小構成。配線とBOMつき。
この構成をエディタで開く・編集する →| 部品 | 役割 | ポート | リンク・価格 |
|---|---|---|---|
| SwitchC6 | Controller | terminal_block, gpio, other:User button, other:Wi-Fi 6 / ESP-NOW wireless | official page — $19.95 |
| Atom Socket | unit | grove_uart, gpio | official page — $28.9 |
SwitchC6とAtom Socketを使って、スマートコンセントをワイヤレスで制御する最小構成のビルドです。SwitchC6がWi-Fi経由でAtom Socketを操作し、接続された家電のオン/オフを切り替えられます。
# M5Stack SwitchC6 + Atom Socket (smart outlet control)
# Wiring: Atom Socket Grove (UART) -> SwitchC6 Grove (GPIO)
# Atom Socket UART: 4800bps 8E1, G22 RX, G23 relay control
from machine import Pin, UART
import time
# Initialize UART on SwitchC6 (GPIO22=RX, GPIO23=TX, but we only need TX for relay)
# Actually Atom Socket uses G22 as RX (receive from controller) and G23 as relay control.
# We'll use UART1 on SwitchC6: TX=GPIO17, RX=GPIO18 (adjust if needed)
# For simplicity, we control relay via GPIO23 directly (if using GPIO mode)
# But Atom Socket expects UART commands. Let's use UART.
# Define UART pins: TX=17, RX=18 (check SwitchC6 pinout)
uart = UART(1, baudrate=4800, bits=8, parity=1, stop=1, tx=17, rx=18)
# Relay control command (example: turn on)
# Atom Socket command format: 0x55 0x01 0x01 (on) or 0x55 0x01 0x00 (off)
# Checksum: sum of bytes except header? We'll use simple on/off.
def relay_on():
uart.write(b'\x55\x01\x01')
time.sleep_ms(10)
def relay_off():
uart.write(b'\x55\x01\x00')
time.sleep_ms(10)
# Test: toggle every 2 seconds
while True:
relay_on()
print("Relay ON")
time.sleep(2)
relay_off()
print("Relay OFF")
time.sleep(2)
この作り方はAIが構成から生成したものです(未検証)。通電前に配線とコードをご確認ください。
この構成はAIが実在するM5Stack部品から設計し、ポート互換をサーバで検証したものです。編集・共有できます。
エディタで開く →UnitKit は M5Stack® 製品向けの非公式ツール。作りたいものを書くと、部品リストと配線図が出ます。