Blog

May 22, 2013 | Circuits |

Ambient Light sensor using an Op-Amp Comparator

Say you have a microcontroller circuit that does something when it goes dark. To save power, you want to put the chip to sleep when the ambient light drops below a certain level. One way to do this is using an LDR and an op-amp comparator.

Here is the schematic:

In the above circuit, the reference voltage at the non-inverting terminal of the op-amp is VCC/2. When it's dark, the LDR has a high resistance (over 20K), and the voltage at the inverting terminal (pin 3) is going to be less than VCC/2. Hence, the output of the op-amp will go to high when it is dark. When sufficient light falls on the LDR, its resistance falls, and the voltage at the inverting terminal (pin 2) exceeds VCC/2. At this point, the op-amp output goes low. We can control the threshold at which it goes from low to high by adjusting the potentiometer R1.

Here is what the circuit looks like on a breadboard. The supply is 5V regulated.

In this case, I am using the LM358 - a very popular general-purpose Op-Amp IC. This works fine for our purpose, but do note that there are dedicated comparator ICs with better switching characteristics for critical applications.

In my next post, I will describe how to hook this up to an ATmega168 and wake it up from power-save mode.


Consulting

Need help with a hardware project or product? Drop us an email at info@electronut.in. We offer consulting services on AVR and Nordic nRF BLE - hardware design, firmware development, prototyping, PCB design/assembly, sourcing and manufacturing. We can help you bring your product to market!


Questions/Comments

We love hearing from our readers. Email us at info@electronut.in for questions or comments on this article. If you found this article useful, please support us by buying some of our hardware products.


Please sign up for updates

Once in a while, we will send you an email update on the latest Electronut Labs projects and products. Your email address will never be shared or abused, ever.

2016 Electronut Labs. All rights reserved.