diff --git a/src/main.cpp b/src/main.cpp index ab26b0a..2d064df 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,21 +3,36 @@ #include #include -#ifndef STASSID -#define STASSID "machbar" -#define STAPSK "machbar-wireless" -#endif +//Capacitive touch sensor +#define ANALOG_READ_PIN A0 //GPIO 5 +#include -const char* ssid = STASSID; -const char* password = STAPSK; + +int sensorValue = 0; +int letzteWerte[100]; +int idWert = 0; + + +// IP Addresse wie bei der Feuerwehr! IPAddress apIP(192, 168, 112, 1); + + + + + +/// Brauchen wir bald nicht mehr int pushButton = D8; int lastbuttonstate = 0; + + + + int auftrittmillis = 0; int abtrittmillis = 0; - int auftrittzeiten[20]; int kontaktzeiten[20]; + + int idx = 0; String websiteA = "Sensor" @@ -33,10 +48,10 @@ const int led = 13; void handleRoot() { String liste; - for(int i = 0; i < 20; i++) { - liste = liste + kontaktzeiten[i] + "\r\n"; + for(int i = 0; i < 100; i++) { + liste = liste + letzteWerte[i] + "\r\n"; } - server.send(200, "text/plain", websiteA + liste + websiteB); + server.send(200, "text/html", websiteA + liste + websiteB); } @@ -47,33 +62,42 @@ void handleNotFound() { void setup(void) { pinMode(pushButton, INPUT); + pinMode(ANALOG_READ_PIN, INPUT); pinMode(led, OUTPUT); digitalWrite(led, 0); Serial.begin(115200); WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0)); WiFi.softAP("Drucksensor"); Serial.println(""); - + Serial.println(""); - Serial.print("Connected to "); - Serial.println(ssid); Serial.print("IP address: "); Serial.println(WiFi.localIP()); - if (MDNS.begin("esp8266")) { Serial.println("MDNS responder started"); } + if (MDNS.begin("esp8266")) { Serial.println("MDNS responder osestarted"); } server.on("/", handleRoot); server.onNotFound(handleNotFound); server.begin(); - Serial.println("HTTP server started"); + Serial.println("HTTP server eierstarted"); } void loop(void) { + + + sensorValue = analogRead(ANALOG_READ_PIN); + Serial.println(sensorValue); + + letzteWerte[idWert] = sensorValue; + idWert = (idWert + 1) % 100; + + // Hier Logik ändern +/* // read the input pin: int buttonState = digitalRead(pushButton); // print out the state of the button: @@ -97,7 +121,9 @@ void loop(void) { idx = (idx + 1)%20; } lastbuttonstate = buttonState; - delay(1); // delay in between reads for stability + */ + + delay(10); // delay in between reads for stability server.handleClient(); MDNS.update(); }