From d9c9c0e02f7907e5b0abae1b0df376c6d57e4c69 Mon Sep 17 00:00:00 2001 From: Andreas Gattringer <andreas.gattringer@univie.ac.at> Date: Wed, 6 Mar 2024 07:27:03 +0100 Subject: [PATCH] added rhtp test program --- programs/rhtp.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 programs/rhtp.py diff --git a/programs/rhtp.py b/programs/rhtp.py new file mode 100644 index 0000000..3b043ae --- /dev/null +++ b/programs/rhtp.py @@ -0,0 +1,37 @@ +import sys + +from umnp.microcontroller.measurementdevice import MeasurementDevice +from umnp.microcontroller.sensors.lps28dfw import LPS28DFW +from umnp.microcontroller.sensors.sht45 import SHT45 + +if sys.implementation.name == "micropython": + # noinspection PyUnresolvedReferences + import machine + + # noinspection PyUnresolvedReferences + import uasyncio as asyncio +else: + from umnp.microcontroller.umock import machine + + +async def main(): + # configure network + device = MeasurementDevice() + i2c = machine.I2C(id=1, scl=machine.Pin(27), sda=machine.Pin(26)) + sht45 = SHT45(i2c) + p_sensor = LPS28DFW(i2c) + while True: + t, rh = await sht45.measure() + p = p_sensor.pressure() + p_t = p_sensor.temperature() + print(f"temperature: {t}") + print(f"rH: {rh}") + print(f"pressure: {p}") + print(f"temperature (p): {p_t}") + print() + print() + asyncio.sleep(1) + + +if __name__ == "__main__": + asyncio.run(main()) -- GitLab