Joy-it RB-P-XPLR-SET handleiding
Handleiding
Je bekijkt pagina 21 van 37

21
from machine import ADC, Pin, SPI
import utime
import dht
import ST7735 # Assuming this is the library for your TFT display
# Initialize DHT11 sensor
sensor_dht11 = dht.DHT11(Pin(0))
# Initialize UV sensor
uv_sensor = ADC(2) # Assuming GP28 is ADC pin number 1 in your conguration
# Initialize LCD
spi = SPI(0, baudrate=8000000, polarity=0, phase=0, sck=Pin(18), mosi=Pin(19),
miso=Pin(16))
lcd = ST7735.ST7735(spi, rst=Pin(6), ce=Pin(17), dc=Pin(3))
backlight = Pin(2, Pin.OUT)
backlight.high()
lcd.reset()
lcd.begin()
lcd.ll_screen(lcd.rgb_to_565(255, 255, 255))
while True:
lcd.ll_screen(lcd.rgb_to_565(255, 255, 255))
# Read UV value
uv_value = uv_sensor.read_u16()
# Conversion in percent
uv_percent = (uv_value / 65000) * 100
print("UV Intensity (percent):", uv_percent)
# DHT11 Read values
sensor_dht11.measure()
temp = sensor_dht11.temperature()
humid = sensor_dht11.humidity()
# Display values on LCD
lcd.p_string(20, 20, "Temp: {}C".format(temp))
lcd.p_string(20, 40, "Humid: {}%".format(humid))
lcd.p_string(20, 60, "UV: {:.2f}%".format(uv_percent)) # Display of UV
intensity in percent with two decimal places
utime.sleep(10)
SUMMARY: Our weather station reads the DHT11 and UV sensors and outputs the data on the TFT display.
Output on the display
Measuring the sensor values
Initialization of the TFT display
Bekijk gratis de handleiding van Joy-it RB-P-XPLR-SET, stel vragen en lees de antwoorden op veelvoorkomende problemen, of gebruik onze assistent om sneller informatie in de handleiding te vinden of uitleg te krijgen over specifieke functies.
Productinformatie
Merk | Joy-it |
Model | RB-P-XPLR-SET |
Categorie | Niet gecategoriseerd |
Taal | Nederlands |
Grootte | 21690 MB |