NCIR Hat

The following products are supported:

NCIRHAT

Micropython Example:

 1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
 2#
 3# SPDX-License-Identifier: MIT
 4
 5import os, sys, io
 6import M5
 7from M5 import *
 8from hardware import *
 9from hat import NCIRHat
10
11
12label0 = None
13i2c0 = None
14hat_ncir_0 = None
15
16
17def setup():
18    global label0, i2c0, hat_ncir_0
19
20    M5.begin()
21    label0 = Widgets.Label("label0", 39, 109, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
22
23    i2c0 = I2C(0, scl=Pin(26), sda=Pin(0), freq=100000)
24    hat_ncir_0 = NCIRHat(i2c0)
25
26
27def loop():
28    global label0, i2c0, hat_ncir_0
29    M5.update()
30    label0.setText(str(hat_ncir_0.get_object_temperature()))
31
32
33if __name__ == "__main__":
34    try:
35        setup()
36        while True:
37            loop()
38    except (Exception, KeyboardInterrupt) as e:
39        try:
40            from utility import print_error_msg
41
42            print_error_msg(e)
43        except ImportError:
44            print("please update to latest firmware")

UIFLOW2 Example:

example.png

stickc_plus2_ncir_example.m5f2

class NCIRHat

Constructors

class NCIRHat(i2c, address: int = 0x5A)

Create a NCIRHat object.

参数:
  • i2c – I2C object

  • address – the I2C address of the device. Default is 0x5A.

UIFLOW2:

init.png

NCIRHat class inherits NCIRUnit class, See unit.NCIRUnit.Methods for more details.