Solar Garden Light switching

Solar cells have their uses – connecting to a “grid” for mass power generation isn’t one of them – but charging a battery to light up your garden with LEDs when it goes dark is. I was asked recently about how to switch on the LEDs when it went dark. That’s an interesting question as you could, obviously, chuck in an LDR and a small micro-controller and job done. But that’s boring and since I know I don’t know much about transistors I wanted to play with other ideas to try and learn something.

The first idea was to connect the battery voltage to the base of a PNP transistor.

Simple PNP transistor

Simple PNP transistor

 

That would switch on when the voltage from the solar panel dropped. What could possibly go wrong with that?

In this case, the transistor switches on when the voltage at the base is 0.7V less than the voltage at the emitter. If we assume we’re using a decent Li-ion battery then we’ll have 4V (say) at the emitter when the battery is fully charged. Assuming a 5V solar panel then we’ll start to switch on the LED when the panel voltage drops to around 3.3V and it will be fully on when it drops to 2.8V. That means it will be on in daylight since it’ll still be quite light to get 2.8V out of a solar panel.

So we can reduce the switch on voltage only by reducing the voltage at the emitter. But… that’s the battery voltage so we couldn’t then use that to drive the LED since it will be too low.

The next idea was to use “a few” Zener diodes in series to drop the battery voltage to something “sensible” at the emitter. We could then use the collector to drive the base of an NPN transistor. The NPN transistor would be connected to the LED and sink current when the transistor came on. The LED would also be connected to the battery so we’ll be able to fully drive the LED as long as we can sink enough current through the NPN transistor.

That circuit (ok, I’m very rusty with EagleCad) looks like:

Two transistor solar switch with selectable on voltage

Two transistor solar switch with selectable on voltage

So, we connect the emitter of the PNP transistor to one of the terminals 1-6 of the diodes to select with voltage we want to use as a reference.

For my test circuit, I measured 4.2V from the battery and the following voltages were available at the diode jumper:

Position Voltage
1 3.2
2 2.8
3 2.4
4 1.9
5 1.5
6 1.2

Cobbling this together was straightforward and, using a bench PSU in place of a solar panel, easy to test.

Switch board, battery

The battery has a cheap charging / discharge protection board attached (red LED indicates charging). The yellow/white wires represent the feed from the solar panel (also fed to the battery charging inputs). The orange jumper wire is set to supply a 2.4V voltage to the emitter of the PNP transistor.

The "solar panel"

The “solar panel”

With LED attached

With LED attached

When it done gone dark - "solar panel" unplugged

When it done gone dark – “solar panel” unplugged

So with 2.4V selected, what happens?

With the supply at 5V, the LED is off and the battery charger is charging.

At around 4.2V, the charging circuit is disabled and the LED stays off.

When the voltage reaches 1.5V the LED illuminates very weakly (we would expect 1.7V from the BC327 datasheet).  By 0.3V it appears to be fully on.

Now, the next value from our “diode ladder” is 1.9V which is a full 0.5V less than we had above. Switching to that as the emitter voltage means that the LED never fully turns on – it’s probably better to have it coming on a little too early then never getting up to full brightness.

Up above I said that “it appears to be fully on”. Let’s do some measurement rather than just relying on hand-wavy bollocks – none of that “post-normal” science bullshit here 🙂

Time to reach for the trusty μCurrent Gold and do some measurements, all taking the 2.4V value at the emitter since that seems to work best for me with my battery.

 

Voltage (V) Current (mA)
1.5 0.1
1.2 0.7
1.0 1.4
0.0 56

So, that’s way off “fully on” – I was expecting about 350mA and a quick test powering the LED direct gives 330mA as the observed value.

Even though this appears to be “working”, it plainly isn’t. Using the 2.8V level (so the LED switches on about 0.4V earlier) we’re only feeding 140mA to the LED, at 3.2V the figure is 210mA.

The PNP transistor is a BC327, with BC337 for the NPN. I came up with 100Ω as a suitable value for the base resistor in the simplest case at the start of this post. That’s the value I’ve used in the two transistor case as well. I’ve been through it again, and again, and I still think that they are reasonable values.

A quick experiment reducing the PNP resistor to 1Ω and the NPN resistor to 10Ω gave an initial current for the LED of 240mA – that’s much better but still not what it should be. After a couple of hours this had fallen off to 80mA anyway – maybe the battery isn’t behaving as it should? I went lower since I thought that even if the smoke came out of the transistors that it would tell me something (apart from that I don’t know what I’m doing).

Anyway, out of time now. Will try to figure out what the problem is – it’s slightly frustrating as it seems to be mostly working almost as I want it to.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*