diff --git a/data/index.html b/data/index.html index 7d87641..d195f18 100644 --- a/data/index.html +++ b/data/index.html @@ -51,7 +51,7 @@
LDR Schwelle [lx]: 50 lx
- +
diff --git a/lib/treppe/treppe.cpp b/lib/treppe/treppe.cpp index 44b6a98..c9ff47a 100644 --- a/lib/treppe/treppe.cpp +++ b/lib/treppe/treppe.cpp @@ -173,11 +173,15 @@ float Treppe::read_ldr() { ldr_value = E(LDR) */ // float ldr_ohm = 37280.00 / analogRead(A0); - float voltage = analogRead(A0) * 0.0036; - float ldr_ohm = 40.57 * (3.3 - voltage) / voltage; + float vol_adc = analogRead(A0) * 0.0036; + if(vol_adc > 3.29) + vol_adc = 3.29; + + float ldr_ohm = 40.67 * (3.3 - vol_adc) / vol_adc; + float ldr_value = 6526.6 / (ldr_ohm * ldr_ohm); #ifdef LDRDEBUG - Serial.printf("Ohm: %f lux: %f Comp: %d\n", ldr_ohm, ldr_value, + Serial.printf("vol_adc: %f Ohm: %f lux: %f Comp: %d\n", vol_adc, ldr_ohm, ldr_value, param.ldr_schwelle); #endif return ldr_value; @@ -186,10 +190,6 @@ float Treppe::read_ldr() { bool Treppe::check_ldr() { static uint8_t active = 0; -#ifdef LDRDEBUG - // return true; -#endif - // follow up: averaging over many samples? float ldr = read_ldr(); diff --git a/lib/treppe/treppe.h b/lib/treppe/treppe.h index 8752c5a..a70bde3 100644 --- a/lib/treppe/treppe.h +++ b/lib/treppe/treppe.h @@ -5,8 +5,8 @@ #include "PCA9685.h" #include -//#define LDRDEBUG // comment in to override LDR measurement -#define LDR_HYS 8 // Hysteresis for switching off FSM [lux] +#define LDRDEBUG // comment in to override LDR measurement +#define LDR_HYS 100 // Hysteresis for switching off FSM [lux] #define SENSOR_OBEN 16 #define SENSOR_UNTEN 12