Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
Danke für den Code. Sieht gar nicht so schlimm aus!
Im Augenblick verwende ich meinen Ardulino nur zum Loggen von Temperaturen, weit entfernt vom Haus.
Real Time Clock, Batteriebetrieb, Speichern der Daten auf SD-Karte.
http://chiliforum.hot-pain.de/threads/vlies-gewaechshaus-ein-erfahrungsbericht.26071/#post-631420
Meine Raspberry verwende ich auf dem Balkon zur Temperaturüberwachung und Wetteraufzeichnung. Hauptsächlich im Frühjahr und Herbst wenn die Temperaturen kritisch sind.
http://chiliforum.hot-pain.de/threads/raspberry-pi-experimente.26848/
Das große Projekt "Erdfeuchtigkeit messen und damit die Bewässerung steuern" kommt sobald ich etwas Zeit habe.
Was mich an der Umsetzung noch hindert ist das Messen der Feuchtigkeit der Erde.
Dabei kommt es durch den Messstrom zu einer Elektrolyse. Auch bei Edelstahl begeben sich Metallionen auf die Wanderschaft. Ich mache mir deutliche Sorgen, dass dadurch die Erde und damit die Pflanzen mit Schwermetallen belastet werden.
Sobald ich dafür eine günstige und gesundheitlich unkritische Lösung gefunden habe geht es los.
// Set up SoftwareSerial
#include <SoftwareSerial.h>
SoftwareSerial esp(3, 4); //ESP Rx/Tx
// Set up float converter
//#include <stdlib.h>
// Set up macros for wifi and Thing Speak connection.
#define SSID "WLAN SSID WLAN SSID" // SSID
#define PASS "PWD PWD PWD" // Password
#define TSKEY "THINGSPEAK-KEY" // Thingspeak Key
#define IP "184.106.153.149" // thingspeak.com
int habanero;
int habaneroorange;
int pwhabanero = 5; //Power PIN 5, to get less oxidation
int pwhabaneroorange = 6; //Power PIN 6, to get less oxidation
int humidity;
int humidity2;
void setup()
{
Serial.begin(9600);
Serial.println("");
Serial.println("Setup gestarted...");
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
analogWrite(5, 0);
analogWrite(6, 0);
esp.begin(9600);
delay(5000);
connectWiFi();
Serial.println("Setup fertig");
Serial.println("");
delay(1000);
}
void loop()
{
analogWrite(5, 204); //255 * 4/5 = 204 == 4V
delay(1);
habanero = analogRead(A0); //PIN 5 is POWER for A0!
analogWrite(5, 0);
habanero = constrain (habanero, 511, 1023); //At about 50%, the plants hang down, so ...
humidity = map (habanero, 511, 1023, 100, 0); //...I maped 50% to 0, decide by yourself, Reset : 0 instead of 511
analogWrite(6, 204); //255 * 4/5 = 204 == 4V
delay(1);
habaneroorange = analogRead(A1); //PIN 6 is POWER for A1!
analogWrite(6, 0);
habaneroorange = constrain (habaneroorange, 511, 1023); //At about 50%, the plants hang down, so ...
humidity2 = map (habaneroorange, 511, 1023, 100, 0); //...I maped 50% to 0, decide by yourself, Reset : 0 instead of 511
String value = String(humidity);
String value2 = String(humidity2);
sendData(value, value2);
delay(360000); //1000 == 1sec -> 36000 == 6min
}
void sendData(String thabanero, String thabaneroorange)
{
// Set up TCP connection.
String cmd = "AT+CIPSTART=\"TCP\",\"";
cmd += IP;
cmd += "\",80";
esp.println(cmd);
Serial.println(cmd);
delay(500);
if(esp.find("Error"))
{
Serial.println("ERROR - UPLOAD 1");
delay(500);
asm volatile ("jmp 0"); // Restart the program, wifi is essential
return;
}
cmd = "GET /update?key=";
cmd += TSKEY;
cmd += "&field3=";
cmd += thabanero;
cmd += "&field4=";
cmd += thabaneroorange;
String precmd = "AT+CIPSEND=" + String(cmd.length() + 4);
esp.println(precmd);
Serial.println(precmd);
delay(1000);
if(esp.find(">")) //AT+CIPSEND antwortet mit ">"
{
esp.println(cmd);
delay(500);
Serial.println(cmd);
esp.println("AT+CIPCLOSE");
}
else
{
esp.println(cmd);
delay(500);
Serial.println("ERROR - UPLOAD 2"); // alert user
Serial.println(cmd);
esp.println("AT+CIPCLOSE");
delay(500);
asm volatile ("jmp 0"); // Restart the program, wifi is essential
}
Serial.print("Habanero Orange ");
Serial.print(humidity);
Serial.println("%");
Serial.print("Bio Habanero ");
Serial.print(humidity2);
Serial.println("%");
Serial.println("");
}
boolean connectWiFi()
{
Serial.println("ESP8266 - Start");
delay(500);
esp.println("AT+RST");
delay(2000);
esp.println("AT+CWMODE=1");
delay(1000);
esp.println("AT+CIPMODE=1");
delay(1000);
String cmd = "AT+CWJAP=\"";
cmd += SSID;
cmd += "\",\"";
cmd += PASS;
cmd += "\"";
esp.println(cmd);
delay(2000);
if (esp.find("OK"))
{
Serial.println("OK, mit WiFi verbunden.");
Serial.println("");
return true;
}
else
{
Serial.println("Keine Verbindung zum W-Lan."), ("Restart des Systems in einigen Sekunden...");
delay(2000);
Serial.println("Restart");
delay(500);
asm volatile ("jmp 0"); // Restart the program, wifi is essential
return false;
}
}
asm volatile ("jmp 0"); // Restart the program, wifi is essential
// Set up SoftwareSerial
#include <SoftwareSerial.h>
SoftwareSerial esp(3, 4); //ESP Rx/Tx
// Set up float converter
//#include <stdlib.h>
// Set up macros for wifi and Thing Speak connection.
#define SSID "SSID-WLAN" // SSID
#define PASS "PWD-WLAN" // Password
#define TSKEY "THINGSPEAK-KEY" // Thingspeak Key
#define IP "184.106.153.149" // thingspeak.com
int apache;
int jalapeno;
int counter = 0;
int pwapache = 5; //Power PIN 5, to get less oxidation
int pwjalapeno = 6; //Power PIN 6, to get less oxidation
int humidity;
int humidity2;
void setup()
{
Serial.begin(9600);
Serial.println("");
Serial.println("Setup gestarted...");
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
analogWrite(5, 0);
analogWrite(6, 0);
esp.begin(9600);
delay(5000);
connectWiFi();
Serial.println("Setup fertig");
Serial.println("");
delay(1000);
}
void loop()
{
analogWrite(5, 204); //255 * 4/5 = 204 == 4V
delay(2000);
apache = analogRead(A0); //PIN 5 is POWER for A0!
analogWrite(5, 0);
apache = constrain (apache, 511, 1023); //At about 50%, the plants hang down, so ...
humidity = map (apache, 511, 1023, 100, 0); //...I maped 50% to 0, decide by yourself, Reset : 0 instead of 511
analogWrite(6, 204); //255 * 4/5 = 204 == 4V
delay(2000);
jalapeno = analogRead(A1); //PIN 6 is POWER for A1!
analogWrite(6, 0);
jalapeno = constrain (jalapeno, 511, 1023); //At about 50%, the plants hang down, so ...
humidity2 = map (jalapeno, 511, 1023, 100, 0); //...I maped 50% to 0, decide by yourself, Reset : 0 instead of 511
String value = String(humidity);
String value2 = String(humidity2);
sendData(value, value2);
delay(360000); //1000 == 1sec -> 360000 == 6min
}
void sendData(String tapache, String tjalapeno)
{
// Set up TCP connection.
String cmd = "AT+CIPSTART=\"TCP\",\"";
cmd += IP;
cmd += "\",80";
esp.println(cmd);
Serial.println(cmd);
delay(500);
if(esp.find("Error"))
{
Serial.println("ERROR - UPLOAD 1");
delay(500);
counter += 1;
restart();
return;
}
cmd = "GET ";
cmd += "/update?api_key=";
cmd += TSKEY;
cmd += "&field1=";
cmd += tapache;
cmd += "&field2=";
cmd += tjalapeno;
String precmd = "AT+CIPSEND=" + String(cmd.length() + 4);
esp.println(precmd);
Serial.println(precmd);
delay(1000);
if(esp.find(">")) //AT+CIPSEND antwortet mit ">"
{
esp.println(cmd);
delay(500);
Serial.println(cmd);
esp.println("AT+CIPCLOSE");
}
else
{
esp.println(cmd);
delay(500);
Serial.println("ERROR - UPLOAD 2"); // alert user
Serial.println(cmd);
esp.println("AT+CIPCLOSE");
delay(500);
counter += 1;
restart();
}
Serial.print("Apache F1 ");
Serial.print(humidity);
Serial.println("%");
Serial.print("Jalapeno ");
Serial.print(humidity2);
Serial.println("%");
Serial.println("");
}
boolean connectWiFi()
{
Serial.println("ESP8266 - Start");
delay(500);
esp.println("AT+RST");
delay(2000);
esp.println("AT+CWMODE=1");
delay(1000);
esp.println("AT+CIPMODE=1");
delay(1000);
String cmd = "AT+CWJAP=\"";
cmd += SSID;
cmd += "\",\"";
cmd += PASS;
cmd += "\"";
esp.println(cmd);
delay(2000);
if (esp.find("OK"))
{
Serial.println("OK, mit WiFi verbunden.");
Serial.println("");
return true;
}
else
{
Serial.println("Keine Verbindung zum W-Lan."), ("Restart des Systems in einigen Sekunden...");
delay(2000);
Serial.println("Restart");
delay(500);
asm volatile ("jmp 0"); // Restart the program, wifi is essential
return false;
}
}
void restart()
{
if (counter >= 3)
{
Serial.println("3 Upload-Fehler, starte neu!");
delay(500);
asm volatile ("jmp 0"); // Restart the program, wifi is essential
}
}
// Set up SoftwareSerial
#include <SoftwareSerial.h>
SoftwareSerial esp(3, 4); //ESP Rx/Tx
// Set up float converter
//#include <stdlib.h>
// Set up macros for wifi and Thing Speak connection.
#define SSID "WLAN-SSID" // SSID
#define PASS "WLAN-PWD" // Password
#define TSKEY "THINGSPEAK-KEY" // Thingspeak Key
#define IP "184.106.153.149" // thingspeak.com
int apache;
int jalapeno;
int counter = 0;
int pwapache = 5; //Power PIN 5, to get less oxidation
int pwjalapeno = 6; //Power PIN 6, to get less oxidation
int humidity;
int humidity2;
void setup()
{
Serial.begin(9600);
Serial.println("");
Serial.println("Setup gestarted...");
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
esp.begin(9600);
delay(5000);
connectWiFi();
Serial.println("Setup fertig");
Serial.println("");
delay(1000);
}
void loop()
{
digitalWrite(5, HIGH);
delay(2000);
apache = analogRead(A0); //PIN 5 is POWER for A0!
digitalWrite(5, LOW);
apache = constrain (apache, 511, 1023); //At about 50%, the plants hang down, so ...
humidity = map (apache, 511, 1023, 100, 0); //...I maped 50% to 0, decide by yourself, Reset : 0 instead of 511
digitalWrite(6, HIGH);
delay(2000);
jalapeno = analogRead(A1); //PIN 6 is POWER for A1!
digitalWrite(6, LOW);
jalapeno = constrain (jalapeno, 511, 1023); //At about 50%, the plants hang down, so ...
humidity2 = map (jalapeno, 511, 1023, 100, 0); //...I maped 50% to 0, decide by yourself, Reset : 0 instead of 511
String value = String(humidity);
String value2 = String(humidity2);
sendData(value, value2);
delay(360000); //1000 == 1sec -> 360000 == 6min
}
void sendData(String tapache, String tjalapeno)
{
// Set up TCP connection.
String cmd = "AT+CIPSTART=\"TCP\",\"";
cmd += IP;
cmd += "\",80";
esp.println(cmd);
Serial.println(cmd);
delay(500);
if(esp.find("Error"))
{
Serial.println("ERROR - UPLOAD 1");
delay(500);
counter += 1;
restart();
return;
}
cmd = "GET ";
cmd += "/update?api_key=";
cmd += TSKEY;
cmd += "&field1=";
cmd += tapache;
cmd += "&field2=";
cmd += tjalapeno;
String precmd = "AT+CIPSEND=" + String(cmd.length() + 4);
esp.println(precmd);
Serial.println(precmd);
delay(1000);
if(esp.find(">")) //AT+CIPSEND antwortet mit ">"
{
esp.println(cmd);
delay(500);
Serial.println(cmd);
esp.println("AT+CIPCLOSE");
}
else
{
esp.println(cmd);
delay(500);
Serial.println("ERROR - UPLOAD 2"); // alert user
Serial.println(cmd);
esp.println("AT+CIPCLOSE");
delay(500);
counter += 1;
restart();
}
Serial.print("Apache F1 ");
Serial.print(humidity);
Serial.println("%");
Serial.print("Jalapeno ");
Serial.print(humidity2);
Serial.println("%");
Serial.println("");
}
boolean connectWiFi()
{
Serial.println("ESP8266 - Start");
delay(500);
esp.println("AT+RST");
delay(2000);
esp.println("AT+CWMODE=1");
delay(1000);
esp.println("AT+CIPMODE=1");
delay(1000);
String cmd = "AT+CWJAP=\"";
cmd += SSID;
cmd += "\",\"";
cmd += PASS;
cmd += "\"";
esp.println(cmd);
delay(2000);
if (esp.find("OK"))
{
Serial.println("OK, mit WiFi verbunden.");
Serial.println("");
return true;
}
else
{
Serial.println("Keine Verbindung zum W-Lan."), ("Restart des Systems in einigen Sekunden...");
delay(2000);
Serial.println("Restart");
delay(500);
asm volatile ("jmp 0"); // Restart the program, wifi is essential
return false;
}
}
void restart()
{
if (counter >= 3)
{
Serial.println("3 Upload-Fehler, starte neu!");
delay(500);
asm volatile ("jmp 0"); // Restart the program, wifi is essential
}
}