I am new to async programming in Python and the internet has not helped me to solve my problem - does anyone of you have a solution?
I have an infinite loop, in which some sensor data is read. However, the sensor reading is quite slow, so I want so await the sensor signals.
My expectation of it looks like this (just the schematics):
import bno055 #sensor library
import asyncio
aync def read_sensor():
altitude=bno055.read()
#..and some other unimportant lines which I hide here
return altitude
def main():
while 1:
await current_altitude= read_sensor() #??? how can I "await" the sensor signals?
#....some other lines which I hide here, but they need to run syncronously
print(current_altitude)
main()
Thank you in advance