Hello everyone!
I've made a climate control for my greenhouse, but after a while the arduino doesn't update no more.
I had to switch out the heater because it was too weak and then the problems started. Before i switched heater, i didn't have this problem.
First i thought it was hardware or because of the heat and humidity, but same problems show up when i place the arduino out of the tent.
Here's my code:
// Temp, Humd = 998 betekend "sensor not detected"
#include <Wire.h>
#include <DS3231.h>
#include "SparkFunHTU21D.h"
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
HTU21D myHumidity;
DS3231 rtc(A4, A5);
Time t;
unsigned long tod;
bool dag;
bool lucht;
bool warm;
bool vocht;
bool licht;
// Eigen karakter maken op site: https://arduinogetstarted.com/tutorials/arduino-lcd-i2c
byte customChar[8] = {
0b01100,
0b10010,
0b10010,
0b01100,
0b00000,
0b00000,
0b00000,
0b00000
};
void setup()
{
Serial.begin(9600);
Serial.println("Booting");
myHumidity.begin();
rtc.begin();
lcd.begin();
lcd.backlight();
// TIJD RTC INSTELLEN
//rtc.setDOW(MONDAY); // Set Day-of-Week to SUNDAY
//rtc.setTime(12, 44, 10); // Set the time to 12:00:00 (24hr format)
//rtc.setDate(20, 3, 2023); // Set the date to January 1st, 2014
lcd.createChar(0, customChar); // create a new custom character
pinMode(12, OUTPUT); // Ultrasone mist maker
pinMode(11, OUTPUT); // Buisverwarming
pinMode(10, OUTPUT); // Verlichting
pinMode(9, OUTPUT); // Luchtcirculatie
}
void loop()
{
t = rtc.getTime();
float humd = myHumidity.readHumidity();
float temp = myHumidity.readTemperature();
unsigned long tod = t.hour*60 + t.min; // Tijd omzetten in RTC code in aantal minuten
// LCD scherm opstelling
lcd.clear();
lcd.setCursor(0, 0); // Cursor op positie (0, 0) zetten
lcd.print("T: "); // Text op gekozen positie
lcd.setCursor(3, 0);
lcd.print(temp, 1); // Actieve temperatuurs weergave
lcd.setCursor(7, 0);
lcd.write((byte)0);
lcd.setCursor(8, 0);
// Onderste lijn
lcd.setCursor(0, 1);
lcd.print("RV:"); // Text op gekozen positie
lcd.setCursor(3, 1);
lcd.print(humd, 1); // Active relatieve vochtigheid
lcd.setCursor(7, 1);
lcd.print("%");
lcd.setCursor(11, 1); // Klok
lcd.print(t.hour);
lcd.setCursor(13, 1);
lcd.print(":");
lcd.setCursor(14, 1);
lcd.print(t.min);
// Seriële monitor
Serial.print(dag);
Serial.print(" : ");
Serial.print(tod);
Serial.print(" T: ");
Serial.print(temp, 1);
Serial.print("C");
Serial.print(" R.V.: ");
Serial.print(humd, 1);
Serial.print("% ");
Serial.print(" Lucht: ");
Serial.print(lucht);
Serial.print(" Warm: ");
Serial.print(warm);
Serial.print(" Vocht: ");
Serial.print(vocht);
Serial.print(" Licht ");
Serial.print(licht);
//Verluchting
if (tod >= 405 && tod <= 1339) { // Tijd van "aan" en "uit" schakelen luchtCIRCULATIE
digitalWrite(9, LOW);
lucht = true;
} else if (humd >= 85.0) { // Ook als RV boven 85% komt, aan gaan
digitalWrite(9, LOW);
lucht = true;
}
else {
digitalWrite(9, HIGH);
lucht = false;
}
// Temperatuur regeling
if (tod >= 410 && tod <= 1259) { // DAG REGELING, verwarming gaat 15min vroeger aan dan zonsopgang
if (temp <= 21.7) { // MIN
digitalWrite(11, LOW); // Verwarming gaat AAN
warm = true;
}
if (temp >= 22.2) { // MAX
digitalWrite(11, HIGH); // Verwarming gaat UIT
warm = false;
}
} else { // NACHT REGELING
if (temp <= 17.8) { // MIN
digitalWrite(11, LOW); // Verwarming gaat AAN
warm = true;
}
if (temp >= 18.3) { // MAX
digitalWrite(11, HIGH); // Verwarming gaat UIT
warm = false;
}
}
// Vocht regeling
if (tod >= 420 && tod <= 1319) {
if (humd <= 79.0) { // MINIMUM vocht !!
digitalWrite(12, LOW); // Verwarming gaat AAN
vocht = true;
}
if (humd >= 82) { // MAXIMUM vocht !!
digitalWrite(12, HIGH); // Verwarming gaat UIT
vocht = false;
}
} else { // S'nachts geen vocht meer bijgeven
digitalWrite(12, HIGH);
vocht = false;
}
//Verlichtings schema
if (tod >= 420 && tod <= 1319){ // Overdagse tijd
digitalWrite(10, LOW);
licht = true;
} else{
digitalWrite(10, HIGH);
licht = false;
}
Serial.println();
delay(5000);
}
Ur help would be appreciated!