NCIR Unit
Support the following products:
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 unit import NCIRUnit 10 11 12i2c0 = None 13ncir_0 = None 14 15 16def setup(): 17 global i2c0, ncir_0 18 19 M5.begin() 20 Widgets.fillScreen(0x222222) 21 22 i2c0 = I2C(0, scl=Pin(22), sda=Pin(21), freq=100000) 23 ncir_0 = NCIRUnit(i2c0) 24 print(ncir_0.get_ambient_temperature()) 25 print(ncir_0.get_object_temperature()) 26 27 28def loop(): 29 global i2c0, ncir_0 30 M5.update() 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:
class NCIRUnit
Constructors
- class NCIRUnit(i2c)
Create an NCIRUnit object.
- The parameters is:
i2c
Define the i2c pin.
UIFLOW2:
Methods
- ncir.get_ambient_temperature()
Obtain the ambient temperature.
UIFLOW2:
- ncir.get_object_temperature()
Get the temperature of the measured object.
UIFLOW2: