gbmanager/gbmanager.py
2022-04-28 22:05:52 +02:00

51 lines
No EOL
1.2 KiB
Python

from machine import Pin, I2C
from onewire import OneWire
from ds18x20 import DS18X20
from time import sleep_ms
from machine_i2c_lcd import I2cLcd
from lcd_api import LcdApi
#from pico_i2c_lcd import I2cLcd
# Relais
relais = Pin(15, machine.Pin.OUT, value = 1)
led_onboard = Pin(25, machine.Pin.OUT, value = 0)
# Temperature
temp_sensor = DS18X20(OneWire(Pin(16)))
sensor_id = temp_sensor.scan()[0]
# LCD Display
#i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=100000)
#lcd = I2cLcd(i2c, 0x27, 2, 16)
i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
lcd_addr = 39
I2C_ADDR = 0x27
I2C_NUM_ROWS = 2
I2C_NUM_COLS = 16
lcd = I2cLcd(i2c, I2C_ADDR, I2C_NUM_ROWS, I2C_NUM_COLS)
# Text in Zeilen
line_top = 'Soll: '
line_bot = 'Ist : '
def ctrl_relais(active = True):
if active:
relais.value(0)
led_onboard.on()
else:
relais.value(1)
led_onboard.off()
while True:
temp_sensor.convert_temp()
sleep_ms(750)
temp_curr = str(temp_sensor.read_temp(sensor_id))
lcd.move_to(0, 0)
lcd.putstr(line_top + "\n" + line_bot + temp_curr + " °C")
sleep_ms(2000)
#ctrl_relais(True)
#sleep_ms(5000)
#ctrl_relais(False)
#sleep_ms(5000)