Skip to content

Instantly share code, notes, and snippets.

@securetorobert
Created April 5, 2022 22:40
Show Gist options
  • Select an option

  • Save securetorobert/4f8d663bb17806c92028e55ed498f5eb to your computer and use it in GitHub Desktop.

Select an option

Save securetorobert/4f8d663bb17806c92028e55ed498f5eb to your computer and use it in GitHub Desktop.

Revisions

  1. securetorobert created this gist Apr 5, 2022.
    26 changes: 26 additions & 0 deletions rpi_temperature_grove.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    #
    # 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)