Building a digital light meter with a calibrated LDR using Atmega8 microcontroller

Summary of Building a digital light meter with a calibrated LDR using Atmega8 microcontroller


This article describes a microcontroller-based light intensity meter that measures illuminance in lux. It uses an LDR calibrated against an external photometer to overcome the limitations of relative measurement devices. The system employs an ATMega8L microcontroller, a custom AVR demo board, and an adjustable voltage divider with an LDR and potentiometer. An analog low-pass filter using a TL072 Op-Amp reduces noise before the signal is processed by the microcontroller's ADC and software algorithms. The final reading is displayed on a 16×2 LCD.

Parts used in the Microcontroller Based Light Intensity Meter:

  • ATMega8L microcontroller
  • MikroC Pro for AVR compiler
  • LDR (Light Dependent Resistor)
  • Precision analogue potentiometer
  • Texas Instruments TL072 dual Op-Amp
  • 16x2 alphanumeric LCD
  • Custom-built 28 pin AVR demo board

Measurement of light intensity is a prime necessity in several occasions.  The diversity of such needs make their way to various branches of physics and engineering as well as in media. For instance, in engineering, such kinds of measurements are needed to design optimum lighting conditions of a room. In photography, light intensity measurements ensure good quality pictures by determining the right exposure. Wiring a phototransistor or a light-dependent-resistor (LDR) with an analogue LED voltmeter chip like the LM3914 or even to a microcontroller and displaying the ADC values is a pretty simple technique of measuring light intensity. The bad part of this technique is that these simple and amateur-level devices can only measure relative intensity of light and are unable to provide measurements on an absolute scale. However, with a precise knowledge of the transfer characteristic (resistance vs light intensity) of the LDR it is possible to relate the LDR output to the intensity of light in standard unit. In case the LDR characteristic is unknown or unreliable, you can still calibrate the sensor output by using a variable light source and an external reference photometer. This project is about a microcontroller based light intensity meter where an LDR light sensor is calibrated against an external photometer to obtain the intensity of incoming light in the unit of lux. The lux is the SI unit of illuminance and luminous emittance, and measures lumens per square meter (lm/m2). The microcontroller used in this project is ATMega8L and its firmware is written using mikroElektronika’s MikroC Pro for AVR compiler.
Title LUX Meter
Circuit diagram
The project’s hardware is simple and requires little explanation. I used my custom-built 28 pin AVR demo board that provides all the necessary interfaces. An LDR is used as a light sensing device. I could have used advanced light sensors like TSL257 or TSL230 but they are pretty expensive and rare. A photo transistor is also a good option but photo transistors and photo diodes are very responsive to rapidly changing signals which is not desired here. Besides, ordinary photo transistors and diodes are more specific to a particular wavelength and therefore may not be equally sensitive to the same intensity of different wavelengths. According to the schematic shown below, an LDR and a precision analogue potentiometer form an adjustable light-dependent voltage divider. The output of this divider goes to a 3rd order analog low pass filter (LPF). This filter is designed with Texas Instrument’s (TI) TL072 dual Op-Amp and allows frequencies lower than 100Hz to pass and stops anything above this value. The LPF is here needed to reduce noise and unwanted high frequency transitions due to sudden flickering lights, glare, pulsating light sources and so on.
Filter Stage
Next the output from the LPF is fed to the first analog input channel ADC0 (pin C0). Additional signal conditioning is done inside the microcontroller by performing the root-mean square (R.M.S) of the ADC samples. Thus both analogue and digital filtering are done. The result of such dual filtering is a highly processed signal which is reasonably reliable and accurate than with a direct connection to the ADC pin. However complexities arise both at hardware and software ends. The rest of the works after signal conditioning are done inside the AVR chip itself and in the software end. A 16×2 alphanumerical LCD is connected to PORTB of the AVR micro to show the measured light intensity level in lux. It should be noted that the AVR runs at 8.0 MHz clock derived from its internal source.
For more Detail: Building a digital light meter with a calibrated LDR using Atmega8 microcontroller

Quick Solutions to Questions related to Microcontroller Based Light Intensity Meter:

  • Why was an LDR chosen over advanced sensors like TSL257?
    Advanced sensors like TSL257 are expensive and rare, making the LDR a more accessible choice.
  • What is the purpose of the 3rd order analog low pass filter?
    The filter reduces noise and unwanted high frequency transitions caused by flickering lights or glare.
  • How does the system ensure accurate measurements despite unknown LDR characteristics?
    The sensor output is calibrated against an external reference photometer to obtain absolute intensity values.
  • What unit of measurement does this project display?
    The device displays light intensity in lux, which is the SI unit of illuminance.
  • How is the signal conditioned after the analog filter?
    The microcontroller performs root-mean square calculations on the ADC samples for additional digital filtering.
  • What clock speed does the AVR microcontroller run at?
    The AVR runs at 8.0 MHz derived from its internal source.
  • Which component is used to display the measured light intensity level?
    A 16x2 alphanumeric LCD connected to PORTB of the AVR microcontroller displays the results.
  • Why are photo transistors not ideal for this specific application?
    Photo transistors are too responsive to rapidly changing signals and are often specific to particular wavelengths.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top