Temp works

This commit is contained in:
Martin Brodbeck 2022-04-28 21:25:32 +02:00
parent 353f15b176
commit ef66e0cfd6

View file

@ -1,8 +1,30 @@
import utime
import machine
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 i2c_lcd import I2cLcd
relais = machine.Pin(15, machine.Pin.OUT, value = 1)
led_onboard = machine.Pin(25, machine.Pin.OUT, value = 0)
# 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.writeto(lcd_addr, '\x7C')
i2c.writeto(lcd_addr, '\x2D')
# Text in Zeilen
line_top = 'Temp. (Soll):'
line_bot = 'Temp. (Ist) :'
def ctrl_relais(active = True):
if active:
@ -14,7 +36,14 @@ def ctrl_relais(active = True):
while True:
ctrl_relais(True)
utime.sleep(5)
ctrl_relais(False)
utime.sleep(5)
temp_sensor.convert_temp()
sleep_ms(750)
print(temp_sensor.read_temp(sensor_id), " °C")
#i2c.writeto(lcd_addr, line_top + "\n" + line_bot)
i2c.writeto(lcd_addr, "Hello world")
sleep_ms(2000)
#ctrl_relais(True)
#sleep_ms(5000)
#ctrl_relais(False)
#sleep_ms(5000)