from machine import Pin, SoftI2C
from time import sleep
from bmp280 import BMP280
from ahtx0 import AHT20

i2c = SoftI2C(scl=Pin(22), sda=Pin(21), freq=10000)

while True:
  aht = AHT20(i2c, address=0x38)
  bmp = BMP280(i2c, addr=0x77)

  temperatura = aht.temperature
  # temperatura2 = bmp.temperature
  humitat = aht.relative_humidity
  pressio = bmp.pressure

  print(f'Temperatura AHT20: {round(temperatura,2)} ºC')
  # print(f'Temperatura BMP280: {round(temperatura2,2)} ºC')
  print(f'Humitat: {round(humitat,2)} %')
  print(f'Pressió atmosfèrica: {round(pressio/100)} hPa')
  print()
  sleep(10)