Using the Unit NCIR2 ・ 使用 Unit NCIR2
M5StackのUnit NCIR2をコントローラーに接続する最小構成。配線とBOMつき。
この構成をエディタで開く・編集する →| 部品 | 役割 | ポート | リンク・価格 |
|---|---|---|---|
| M5Stack Core2 | Controller | grove_i2c, grove_analog, grove_uart, mbus | official page — $46.9 |
| Unit NCIR2 | unit | grove_i2c | official page — $21.9 |
M5Stack Core2とUnit NCIR2(非接触赤外線温度センサー)を使って、物体の表面温度を非接触で測定する装置です。Core2の画面に温度を表示し、設定した温度範囲を超えると警告を出します。配線はI2C接続1本で簡単です。
# M5Stack Core2 + Unit NCIR2 (non-contact IR temperature sensor)
# Wiring: NCIR2 -> Core2 red Port.A (I2C)
import time
from machine import Pin, I2C
from m5stack import lcd
# I2C setup on Port.A (Core2: sda=21, scl=22)
i2c = I2C(0, scl=Pin(22), sda=Pin(21), freq=100000)
# NCIR2 I2C address is 0x0A (10 decimal)
NCIR2_ADDR = 0x0A
# Read temperature register (2 bytes, big-endian, unit: 0.1°C)
def read_temperature():
data = i2c.readfrom_mem(NCIR2_ADDR, 0x01, 2) # register 0x01 = temperature
raw = (data[0] << 8) | data[1]
if raw & 0x8000: # negative temperature
raw -= 0x10000
return raw / 10.0 # convert to Celsius
ALARM_HIGH = 35.0 # °C
ALARM_LOW = 10.0 # °C
while True:
temp = read_temperature()
lcd.clear()
lcd.print('Temp: %.1f C' % temp, 10, 20)
if temp > ALARM_HIGH or temp < ALARM_LOW:
lcd.print('ALARM!', 10, 60)
time.sleep(1)
この作り方はAIが構成から生成したものです(未検証)。通電前に配線とコードをご確認ください。
この構成はAIが実在するM5Stack部品から設計し、ポート互換をサーバで検証したものです。編集・共有できます。
エディタで開く →UnitKit は M5Stack® 製品向けの非公式ツール。作りたいものを書くと、部品リストと配線図が出ます。