Initial commit
This commit is contained in:
commit
3f25265bd8
104
TankCool.ino
Normal file
104
TankCool.ino
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
// First we include the libraries
|
||||||
|
#include <OneWire.h>
|
||||||
|
#include <DallasTemperature.h>
|
||||||
|
#include <Controllino.h>
|
||||||
|
#include <SPI.h>
|
||||||
|
#include <Ethernet.h>
|
||||||
|
|
||||||
|
/********************************************************************/
|
||||||
|
// Data wire is plugged into pin 2 on the Arduino
|
||||||
|
#define ONE_WIRE_BUS 20
|
||||||
|
/********************************************************************/
|
||||||
|
// Setup a oneWire instance to communicate with any OneWire devices
|
||||||
|
// (not just Maxim/Dallas temperature ICs)
|
||||||
|
OneWire oneWire(ONE_WIRE_BUS);
|
||||||
|
/********************************************************************/
|
||||||
|
// Pass our oneWire reference to Dallas Temperature.
|
||||||
|
DallasTemperature sensors(&oneWire);
|
||||||
|
/********************************************************************/
|
||||||
|
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x09, 0x70 };
|
||||||
|
IPAddress ip(192,168,178,57);
|
||||||
|
EthernetServer server(80);
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
// start serial port
|
||||||
|
Serial.begin(9600);
|
||||||
|
// Start up the library
|
||||||
|
sensors.begin();
|
||||||
|
Ethernet.begin(mac, ip);
|
||||||
|
server.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
// put your main code here, to run repeatedly:
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebServer(){
|
||||||
|
// ETHERNET
|
||||||
|
EthernetClient client = server.available();
|
||||||
|
// Wenn es einen Client gibt, dann...
|
||||||
|
if (client) {
|
||||||
|
Serial.println("Neuer Client");
|
||||||
|
// Jetzt solange Zeichen lesen, bis eine leere Zeile empfangen wurde
|
||||||
|
// HTTP Requests enden immer mit einer leeren Zeile
|
||||||
|
boolean currentLineIsBlank = true;
|
||||||
|
// Solange Client verbunden
|
||||||
|
while (client.connected()) {
|
||||||
|
// client.available() gibt die Anzahl der Zeichen zurück, die zum Lesen
|
||||||
|
// verfügbar sind
|
||||||
|
if (client.available()) {
|
||||||
|
// Ein Zeichen lesen und am seriellen Monitor ausgeben
|
||||||
|
char c = client.read();
|
||||||
|
Serial.write(c);
|
||||||
|
// In currentLineIsBlank merken wir uns, ob diese Zeile bisher leer war.
|
||||||
|
// Wenn die Zeile leer ist und ein Zeilenwechsel (das \n) kommt,
|
||||||
|
// dann ist die Anfrage zu Ende und wir können antworten
|
||||||
|
if (c == '\n' && currentLineIsBlank) {
|
||||||
|
client.println("HTTP/1.1 200 OK");
|
||||||
|
client.println("Content-Type: text/html");
|
||||||
|
client.println("Connection: close"); // Verbindung wird nach Antwort beendet
|
||||||
|
client.println("Refresh: 30"); // Seite alle 25 Sekunden neu abfragen
|
||||||
|
client.println();
|
||||||
|
// Ab hier berginnt der HTML-Code, der an den Browser geschickt wird
|
||||||
|
client.println("<!DOCTYPE HTML>");
|
||||||
|
client.println("<html>");
|
||||||
|
client.println("<head><title>CONTROLLINO Analog Input</title></head>");
|
||||||
|
client.println("<body><h3>CONTROLLINO</h3>");
|
||||||
|
|
||||||
|
client.println("<p>");
|
||||||
|
client.print("Aktuelle Temperatur: ");
|
||||||
|
client.println(temperatureA);
|
||||||
|
client.println("</p>");
|
||||||
|
client.println("<p>");
|
||||||
|
client.print("Sollwert Temperatur: ");
|
||||||
|
client.println(temperatureSP);
|
||||||
|
client.println("</p>");
|
||||||
|
client.println("<p>");
|
||||||
|
client.print("Delta Temperatur: ");
|
||||||
|
client.println(DeltaT);
|
||||||
|
client.println("</p>");
|
||||||
|
client.write("<form method=GET>T: <input type=text name=t>");
|
||||||
|
client.write("R: <input type=text name=r><input type=submit></form>");
|
||||||
|
client.println(r,t);
|
||||||
|
client.println("</body></html>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (c == '\n') {
|
||||||
|
// Zeilenwechsel, also currentLineIsBlack erstmal auf True setzen
|
||||||
|
currentLineIsBlank = true;
|
||||||
|
}
|
||||||
|
else if (c != '\r') {
|
||||||
|
// Zeile enthält Zeichen, also currentLineIsBlack auf False setzen
|
||||||
|
currentLineIsBlank = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Kleine Pause
|
||||||
|
delay(1);
|
||||||
|
// Verbindung schliessen
|
||||||
|
client.stop();
|
||||||
|
Serial.println("Verbindung mit Client beendet.");
|
||||||
|
Serial.println("");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue