Skip to content

Instantly share code, notes, and snippets.

@securetorobert
Created April 5, 2022 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save securetorobert/4f8d663bb17806c92028e55ed498f5eb to your computer and use it in GitHub Desktop.
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
#
# 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