# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT import time import board import adafruit_dps310 i2c = board.I2C() # uses board.SCL and board.SDA dps310 = adafruit_dps310.DPS310(i2c) while True: print("Temperature = %.2f *C" % dps310.temperature) print("Pressure = %.2f hPa" % dps310.pressure) print("") time.sleep(1.0)
# Get the 'temperature' feed from Adafruit IO temperature_feed = io.get_feed("gardentemp") except AdafruitIO_RequestError: # If no 'temperature' feed exists, create one temperature_feed = io.create_new_feed("gardentemp") #turn the backlight off backlight = DigitalInOut(board.TFT_BACKLIGHT) backlight.direction = Direction.OUTPUT select = DigitalInOut(board.BUTTON_SELECT) select.direction = Direction.INPUT # Create the sensor object using I2C sensor = adafruit_ahtx0.AHTx0(board.I2C()) dps310 = adafruit_dps310.DPS310(board.I2C()) loop_count = 0 while True: loop_count = (loop_count + 1) % 60 backlight.value = select.value if (loop_count % 10 == 0): print("\nAHTTemperature: %0.1f C" % sensor.temperature) print("AHTHumidity: %0.1f %%" % sensor.relative_humidity) print("DPSTemperature = %.2f *C" % dps310.temperature) print("DPSPressure = %.2f hPa" % dps310.pressure) print(select.value) print("") if (loop_count == 0): temperature_feed = io.get_feed("gardentemp")