Go Down

Topic: Light meter project, get the right lux (Read 1 time) previous topic - next topic

poli


Hi Everybody, I am Working on a light meter, I have Just "finished it" but I borrowed a real Lux meter and the values I get from the arduino are totally different... the formula I used is one I found in some other post.
This is the code I have used for the lux meter:
Code: [Select]

#include <ks0108.h> //  library for LCD
#include "SystemFont5x7.h"   // we need this for character display, included with ks0108.h download
int LDRPINA4 = 5;
int LDRREADING4;
float Resistance = 10.0;
int val = 0;

void setup()
{
 
GLCD.Init(NON_INVERTED);   // load the GLCD library
GLCD.ClearScreen();
GLCD.SelectFont(System5x7);  // choose font to use (note this needs to match the #include above
  countdown(1);
  GLCD.ClearScreen();
GLCD.DrawRect(0, 0, 127, 63,BLACK);
GLCD.CursorTo(1, 1);
// set cursor to top left of LCD (uses character coordinates
// not pixel coordinates
GLCD.Puts("   Welcome To The"); // sends strings to LCD. Does not wrap to next line!
GLCD.CursorTo(1, 2);
GLCD.Puts("#AMAZING LUX METER#");
GLCD.CursorTo(0, 3);
GLCD.Puts("Project Developed by:");
GLCD.CursorTo(1, 4);
GLCD.Puts("Sixto Llorens Zabala");
GLCD.CursorTo(1, 5);
GLCD.Puts("Student No: 08154978");
delay(900);
GLCD.ClearScreen();
GLCD.DrawRect(0, 0, 127, 63,BLACK);
GLCD.CursorTo(1, 1);
GLCD.Puts("Lux Given in Lumens "); // sends strings to LCD. Does not wrap to next line!
GLCD.CursorTo(1, 3);
GLCD.Puts("       LUX\t=");
}
void loop(void)
{
LDRREADING4 = analogRead(LDRPINA4);
float Vout5=LDRREADING4*0.0048828125;
int lux4=104.1*Vout5;
GLCD.CursorTo(12,3);
GLCD.PrintNumber(lux4);
delay(1000);

delay (20);
}

void countdown(int count){
  while(count--){  // do countdown 
    GLCD.CursorTo(10,3);   // first column, second row (offset is from 0)
    GLCD.PutChar(count + '0');
    delay(1000); 
  }
}


Please can anyone help me on it? can anyone suggest me where I went wrong? or what formula will be giving me the right answer?
By the way, I am using analog input A5... does that affect? This is because in the other posts everybody uses the analog input 0, but because I am using a GLCD my analog input 0 has been used for the screen.

I really want to get this project done as I have been working on it for quite a while now, has anyone attempted it? And got the right values?

Thanks in advance

Sixto

Sorry for my english, Im spanish and I struggle to write it properly



Terry King

Hi,

What sensor are you using, and what is the information on it's response to different light levels???

Remember that the Analog reading will be between 0 and 1023. You need a clear understanding of how THAT relates to LUX and then do your calculation.
Regards, Terry King  ..On the Red Sea at KAUST.edu.sa
terry@yourduino.com  LEARN! DO! (Arduino Boards, Sensors, Parts @ http://yourduino.com

MarkT

What colour light are you sensing?  Lux is well defined for a particular wavelength of green light - different sensors will have different spectral sensisitivities (unless very expensive calibrated units).  Cheap sensors will have poor accuracy and need calibrating anyhow.

No all analog inputs are the same, there is only on ADC unit on the chip.
[ I won't respond to messages, use the forum please ]

poli

find the attached picture, thats the LDR i am using, but i am not getting those value you where saying, my max value is about 515 and my min about 120, the thing is that when I used a 16x2 lcd I was getting the values you where saying... do u know why i am not getting those?

Kind Regards

Terry King

There are many similar Photo Resistive sensors. Can you find the type number??

Maybe take a look at the spec sheet pointed to here: http://arduino-direct.com/sunshop/index.php?l=product_detail&p=135

Down a few pages and table of characteristics...
Regards, Terry King  ..On the Red Sea at KAUST.edu.sa
terry@yourduino.com  LEARN! DO! (Arduino Boards, Sensors, Parts @ http://yourduino.com

Go Up