Servus
Delays sind drin
Hier die der Poolsteurung
// Date and time functions using a DS3231 RTC connected via I2C and Wire lib
#include <Wire.h>
#include "RTClib.h"
#include <LiquidCrystal.h>
RTC_DS3231 rtc;
char daysOfTheWeek[7][12] = {"So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"};
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup () {
#ifndef ESP8266
while (!Serial);
#endif
Serial.begin(9600);
Serial.println("Pumpenlaufzeit");
pinMode(40,OUTPUT);
delay(3000); // wait for console opening
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}
if (rtc.lostPower()) {
Serial.println("RTC lost power, lets set the time!");
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2); //LCD Zeile 1
lcd.print("Poolsteuerung"); //Startanzeige vom LCD Display
lcd.setCursor(0, 1); //LCD Zeile 2
lcd.print("MW"); //Schreibe Text
delay(10000); //Wartezeit
}
}
void loop () {
DateTime now = rtc.now();
Serial.print(now.year(), DEC); //Serial Ausgabe Zeiten
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" (");
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
Serial.print(") ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
Serial.print("Temperature: "); //Serial Ausgabe Temperatur
Serial.print(rtc.getTemperature());
Serial.println(" C");
Serial.println();
delay(1000);
{
lcd.setCursor(0, 1); //Cursor in Zeile 2
// print the number of seconds since reset:
lcd.print(millis() / 1000);
}
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print(now.hour(), DEC);
lcd.print(":");
lcd.print(now.minute(), DEC);
lcd.print(" ");
lcd.print(now.day(), DEC);
lcd.print(".");
lcd.print(now.month(), DEC);
lcd.print(".");
lcd.print(now.year(), DEC);
delay(5000);
lcd.clear();
lcd.begin(16, 2);
//lcd.print(daysOfTheWeek[now.dayOfTheWeek()]);
lcd.print("Technik ");
lcd.print(rtc.getTemperature());
lcd.print("\337C");
lcd.setCursor(0, 1);
lcd.print("Pool ");
lcd.print(" \337C");
//Variable
//
float pumpe = 6, volumen = 12.08, pleistung = 0, mlaufzeit = 0,dtemp = 0, atemp = 32, ptemp = 28, pltemp = 0, tnausgleichA = 0, tnausgleichB = 0, vorm = 0, nachm = 0;
int dptemp = 0, endzn = 0;
Serial.print("Pumpenleistung ");
Serial.println(pumpe); //Ausgabe Variable Pumpenleistung
Serial.print("Poolvolumen "); //schreibe Poolvolumen
Serial.println(volumen); // Ausgabe Variable Poolvolumen
Serial.print("Pumpenlaufzeit 75% "); //Schreibe Pumpenlaufzeit berchnet auf 75%
Serial.println(pleistung = (pumpe/100)*75); //Ergebnis 75% Pumpenleistung
Serial.print("min. Laufzeit "); //schreibe min. Laufzeit
Serial.println(mlaufzeit = (volumen / pleistung)); //Ergebnis min Laufzeit
Serial.print("Aussentemperatur ");
Serial.println(atemp);
Serial.print("Pooltemparatur ");
Serial.println(ptemp);
Serial.print("Durchschnitt Temp (Pool/Aussen) ");
Serial.println(dtemp = (atemp + ptemp)/2);
Serial.print("Pumpenlaufzeit nach Temp ");
Serial.println(pltemp = (dtemp/2));
Serial.print("Tag / Nacht Ausgleich zwischenberechnung ");
Serial.println(tnausgleichA = dtemp/2);
Serial.print("Tag / Nacht Ausgleich ");
Serial.println(tnausgleichB = (tnausgleichA/2)/1.1);
Serial.print("Duchschnitt Laufzeit Pumpe nach Temperatur ");
Serial.println(dptemp = ((tnausgleichB + mlaufzeit)/2)+2);
Serial.println("Verteilung Zeiten vormittag / Nachmittag");
Serial.print("Vormittag ");
Serial.println(vorm = dptemp/2);
Serial.print("Nachmittag ");
Serial.println(nachm = dptemp/2);
Serial.println("Startzeit vormittag 9:00");
Serial.print("Endzeit vormittag ");
Serial.println(9 + vorm);
Serial.println("Startzeit nachmittag 15:00");
Serial.print("Endzeit nachmittag ");
Serial.println(endzn = (15 + nachm));
Serial.println();
delay(10000);
}
}
Hier sind die Daten zum Senoren auslesen
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 6
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup()
{
Serial.begin(9600);
sensors.begin();
}
void loop()
{
sensors.requestTemperatures();
Serial.println("Temperaturen");
Serial.print("Pool ");
Serial.print(sensors.getTempCByIndex(0));
Serial.println(" °C");
Serial.print("Solar Absorber ");
Serial.print(sensors.getTempCByIndex(1));
Serial.println(" °C");
Serial.println("");
delay(2000);
}