Tube Pressure Unit
This is the driver library of Tube Pressure Unit, which is used to control the pressure sensor.
Support the following products:
UiFlow2 Example
get pressure value
Open the tube_pressure_core2_example.m5f2 project in UiFlow2.
The example shows the pressure value of the tube pressure unit.
UiFlow2 Code Block:
Example output:
None
MicroPython Example
get pressure value
The example shows the pressure value of the tube pressure unit.
MicroPython Code Block:
1# SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD 2# 3# SPDX-License-Identifier: MIT 4 5import os, sys, io 6import M5 7from M5 import * 8from unit import TubePressureUnit 9 10 11title0 = None 12label2 = None 13label0 = None 14label1 = None 15tubepressure_0 = None 16 17 18def setup(): 19 global title0, label2, label0, label1, tubepressure_0 20 21 M5.begin() 22 Widgets.fillScreen(0x222222) 23 title0 = Widgets.Title( 24 "TubePressureUnit Core2 Example", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.DejaVu18 25 ) 26 label2 = Widgets.Label("label2", 1, 159, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 27 label0 = Widgets.Label("label0", 1, 73, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 28 label1 = Widgets.Label("label1", 1, 116, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 29 30 tubepressure_0 = TubePressureUnit((36, 26)) 31 32 33def loop(): 34 global title0, label2, label0, label1, tubepressure_0 35 M5.update() 36 label0.setText(str((str("Pressure:") + str((tubepressure_0.get_pressure()))))) 37 label1.setText(str((str("ADC 12Bits Value:") + str((tubepressure_0.get_analog_value(12)))))) 38 label2.setText(str((str("Voltage:") + str((tubepressure_0.get_voltage()))))) 39 40 41if __name__ == "__main__": 42 try: 43 setup() 44 while True: 45 loop() 46 except (Exception, KeyboardInterrupt) as e: 47 try: 48 from utility import print_error_msg 49 50 print_error_msg(e) 51 except ImportError: 52 print("please update to latest firmware")
Example output:
None
API
TubePressureUnit
- class unit.tube_pressure.TubePressureUnit(port)
Bases:
objectCreate an TubePressureUnit object.
- Parameters:
port (tuple) – The port of the tube pressure.
UiFlow2 Code Block:

MicroPython Code Block:
from unit import TubePressureUnit tube_pressure_0 = TubePressureUnit((32, 26))
- get_pressure()
Getting the pressure value of the tube pressure.
- Returns:
pressure value.
- Return type:
UiFlow2 Code Block:

MicroPython Code Block:
tube_pressure_0.get_pressure()
- get_voltage()
Getting the voltage value of the tube pressure.
- Returns:
voltage value.
- Return type:
UiFlow2 Code Block:

MicroPython Code Block:
tube_pressure_0.get_voltage()


