Try to get hardware working. Proper regulation is missing.

This commit is contained in:
Fliegerjohn 2024-04-23 17:18:56 +02:00
parent 26f68b2b74
commit 7c12ac40f8
Signed by: fliegerjohn
GPG key ID: E2221D5FE4656B6A
2 changed files with 982 additions and 190 deletions

View file

@ -1,10 +1,24 @@
#include <Wire.h> // Support for I2C --> LCD #include <Wire.h> // Support for I2C --> LCD
#include <LiquidCrystal_I2C.h> // Support for PCF8574 --> LCD #include <LiquidCrystal_I2C.h> // Support for PCF8574 --> LCD
#include <OneWire.h> // 1-Wiresupport for DS18B20
#include <DallasTemperature.h> // Easy reading of DS18B20
#define ONE_WIRE_BUS 10 // Enable 1-Wirebus on digital 10 (PB2 - Pin16)
LiquidCrystal_I2C lcd(0x3F,20,4); // declare LCD LiquidCrystal_I2C lcd(0x3F,20,4); // declare LCD
OneWire oneWire(ONE_WIRE_BUS); // declare 1-Wirebus
DallasTemperature sensors(&oneWire); // declare sensors
float tempset;
float watertemp;
int poti;
void setup() { void setup() {
// Setup GPIO
pinMode(9, OUTPUT); // Output "Wecktopf"
pinMode(8, OUTPUT); // Fan
// Setup sensors
sensors.begin();
// Setup I2C-LCD // Setup I2C-LCD
lcd.init(); lcd.init();
lcd.backlight(); lcd.backlight();
@ -19,15 +33,53 @@ void setup() {
void loop() { void loop() {
// //
lcd.setCursor(6, 0); settemp();
lcd.print("Nothing"); readtemp();
lcd.setCursor(9, 1); lcdoutput();
lcd.print("to");
lcd.setCursor(9, 2); delay(100);
lcd.print("do");
lcd.setCursor(8, 3); if (tempset >= watertemp) {
lcd.print("jet."); digitalWrite(9, HIGH);
delay(1000000000);
} }
else {
digitalWrite(9, LOW);
}
}
//------------------------------------------
// Read temp from DS18B20
void readtemp() {
/* Read temp of first sensor and take if for watertemp.
* In future we might add others.
*/
sensors.requestTemperatures();
watertemp = sensors.getTempCByIndex(0);
}
//------------------------------------------
// LCD output
void lcdoutput() {
// Output temperatureset
lcd.setCursor(0, 1);
lcd.print("s:");
lcd.print(tempset);
// Output watertemp
lcd.setCursor(9, 1);
lcd.print("t:");
lcd.print(watertemp);
}
//------------------------------------------
// Read Poti
void settemp() {
poti = analogRead(A3);
tempset = (poti*0.1);
}

File diff suppressed because it is too large Load diff