diff --git a/.gitignore b/.gitignore index eb54202..3b14a85 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .autogit *.txt -*.pdf \ No newline at end of file +*.pdf +output/ \ No newline at end of file diff --git a/.vscode/arduino.json b/.vscode/arduino.json new file mode 100644 index 0000000..13c2e29 --- /dev/null +++ b/.vscode/arduino.json @@ -0,0 +1,7 @@ +{ + "board": "esp8266:esp8266:d1_mini", + "configuration": "xtal=80,vt=flash,exception=legacy,ssl=all,eesz=4M2M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=921600", + "port": "COM4", + "sketch": "Steuerung_Truhen.ino", + "output": "output" +} \ No newline at end of file diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..f5fedb7 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,17 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "C:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\**", + "C:\\Users\\User\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.6.0\\**" + ], + "forcedInclude": [], + "intelliSenseMode": "msvc-x64", + "compilerPath": "/usr/bin/gcc", + "cStandard": "gnu11", + "cppStandard": "gnu++14" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..9c4b16d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "window.zoomLevel": 0, + "arduino.path": "C:\\Program Files (x86)\\Arduino", + "git.autofetch": true, + "C_Cpp.updateChannel": "Insiders", + "arduino.additionalUrls": "" +} \ No newline at end of file diff --git a/DHT.zip b/DHT.zip deleted file mode 100644 index 064fbff..0000000 Binary files a/DHT.zip and /dev/null differ diff --git a/Settings.h b/Settings.h new file mode 100644 index 0000000..7a0b497 --- /dev/null +++ b/Settings.h @@ -0,0 +1,26 @@ +//* **EINSTELLUNGEN** *// +#define SETUPTIMEOUT 500 + +// So, the minimum sampling period is the minimum time +// interval that we need to wait between two consecutive +// measurements from the sensor. In the case of the DHT22, +// this value is of 2 seconds [1]. + +static const unsigned long MESS_REFRESH_INTERVAL = 10000; // ms getMinimumSamplingPeriod == 2 sec +static const unsigned long SCHALT_REFRESH_INTERVAL = 60000; // ms +static const unsigned long LCD_REFRESH_INTERVAL = 500; // ms + +const int uT = 1; //Abschalt-Temperatur in °C +const int oT = 4; //Einschalt-Temperatur in °C + +/* +Truhe truhen[] = { + Truhe("Truhe 1", 2, 8), + Truhe("Truhe 2", 3, 9), +};*/ +//Name, Relaypin, DTH Pin +Truhe truhen[] = { + Truhe("Truhe 1", D0, D2), +}; + +//LiquidCrystal_I2C lcd(0x3F, 0, 0, 0, 0, 0, 0, 0, 0, POSITIVE); //0x3F = Adresse des Displays diff --git a/Settings.h.original b/Settings.h.original new file mode 100644 index 0000000..7a0b497 --- /dev/null +++ b/Settings.h.original @@ -0,0 +1,26 @@ +//* **EINSTELLUNGEN** *// +#define SETUPTIMEOUT 500 + +// So, the minimum sampling period is the minimum time +// interval that we need to wait between two consecutive +// measurements from the sensor. In the case of the DHT22, +// this value is of 2 seconds [1]. + +static const unsigned long MESS_REFRESH_INTERVAL = 10000; // ms getMinimumSamplingPeriod == 2 sec +static const unsigned long SCHALT_REFRESH_INTERVAL = 60000; // ms +static const unsigned long LCD_REFRESH_INTERVAL = 500; // ms + +const int uT = 1; //Abschalt-Temperatur in °C +const int oT = 4; //Einschalt-Temperatur in °C + +/* +Truhe truhen[] = { + Truhe("Truhe 1", 2, 8), + Truhe("Truhe 2", 3, 9), +};*/ +//Name, Relaypin, DTH Pin +Truhe truhen[] = { + Truhe("Truhe 1", D0, D2), +}; + +//LiquidCrystal_I2C lcd(0x3F, 0, 0, 0, 0, 0, 0, 0, 0, POSITIVE); //0x3F = Adresse des Displays diff --git a/Truhe.cpp b/Truhe.cpp new file mode 100644 index 0000000..67f08b5 --- /dev/null +++ b/Truhe.cpp @@ -0,0 +1,46 @@ +#include "Truhe.h" +Truhe::Truhe(String name, int relay, uint8_t dhtpin): _dht(dhtpin, DHT22) { + _name = name; + _relay = relay; + _dhtpin = dhtpin; + +}; + +void Truhe::setup() { + Serial.println("Setup " + _name); + Serial.println(_dhtpin); + pinMode(_relay, OUTPUT); + digitalWrite(_relay, HIGH); + pinMode(_dhtpin, INPUT); + _dht.begin(); + delay(2000); +} + +void Truhe::mess() { + Serial.println(String(_name) + " mess()"); + //Serial.print("Minimum Sampling Period: "); + //delay(_dht.getMinimumSamplingPeriod()); + _cur_temp = _dht.readTemperature(); + Serial.println(String(_name) + "\t\t" + String((int)_cur_temp) + " grad gelesen"); +}; + +void Truhe::schalt(int oT, int uT) { + Serial.print(String(_name) + " schalt() stat: " + String(_stat)); + if (_cur_temp >= oT && _stat != 1) { + digitalWrite(_relay, LOW); + _stat = 1; + Serial.println("schalt " + _name + " zu " + String(_stat)); + } + else if (_cur_temp <= uT && _stat != 0) { + digitalWrite(_relay, HIGH); + _stat = 0; + Serial.println("schalt " + _name + " zu " + String(_stat)); + } +} +int Truhe::getUpdLcd(){ return _updlcd;}; +void Truhe::setUpdLcd(int updlcd){ _updlcd = updlcd;}; +int Truhe::getRelay(){ return _relay;}; +int Truhe::getDhtPin(){return _dhtpin;}; +int Truhe::getStat(){return _stat;}; +float Truhe::getCurTemp(){return _cur_temp;}; +String Truhe::getName(){return _name;}; diff --git a/Truhe.h b/Truhe.h new file mode 100644 index 0000000..71a3e84 --- /dev/null +++ b/Truhe.h @@ -0,0 +1,23 @@ +#include +class Truhe { + private: + DHT _dht; + int _relay; + uint8_t _dhtpin; + int _stat = -1; + float _cur_temp = 0; + int _updlcd = 0; + String _name = ""; + public: + Truhe(String, int, uint8_t); + void setup(); + void mess(); + void schalt(int, int); + int getUpdLcd(); + void setUpdLcd(int); + int getRelay(); + int getDhtPin(); + int getStat(); + float getCurTemp(); + String getName(); +};