Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
b888c26b8a |
2 changed files with 950 additions and 3405 deletions
|
@ -1,12 +1,13 @@
|
||||||
/* Weckkubator - Weck(topf)-(In)kubator
|
/* Weckkubator - Weck(topf)-(In)kubator
|
||||||
*
|
*
|
||||||
* Version 0.1.0
|
* Version 1.1.0
|
||||||
*
|
*
|
||||||
* Fliegerjohn - 06.05.2024
|
* Fliegerjohn - 06.05.2024
|
||||||
|
*
|
||||||
|
* Have fun!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#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 <OneWire.h> // 1-Wiresupport for DS18B20
|
||||||
|
@ -14,8 +15,8 @@
|
||||||
#include <PID_v1.h> // PID-Controller
|
#include <PID_v1.h> // PID-Controller
|
||||||
|
|
||||||
#define ONE_WIRE_BUS 10 // Enable 1-Wirebus on digital 10 (PB2 - Pin16)
|
#define ONE_WIRE_BUS 10 // Enable 1-Wirebus on digital 10 (PB2 - Pin16)
|
||||||
#define fan 8
|
#define fan 8 // Fan for cooling the Triac
|
||||||
#define wecktopf 9
|
#define wecktopf 9 // Triac for wecktopf
|
||||||
|
|
||||||
LiquidCrystal_I2C lcd(0x3F,20,4); // declare LCD
|
LiquidCrystal_I2C lcd(0x3F,20,4); // declare LCD
|
||||||
OneWire oneWire(ONE_WIRE_BUS); // declare 1-Wirebus
|
OneWire oneWire(ONE_WIRE_BUS); // declare 1-Wirebus
|
||||||
|
@ -33,6 +34,8 @@ unsigned long windowStartTime;
|
||||||
// Temp adjustment
|
// Temp adjustment
|
||||||
float tempset;
|
float tempset;
|
||||||
int poti;
|
int poti;
|
||||||
|
int potiold;
|
||||||
|
int poticlean;
|
||||||
|
|
||||||
// time
|
// time
|
||||||
unsigned long previousMillis;
|
unsigned long previousMillis;
|
||||||
|
@ -73,7 +76,7 @@ void setup() {
|
||||||
myPID.SetMode(AUTOMATIC); //turn on the PID
|
myPID.SetMode(AUTOMATIC); //turn on the PID
|
||||||
|
|
||||||
// Greetings
|
// Greetings
|
||||||
lcd.print("Weckkubator 0.1.0");
|
lcd.print("Weckkubator 1.1.0");
|
||||||
delay(3000);
|
delay(3000);
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,14 +87,16 @@ void setup() {
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
||||||
|
// read temp
|
||||||
|
readtemp();
|
||||||
|
|
||||||
// run pid
|
// run pid
|
||||||
pid();
|
pid();
|
||||||
|
|
||||||
// update LCD
|
// update LCD all 250ms
|
||||||
unsigned long currentMillis = millis();
|
unsigned long currentMillis = millis();
|
||||||
if (currentMillis - previousMillis >= 250) {
|
if (currentMillis - previousMillis >= 250) {
|
||||||
settemp();
|
settemp();
|
||||||
readtemp();
|
|
||||||
lcdoutput();
|
lcdoutput();
|
||||||
previousMillis = currentMillis;
|
previousMillis = currentMillis;
|
||||||
}
|
}
|
||||||
|
@ -102,6 +107,7 @@ void loop() {
|
||||||
else digitalWrite(fan, LOW);
|
else digitalWrite(fan, LOW);
|
||||||
previousMillisFan = currentMillis;
|
previousMillisFan = currentMillis;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------
|
//------------------------------------------
|
||||||
|
@ -128,13 +134,14 @@ void readtemp() {
|
||||||
sensors.requestTemperatures();
|
sensors.requestTemperatures();
|
||||||
watertemp = sensors.getTempCByIndex(0);
|
watertemp = sensors.getTempCByIndex(0);
|
||||||
|
|
||||||
if (watertemp == -127.00) missingsensor();
|
if (watertemp == -127.00) missingsensor(); // print error if temp -127 (sensor not detected)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------
|
//------------------------------------------
|
||||||
// LCD output
|
// LCD output
|
||||||
void lcdoutput() {
|
void lcdoutput() {
|
||||||
|
|
||||||
// Output temperatureset
|
// Output temperatureset
|
||||||
lcd.setCursor(8, 1);
|
lcd.setCursor(8, 1);
|
||||||
lcd.print(pidset);
|
lcd.print(pidset);
|
||||||
|
@ -157,11 +164,15 @@ void lcdoutput() {
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------
|
//------------------------------------------
|
||||||
// Read Poti
|
// Read Poti and calculate the settemp
|
||||||
void settemp() {
|
void settemp() {
|
||||||
poti = analogRead(A3);
|
|
||||||
tempset = (20+(poti*0.04));
|
|
||||||
|
|
||||||
|
poti = analogRead(A3);
|
||||||
|
poticlean = ((potiold+poti)/2); // Make average with last value so the tempset will not jump to much
|
||||||
|
tempset = (20+(poticlean*0.04));
|
||||||
|
potiold = poti;
|
||||||
|
|
||||||
|
// jump to 80 degrees if tempset above 51 degrees.
|
||||||
if (tempset <= 50) {
|
if (tempset <= 50) {
|
||||||
pidset = tempset;
|
pidset = tempset;
|
||||||
}
|
}
|
||||||
|
@ -175,22 +186,28 @@ void settemp() {
|
||||||
//------------------------------------------
|
//------------------------------------------
|
||||||
// Missing Sensor
|
// Missing Sensor
|
||||||
void missingsensor() {
|
void missingsensor() {
|
||||||
// turn of all output
|
|
||||||
|
// turn of all output to stop heating
|
||||||
digitalWrite(wecktopf, LOW);
|
digitalWrite(wecktopf, LOW);
|
||||||
digitalWrite(fan, LOW);
|
digitalWrite(fan, LOW);
|
||||||
|
|
||||||
// Clear LCD
|
// Clear LCD
|
||||||
lcd.clear();
|
lcd.clear();
|
||||||
|
|
||||||
|
// keep in loop until it reads a valid temp
|
||||||
do {
|
do {
|
||||||
|
// print errormessage
|
||||||
lcd.setCursor(0, 0);
|
lcd.setCursor(0, 0);
|
||||||
lcd.print("Error:");
|
lcd.print("Error:");
|
||||||
lcd.setCursor(0, 1);
|
lcd.setCursor(0, 1);
|
||||||
lcd.print("Missing Sensor");
|
lcd.print("Missing Sensor");
|
||||||
|
// read sensor
|
||||||
sensors.requestTemperatures();
|
sensors.requestTemperatures();
|
||||||
watertemp = sensors.getTempCByIndex(0);
|
watertemp = sensors.getTempCByIndex(0);
|
||||||
|
|
||||||
} while (watertemp == -127.00);
|
} while (watertemp == -127.00);
|
||||||
|
|
||||||
|
// set back the display
|
||||||
setupdisplay();
|
setupdisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue