So I figured it out. The worst flaw was the
solltemperatur = 0;
part at the beginning of my loop. It basically resettet the set temperature value to 0 immediately so no wonder that it wouldn't rise. I redirected this part to the setup.
To get it to work i had to set the Millis in the non blocking version of Timing suggested by Stefan to <100, but from an angle you could see the display flicker because of the fast update rate, and such a high update rate wasn't recommended for the DHT-11 anyways (It still worked tho ...). So I made the display update whenever a turn of the encoder was detected (as suggested by Grumpy_Mike) and also every 2 seconds to get an Updated environment temperature from the DHT-11.
The KY-040 wasn't working very reliably, it skipped over quite a few numbers and didn't felt very smooth. I changed to a Grove-Encoder from Seeed and used the Encoder.h and TimerOne.h library as suggested on the Seeed Wiki (it was pretty straight forward) and now it runs almost perfectly. (For some reason the higest value that can be displayed is 71 and the lowest is 24 even tho it should actually be 70 and 25 but that gives me no headaches tbh)
Anyways thanks for the help guys. If anyone is interested in my final program, here you go:
(Sorry for the German comments but I'm too lazy to translate right now, also i doubt someone gives a shit)
// Doofenschmirtz Dörrinator
// Mads Duggen
// Interactive Prototyping 2021
// Unter der Leitung von Martin Fischbock
// Muthesius Kunsthochschule
// Tips für non-blocking timing von StefanL38 aus dem Aduino Forum
// ARDUINO PIN-BELEGUNG
// LCD mit I2C Modul
// A5 - SCL
// A4 - SDA
// 5v - VCC
// GND - GND
// DHT 11 Sensor mit Platine
// 8 - OUTPUT
// 5v - VCC
// GND - GND
// Heiz und Lüft Relais Channel 1 und 2
// 10 - CH1
// 11 - CH2
// 5v - DC+
// GND - DC-
// Grove Rotary Encoder
// 2 - SIGB
// 3 - SIGA
// 5v - VCC
// GND - GND
// Genutzte Bibiliotheken
#include <Encoder.h>
#include <TimerOne.h>
#include <DHT.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
// Data-Pin und Sensortyp Definierung
#define DHTPIN 8
#define DHTTYPE DHT11
// Zuordnung der Variablen als Integere
int solltemperatur;
int temperatur;
int luftfeuchtigkeit;
// LCD und DHT Objekte erstellen und definieren von Pins, Adresse, Spalten & Zeilen
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 16, 2);
unsigned long myLcdUpdateTimer;
// Hilfsfunktion für non-blcoking-timing von StefanL38
boolean TimePeriodIsOver (unsigned long &expireTime, unsigned long TimePeriod) {
unsigned long currentMillis = millis();
if ( currentMillis - expireTime >= TimePeriod )
{
expireTime = currentMillis; // set new expireTime
return true; // more time than TimePeriod) has elapsed since last time if-condition was true
}
else return false; // not expired
}
void setup() {
// Initialisierung Relais Pins
pinMode(10, OUTPUT); // Relais Heizelement
pinMode(11, OUTPUT); // Relais Lüfter
//Initialisieren des encoders
encoder.Timer_init();
// Solltemperatur Grundwert auf 0 setzten
solltemperatur = 0;
// Begrüßungssequenz
dht.begin(); // Initialisierung des DHT11 Sensors
lcd.backlight(); // Anschalten der LCD Hintergrundbeleuchtung
lcd.begin(); // Intialisierung des LCD
delay(2000);
lcd.setCursor( 0, 0); // Auswählen der 1. Zeile
lcd.print(" Doofenschmirtz"); // Text für die 1. Zeile
lcd.setCursor( 0, 1); // Auswählen der 2. Zeile
lcd.print(" Doerrinator"); // Text für die 2. Zeile
delay(5000);
}
void printToLCD() {
lcd.clear();
delay(10);
//Die Umgebungstemperatur wird in der ersten Zeile angezeigt
lcd.setCursor( 0, 0);
lcd.print("Temp. :");
lcd.print(temperatur);
lcd.print("C");
//Die eingestellte Temperatur wird in der zweiten Zeile angezeigt
lcd.setCursor( 0, 1);
lcd.print("Soll. :");
lcd.print(solltemperatur); // Einstellbare Variable zum Feststellen des Temperatur-Sollwertes
lcd.print("C");
}
void loop() {
temperatur = dht.readTemperature(); // Umgebungstemperatur
luftfeuchtigkeit = dht.readHumidity(); // Luftfeuchtigkeit (bisher nicht in Benutzung)
// Wenn an dem Drehgeber gedreht wird
if (encoder.rotate_flag == 1)
{
//Wenn gegen den Uhrzeigersinn gedreht wird, solltemperatur verringern
if (encoder.direct == 1)
{
solltemperatur --;
printToLCD(); //Der LCD wird nur geupdatet wenn an dem Encoder gedreht wird
}
//Wenn mit dem Uhrzeigersinn gedreht wird, solltemperatur erhöhen
else
{
solltemperatur ++;
printToLCD(); //Der LCD wird nur geupdatet wenn an dem Encoder gedreht wird
}
// Encoder auf 0 zurücksetzten
encoder.rotate_flag = 0;
}
if (temperatur != temperatur) {
printToLCD();
}
// Unteres Temperaturlimit // Irgendwie ist 24 das Minimm ... Kein Plan wieso
if (solltemperatur <= 15) {
solltemperatur = 15;
}
// Oberes Temperaturlimit // Irgediwe ist 71 das Maximum ... Kein Plan wieso
if (solltemperatur >= 70) {
solltemperatur = 70;
}
// Das Relais wird angeschaltet, wenn die Außentemperatur niedriger ist als der eingestellte Wert
if (solltemperatur > temperatur) {
digitalWrite(10, LOW);
digitalWrite(11, LOW);
}
// Falls nicht wird es ausgeschaltet
else {
digitalWrite(10, HIGH);
digitalWrite(11, LOW);
}
if ( TimePeriodIsOver(myLcdUpdateTimer, 2000) ) {
printToLCD(); // LCD-Update zur Erfassung des Aktuellen Temperaturwertes über den DHT-11 Sensor
}
}
// Genutzte Anleitungen und Tutorials
// Q1. https://wiki.seeedstudio.com/Grove-Encoder/
// Q2. https://github.com/hduijn/arduino-dehydrator/blob/master/arduinocode/dehydrator.ino
// Information zu Betrieb von I2C LCD und DHT11 aus den Beispielsketches der Bibiliotheken <DHT.h> und <LiquidCrystal_I2C.h>