micropython-i2c-async.py 598 B

1234567891011121314151617
  1. import bme280
  2. import uasyncio
  3. async def example():
  4. async with bme280.BME280(i2cBus=0) as bme:
  5. while True:
  6. t, h, p = await bme.readForcedAsync(filter=bme280.FILTER_4,
  7. tempOversampling=bme280.OVSMPL_4,
  8. humidityOversampling=bme280.OVSMPL_16,
  9. pressureOversampling=bme280.OVSMPL_4)
  10. print("t=%.2f h=%.2f p=%.1f" % (t, h * 1e2, p * 1e-2))
  11. uasyncio.sleep(1)
  12. uasyncio.run(example())
  13. # vim: ts=4 sw=4 expandtab