English
English
简体中文
日本語

UiFlow Tutorial

UiFlow1 Development Guide

Project Management

Use LTE network

UiFlow1 Blockly

Event

Unit

Unit ENV/ENV-II/ENV-III/ENV-IV

Example

Get temperature, humidity, and atmospheric pressure data collected by ENV

This example uses the first-generation Unit ENV. ENV II / III / IV use the same blocks for reading temperature, humidity, and pressure. Add the matching model in UiFlow1 to generate its initialization code automatically. When writing Python directly, use the corresponding initialization constant below; the subsequent read operations remain the same.

Product Initialization Constant
Unit ENV unit.ENV
Unit ENV II unit.ENV2
Unit ENV III unit.ENV3
Unit ENV IV unit.ENV4
from m5stack import *
from m5ui import * 
from uiflow import *
import unit

setScreenColor(0x222222)
env_0 = unit.get(unit.ENV, unit.PORTA)

while True:
  print(env_0.temperature)
  print(env_0.humidity)
  print(env_0.pressure)
  wait_ms(2)

API

print(env_0.temperature)
  • This method allows you to read the temperature value collected by ENV and return a floating-point value. The unit of measurement is °C.
print(env_0.humidity)
  • This method allows you to read the relative humidity value taken by ENV and return a floating-point value. The unit of measurement is %RH.
print(env_0.pressure)
  • This method allows you to read the atmospheres collected by ENV and return a floating-point value. The unit of measurement is hPa.

ENV IV-Specific Functions

env4_0.set_mode(0xFD)
  • Set the device running mode. This function only applies to ENV IV
print(env4_0.get_mode)
  • Obtain the current device running mode. This function only applies to ENV IV
    • NOHEAT_HIGHPRECISION: No heating, maintain high-precision measurement or control
    • NOHEAT_MEDPRECISION: No heating, medium precision
    • NOHEAT_LOWPRECISION: No heating, lowest precision
    • HIGHHEAT_1S: High heating mode, heating cycle of 1 second
    • HIGHHEAT_100MS: High heating mode, heating cycle of 100 milliseconds
    • MEDHEAT_1S: Medium heating mode, heating cycle of 1 second
    • MEDHEAT_100MS: Medium heating mode, heating cycle of 100 milliseconds
    • LOWHEAT_1S: Low heating mode, heating cycle of 1 second
    • LOWHEAT_100MS: Low heating mode, heating cycle of 100 milliseconds
Page Tools
PDF
On This Page