zhexo

Raspberry Pi Pico W - DHT11

Dec 26th, 2023
969
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | Software | 0 0
  1. from machine import Pin
  2. from time import sleep
  3. import dht
  4.  
  5. sensor = dht.DHT11(Pin(18))
  6.  
  7. while True:
  8.   try:
  9.     sleep(2)
  10.     sensor.measure()
  11.     temp = sensor.temperature()
  12.     hum = sensor.humidity()
  13.     temp_f = temp * (9/5) + 32.0
  14.     print('Temperatura: %3.1f C' %temp)
  15.     print('Vlaznost: %3.1f %%' %hum)
  16.   except OSError as e:
  17.     print('DHT11 nedostupan')
Advertisement
Add Comment
Please, Sign In to add comment