Created
April 5, 2022 22:40
-
-
Save securetorobert/4f8d663bb17806c92028e55ed498f5eb to your computer and use it in GitHub Desktop.
A python file for reading temperature and humidity and displaying on an LCD screen using Grove connectors
This file contains 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
# | |
# Weather Station. Requires Grove Shield, Temp Sensor, and LCD | |
import utime | |
from lcd1602 import LCD1602 | |
from dht11 import * | |
from machine import Pin, I2C | |
from time import sleep | |
dht2 = DHT(18) #temperature and humidity sensor connect to D18 port | |
i2c = I2C(1, scl=Pin(7), sda=Pin(6), freq=400000) | |
d = LCD1602(i2c, 2, 16) | |
while True: | |
t,h = dht2.readTempHumid()#temp: humid: | |
d.clear() | |
d.print('T: {} C'.format(t)) | |
d.setCursor(0,1) | |
d.print('H: {} %'.format(h)) | |
print('T: {}'.format(t)) | |
print('H: {}'.format(h)) | |
utime.sleep(5) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment