import machine
from time import sleep
from machine import Pin, SoftI2C
from pico_i2c_lcd import I2cLcd
from lcd_api import LcdApi
import ssd1306
import dht
from dht import DHT22
a15 =Pin(15, Pin.OUT)
i2c = machine.SoftI2C(scl=machine.Pin(1), sda=machine.Pin(0))
adress = i2c.scan()[0]
lcd = I2cLcd(i2c , adress , 4 , 20 )
#i2c = machine.SoftI2C(scl=machine.Pin(3), sda=machine.Pin(2))
pin = machine.Pin(16, machine.Pin.OUT)
pin.value(0)
pin.value(1)
oled_width = 128
oled_height = 32
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)
oled.fill(0)
dht = DHT22(Pin(4))
lcd.move_to(0 , 0)
lcd.putstr("Andy GT *****")
sleep(0.5)
lcd.move_to(0 , 1)
lcd.putstr("25.12.2024")
sleep(0.5)
lcd.clear()
#lcd.backlight_off()
lcd.move_to(0 , 1)
lcd.putstr("Raspberry Pi Pico ")
sleep(0.5)
lcd.clear()
while True:
dht.measure()
temp = dht.temperature()
hum = dht.humidity()
print("Temperature: {}°C Humidity: {:.0f}% ".format(temp, hum))
#lcd.clear()
lcd.move_to(0,0)
lcd.putstr('Temperatur: ' + str(temp) + " C")
lcd.move_to(0,1)
lcd.putstr('Feuchte: ' + str(hum) + "% ")
sleep(0.5)
lcd.putstr('Temperatur: ' + str(temp) + " C")
lcd.move_to(0,1)
lcd.putstr('Feuchte: ' + str(hum) + "% ")
oled.fill(0)
oled.text('Temperatur: ' + str(temp) + " C", 0, 0)
oled.text('Raspy Pi Pico', 0, 10)
oled.text('Feuchte: ' + str(hum) + "% ", 0, 20)
oled.show()
a15.on()
sleep(1)
#oled.fill(0)
#oled.text('Feuchte: ' + str(hum) + "% ", 0, 0)
#oled.text('OLED Ansteuerung', 0, 10)
#oled.text('******************', 0, 20)
#oled.show()
sleep(1)
a15.off()