Created
January 4, 2022 20:07
-
-
Save baskaufs/67e4917e3c068b7b9bddf1c71ceb41be to your computer and use it in GitHub Desktop.
CircuitPython script to run temperature and RH sensor with 0.91 OLED display on QT Py RP2040
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import board | |
import busio # contains an interface for using hardware-driven I2C communication from your board | |
# board | |
import adafruit_hts221 | |
# display | |
import displayio | |
import adafruit_displayio_ssd1306 | |
displayio.release_displays() | |
oled_reset = board.D9 | |
i2c = busio.I2C(board.SCL1, board.SDA1) | |
display_bus = displayio.I2CDisplay(i2c, device_address=0x3c) | |
display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=32) | |
hts = adafruit_hts221.HTS221(i2c) | |
# read the rel humidity and temp every second | |
while True: | |
print() # this generates a newline to make up for the missing one at the end of the loop | |
print() # this generates another newline to clear the text off the top of the display | |
print("RH: %.2f %%" % hts.relative_humidity) | |
print("Temp: %.2f C" % hts.temperature, end ="") # suppress newline to prevent text shifting up on display | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment