Normally in photography we use light meter. Unfortunately, good light meter is not cheap. It is difficult to measure in light in Lux but possible to measure in some units although exactly Lux. That possibly able to deliver an idea about intensity of light. Here is How To on Light Measurement With Arduino, LDR and LCD. We have basic guides around LDR with Arduino., however that is far from meeting a basic need.
Light Measurement With Arduino, LDR and LCD
The basic circuit diagram of Arduino with LCD is like we described in our guide on how to setup Arduino with 1602A LCD Display. Circuit diagram is easy if you followed our previous guide on 1602A LCD Display Arduino Connection :
All we have done for the circuit is adding one LDR and 10K Ohm resister. We added three jumpers to three empty columns on the breadboard. Then connected GND of Arduino to one leg of LDR. Arduino’s A0 pin at the middle column where another leg of LDR and one leg of 10K Phd resistor inserted. Remaining one got connected to 5v of Arduino and the 10K Ohm resistor.
---
In our case equation to calculate Resistance of LDR, is [R-LDR =(R1 (Vin – Vout))/ Vout], where R1 = 10,000 Ohms, Vin = 5.0 Vdc, Vout = Output voltage from potential Divider, [Vout = Reading * (Vin / 1024)].
It will be extremely wrong to claim it as LUX. It is just a measurable unit.
Principle of Light Measurement With Arduino, LDR and LCD
The analog input pin of Arduino is capable of receiving the signal and printing the voltage on LCD. Omitting many steps, analog pin can send a value between 0-1023 to the Arduino. You’ll get total 1024 values. From V=IR, we can change the potential drop across the LDR and to limit the current, we used 10K Ohm resistor. Let us watch the video of our end result :
Code of Light Measurement With Arduino
A very basic version of the thing is :
1 2 3 4 5 6 7 8 9 10 11 12 13 | #include <LiquidCrystal.h> LiquidCrystal lcd(7, 8, 9, 10, 11 , 12); void setup() { lcd.begin(16, 2); lcd.setCursor(0,1); lcd.write("LIGHT: "); } void loop() { int sensorValue = analogRead(A0); lcd.setCursor(7,1); lcd.print(sensorValue); delay(100); } |
You can see here that someone asking for measuring as Lux:
1 | https://forum.arduino.cc/index.php?topic=141815.0 |
Slightly advanced from that discussion is :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include <LiquidCrystal.h> LiquidCrystal lcd(7, 8, 9, 10, 11 , 12); float RLDR; float Vout; float Lux; void setup() { lcd.begin(16, 2); lcd.setCursor(0,1); lcd.write("LIGHT: "); } void loop() { int sensorValue = analogRead(A0); Vout = (sensorValue * 0.0048828125); RLDR = (10000.0 * (5 - Vout))/Vout; Lux = (RLDR/500); lcd.setCursor(7,1); lcd.print(Lux); delay(100); } |
Basically I wrongly closed the Arduino IDE without saving the exact sketch. I had to re-write and test the code (never do that mistake – save on Github as gist when a code is bug free), not always you can recall and get this :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | #include <LiquidCrystal.h> LiquidCrystal lcd(7, 8, 9, 10, 11 , 12); float RLDR; float Vout; float Lux; void setup() { lcd.begin(16, 2); } void loop() { int sensorValue = analogRead(A0); Vout = (sensorValue * 0.0048828125); RLDR = (10000.0 * (5 - Vout))/Vout; Lux = (RLDR/500); lcd.clear(); lcd.setCursor(0, 0); lcd.print("LIGHT : "); lcd.print(Lux); delay(100); lcd.setCursor(0, 1); if ((Lux >= 0) && (Lux <= 5)) { lcd.print("DARK"); } else if ((Lux > 5) && (Lux <= 14)) { lcd.print("DIM"); } else if ((Lux > 14) && (Lux <= 50)) { lcd.print("BRIGHT"); } else { lcd.print("VERY BRIGHT"); } delay(500); } |