Robert John
Published © GPL3+

Temperature Reading with RPi Pico & MicroPython

New to embedded programming? Use MicroPython to read and display temperature and humidity on an LCD. No soldering or breadboard is needed.

BeginnerFull instructions provided1 hour2,616
Temperature Reading with RPi Pico & MicroPython

Things used in this project

Hardware components

Raspberry Pi Pico
Raspberry Pi Pico
×1
Seeed Studio Grove Starter Kit for Raspberry Pi Pico
×1

Software apps and online services

Thonny

Story

Read more

Code

MicroPython Code for Temperature Sensor and LCD Screen

MicroPython
This is the code that you need to copy and paste into the Thonny Editor
#
# Weather Station. Requires:
# * Grove Shield, 
# * Temperature & Humidity Sensor,  
# * 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) # connect I2C
d = LCD1602(i2c, 2, 16) # connect the LCD
 
while True:  
 
    t,h = dht2.readTempHumid() # temp:  humid:
    
    d.clear() # clear the LCD so old text isn't visible
    d.print('T: {} C'.format(t))
    d.setCursor(0,1) # go to line 2 of the LCD
    d.print('H: {} %'.format(h))
    print('T: {}'.format(t)) # debug
    print('H: {}'.format(h)) # debug
    utime.sleep(5) # wait 5 seconds

Credits

Robert John

Robert John

3 projects • 9 followers
Data Team lead by day, community and hardware builder at night. Arm Innovator, Edge Impulse Expert, Google Dev Expert.

Comments