Light sensor using Photo Transistor

The circuit you show should work as it is, since it is already for a phototransistor. Just leave your base lead floating.

EDIT - the breadboard circuit you have added looks correct (though it's hard to read..) so go ahead and try it. If it doesn't work let us know. Maybe change the resistor to 2k or larger if you are worried about blowing the LED.

Just to note this circuit will work fine, although Steven's suggestion is "preferable" in general. I would maybe not change things till you have it working.
The reason the circuit is usually not the best way to do this is because it relies upon Hfe, which can vary quite widely in a transistor and is subject to temperature changes. This means the base resistor must be chosen according to the particular transistor used.

The reasons it is picked for this circuit are as it uses 1 less resistor (for size purposes, see picture below) Also this circuit is designed for a 3V cell like a CR2032, which has a high internal resistance and generally cannot supply enough current to damage the LED (so it's like having a series resistor in place) The original project page explains all this.

CR2032 light sensor

So if you are intending to eventually power this circuit from something else other than a coin cell, then you should go for the common emitter circuit Steven describes. The site you got the above circuit from also has an example of such a circuit:

Common emitter light sensor

To help with the breadboard I just threw together the little circuit shown in your question. I only had an IR phototransistor but it doesn't matter much for this, it still works the same. Anyway here are a couple of pictures of it working, hopefully you can see how the connections go:

phototransistor light

The phototransistor base is floating, and I swapped the 1k for a 22k in my circuit to bias it correctly (I arrived at this value roughly, see below) and used a BC337 npn. Since the BC337 has lots of gain the 22k works well for the base current.
To give an idea of why the 22k resistor, the BC337 I'm using has a gain of around ~400, and the voltage it will see is 3V - (Vled + collector-emitter drop) -> 3V - (1.8V + 0.7V) = ~0.5V. So 0.5V / 22k = 23uA into the base.
The gain for the BC337-40 is typically 400, so 23uA * 400 = 9.2mA. The min/max gain given in the datasheet is 250-630, so the actual max LED current could vary from ~6mA to 14mA, which is within maximum LED current (20mA) My actual measured maximum current was 10mA, so this fits with the above calculations.
The power rails are on the right, red for +V and black for ground.

With the lights turned down a bit:

phototransistor dark

It actually works very well, off in normal light and starts turning on as soon as I start dimming the lights. You may have to try a few different values of resistor in your circuit to arrive at your desired setting.


First move the LED to the transistor's collector, and add a series resistor. You now have a common collector circuit, and the 2N3904's base is at 2.7 V or higher, depending on the LED voltage. Then if there's no current through the phototransistor you have 300 \$\mu\$A base current (0.3 V / 1 kΩ). If the transistor has an \$H_{FE}\$ of 100 you'll have 30 mA LED current and that may be too much. But the main problem is that \$H_{FE}\$ may have a wide variation, and the upper limit is often not even specified. You have absolutely no feedback in the circuit so that 30 mA may as well be 150 mA, probably destroying the LED in a circuit with a higher power supply. You do need a resistor, and with the LED on the collector's side your series resistor will limit the current.

enter image description here

edited to explain it better This is the circuit you should get. If phototransistor Q2 does not draw current, then Q1's base gets current through R2. The base is at 0.7 V (always 0.7 V higher than the emitter), and the power supply is 3 V, so there's 3 V - 0.7 V = 2.3 V across R2. Then because of Ohm's Law the current through R2 = 2.3 V / 1 kΩ = 2.3 mA. Transistor Q1 will want to increase that 100-fold to get 230 mA collector current. R1 will limit that. If Q1 is on then the LED's cathode will be at around 0 V, and the anode 2 V higher, at 2 V (that's typical for a red LED). So there remains 1 V for resistor R1, and if we want 20 mA through it (and the LED) we apply Ohm's Law again: R = 1 V / 20 mA = 50 Ω. So R1 will make sure that the LED current won't go higher than 20 mA.

Now if Q2 (the phototransistor) gets light it will also draw current, and draw it away from Q1. The more light, the more Q2 current, and the less Q1 base current. So that the LED will go dimmer with more ambient light.