Browse Source

new ldr algo

tags/v1.0.0
Dominik Bartsch 2 years ago
parent
commit
937f7f09e7
2 changed files with 7 additions and 2 deletions
  1. 6
    1
      lib/treppe/treppe.cpp
  2. 1
    1
      lib/treppe/treppe.h

+ 6
- 1
lib/treppe/treppe.cpp View File

@@ -169,8 +169,13 @@ float Treppe::read_ldr() {
E(LDR) = 6526.5 / (R(LDR)^2)
ldr_value = E(LDR)
*/
float ldr_ohm = 37280.00 / analogRead(A0);
//float ldr_ohm = 37280.00 / analogRead(A0);
float voltage = analogRead(A0)*0.0036;
float ldr_ohm = 40.57*(3.3-voltage)/voltage;
float ldr_value = 6526.6 / (ldr_ohm * ldr_ohm);
#ifdef LDRDEBUG
Serial.printf("Ohm: %f lux: %f\n", ldr_ohm,ldr_value);
#endif
return ldr_value;
}


+ 1
- 1
lib/treppe/treppe.h View File

@@ -6,7 +6,7 @@
#include <EEPROM.h>

// #define LDRDEBUG // comment in to override LDR measurement
#define LDR_HYS 1 // Hysteresis for switching off FSM [lux]
#define LDR_HYS 5 // Hysteresis for switching off FSM [lux]

#define SENSOR_OBEN 16
#define SENSOR_UNTEN 12

Loading…
Cancel
Save