ENV Hat
The following products are supported:
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 ENVHat 10 11 12label0 = None 13label1 = None 14label2 = None 15i2c0 = None 16hat_env3_0 = None 17 18 19def setup(): 20 global label0, label1, label2, i2c0, hat_env3_0 21 22 M5.begin() 23 label0 = Widgets.Label("label0", 9, 15, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 24 label1 = Widgets.Label("label1", 9, 44, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 25 label2 = Widgets.Label("label2", 9, 72, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 26 27 i2c0 = I2C(0, scl=Pin(26), sda=Pin(0), freq=100000) 28 hat_env3_0 = ENVHat(i2c0, type=3) 29 30 31def loop(): 32 global label0, label1, label2, i2c0, hat_env3_0 33 M5.update() 34 label0.setText(str(hat_env3_0.read_temperature())) 35 label1.setText(str(hat_env3_0.read_pressure())) 36 label2.setText(str(hat_env3_0.read_humidity())) 37 38 39if __name__ == "__main__": 40 try: 41 setup() 42 while True: 43 loop() 44 except (Exception, KeyboardInterrupt) as e: 45 try: 46 from utility import print_error_msg 47 48 print_error_msg(e) 49 except ImportError: 50 print("please update to latest firmware")
UIFLOW2 Example:
stickc_plus2_env_hat_example.m5f2
class ENVHat
Constructors
- class ENVHat(i2c: I2C | PAHUBHat, type: Literal[1, 2, 3])
Create an ENVHat object.
parameter is:
i2cis an I2C object.typeis the type of ENVHat1- ENV2- ENV II3- ENV III
UIFLOW2:

Methods
- ENVHat.read_temperature()
This method allows to read the temperature value collected by ENV and returns a floating point value. The hat of measurement is °C.
UIFLOW2:

- ENVHat.read_humidity()
This method allows to read the relative humidity value collected by ENV and returns a floating point value. The hat of measurement is %RH.
UIFLOW2:

- ENVHat.read_pressure()
This method allows to read the atmospheric pressure collected by ENV and returns a floating point value. The hat of measurement is Pa.
UIFLOW2:



