Example: 50-Arduino-Boards/Nano-33-BLE-Sense/51-Sensors/hts221.py

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 相对湿度和温度传感器示例。
# 请注意,Arduino Nano BLE 33 Sense Rev2使用HS3003。

import time
from hts221 import HTS221
from machine import Pin, I2C

bus = I2C(1, scl=Pin(15), sda=Pin(14))
try:
    hts = HTS221(bus)
except OSError:
    from hs3003 import HS3003

    hts = HS3003(bus)

while True:
    rH = hts.humidity()
    temp = hts.temperature()
    print("rH: %.2f%% T: %.2fC" % (rH, temp))
    time.sleep_ms(100)

results matching ""

    No results matching ""