E(LDR) = 6526.5 / (R(LDR)^2) | E(LDR) = 6526.5 / (R(LDR)^2) | ||||
ldr_value = E(LDR) | 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); | 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; | return ldr_value; | ||||
} | } | ||||
#include <EEPROM.h> | #include <EEPROM.h> | ||||
// #define LDRDEBUG // comment in to override LDR measurement | // #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_OBEN 16 | ||||
#define SENSOR_UNTEN 12 | #define SENSOR_UNTEN 12 |