Hello, everyone! I would like to know what is the best method to calibrate sensor LDR and how i find the values for sensitivity and threshold? Thank very much
This might help
I made an LDR-based Luxmeter for my sons car headlights..
calibrated by comparison with the BH1750FVI
my code
/*
* Running pr. 20.11.17
* calculate Rldr first -> Then Rldr * x^-1.6
* R ser = 6k8
The circuit: 2lines 16 char LCD panel
LCD RS pin to digital pin 2
LCD Enable pin to digital 4
LCD D4 pin to digital pin 5
LCD D5 pin to digital pin 6
LCD D6 pin to digital pin 7
LCD D7 pin to digital pin 8
LCD R/W pin to ground pin 3
LCD VSS pin to ground
LCD VCC pin to 5V
10K resistor:
ends to +5V and ground
wiper to LCD VO pin 2k2 pot
http://www.arduino.cc/en/Tutorial/LiquidCrystal
Circuite runs from 3*1,5V AA batteries
resistors for battery check 47k/12k , ref 1.1V => 5V returns analog read 948
*/
#define Rsel 3
#define Enable 4
#define Db4 5
#define Db5 6
#define Db6 7
#define Db7 8
#define vpin A0
#define s1pin A6 // !!!! this is for the pro mini , Change if using UNO
#include <LiquidCrystal.h>
LiquidCrystal lcd(Rsel, Enable, Db4, Db5, Db6, Db7);
unsigned int v1, i ; // voltage1, sensor1
float battery, Lux,Rldr,s1;
void setup()
{
Serial.begin(115200);
//Battery check
analogReference(INTERNAL); // 1.1V
analogRead(vpin); delay(300); analogRead(vpin);
v1 = analogRead(vpin);
analogRead(s1pin); // dummy read
lcd.begin(16, 2);
lcd.print("Batteri : ");
battery = v1 / 193.0;
if (battery > 3.5)
{
lcd.print(battery, 1);
lcd.print(" V");
}
else lcd.print("low !");
lcd.setCursor(0, 1);
lcd.print("Lys : ");
analogReference(DEFAULT); // back to supply current
analogRead(s1pin); delay(100);
analogRead(s1pin); delay(100);
}
void loop()
{
s1 = 0;
for (i = 0; i < 20; i++) s1 = s1 += analogRead(s1pin);
s1 = s1/20.0;
Rldr= 68.0*(1023-s1)/s1;
Lux = 200000.0*pow(Rldr,-1.6);
Serial.println(Lux);
lcd.setCursor(6, 1);
lcd.print(Lux,0);
lcd.print(" Lux ");
delay(999);
}
If you want to measure whether it's dark outside, or if a light is on or off, an LDR will do fine.
If you want to measure lux, get a lux meter, such as the TSL2591 (or the older TSL2561).