From f95e6a8b0fbd4b2af4a1a5d78d0f75c0265aa8d0 Mon Sep 17 00:00:00 2001 From: jakobst1n Date: Thu, 19 Jul 2018 15:20:46 +0200 Subject: Add basic OTA, Clap-sensing code --- Luxcena-cs.ino | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Luxcena-cs.ino b/Luxcena-cs.ino index 41bef63..16bad53 100644 --- a/Luxcena-cs.ino +++ b/Luxcena-cs.ino @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,7 @@ int sensorthreshold = 600; int bufferKey[6] = {0, 0, 1, 0, 1, 0}; ESP8266WebServer server ( 80 ); // webServer on port 80 +ESP8266HTTPUpdateServer httpUpdater; void setup ( void ) { // Activate serial @@ -134,10 +136,12 @@ void setup ( void ) { Serial.println(myIP); } - if ( MDNS.begin ( "esp8266" ) ) { + if ( MDNS.begin ( "clapSensor" ) ) { Serial.println ( "MDNS responder started" ); } + httpUpdater.setup(&server); + // Gui server.on ( "/", handleRoot ); server.on ( "/settings", handleSettings ); @@ -178,17 +182,20 @@ void loop ( void ) { eventStatus = 0; sensorValue = analogRead(A0); + //Serial.println(sensorValue); delay(1); if (eventStatus == 0) { if (sensorValue > sensorThresholdHigh) { + Serial.println("Level up: 1"); eventStatus = 1; } } - if (eventStatus == 0) { + if (eventStatus == 1) { for (int i = 0; i > 10; i++) { sensorValue = analogRead(A0); if(sensorValue < sensorthresholdLow) { + Serial.println("Level up: 2"); eventStatus = 2; break; } @@ -199,12 +206,14 @@ void loop ( void ) { sensorValue = analogRead(A0); delay(1); if (sensorValue > sensorThresholdHigh) { + Serial.println("Level up: 3"); eventStatus = 3; break; } } } if (eventStatus == 3) { + Serial.println("TOGGLE!!!!!!"); setLamp("TOGGLE"); } -- cgit v1.2.3