# Intelligent Solar Garden Light - Part 1

29,798

51

7

I bought a solar powered garden light. The solar panel charges the batteries and when it gets dark the lights (3x LEDs) turn on until it either gets lights again or the batteries run out.

It has a small amount of intelligence (turns on when dark off when light) but not enough! Time for some upgrades. :D

First, the batteries. The control box houses the batteries, which are three Ni-MH AA cells. They are 600mAh. (That's not a typo - six hundred). I swapped them out for three 1500mAh Ni-MH cells that I don't use anymore (because they are only 1500mAh).

Then I reverse engineered the circuit diagram for the electronics (nothing special there, two transistors, two resistors a switch and a diode).

I have a few ideas for sensors and transducers I want to add to the light, but I'll start by adding a microcontroller. Step forward the Arduino Wee made by SparkFun Electronics.

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## Step 1: Existing Circuit Diagram

When light is falling on the solar cell, transistor Q1 is turned on and connects the base of transistor Q2 to ground. This isolates the output of Q2 keeping the LED spotlights turned off. When it gets dark, Q1 is turned off, leaving the emitter isolated (floating). Assuming SW1 is turned on, the base of Q2 will be high due to R2. This will turn Q2 on and connect the emitter to ground. This completes the circuit for the LED spotlights and they turn on.

## Step 2: Add the Arduino

So, the Arduino Wee is a 3.3V device (the normal Arduino is 5V TTL). The battery is made of 3x 1.2V cells giving 3.6V total. The Wee can cope with the extra 0.3V. I connected the Wee to the positive power rail after the switch and to the negative rail on the battery compartment. Then I unsoldered R1 and connected digital pin 3 to the base of transistor Q1, and the analogue input A0 to the positive rail of the solar panel. The Wee can now control the LED spotlights and knows if it's light or dark.

## Step 3: Soft on / Off

As there's intelligence in the solar garden light now, why just turn the lights on immediately when it gets dark? That's not very sophisticated is it? Slowly turning the light on and getting brighter until it's fully on, looks sooooo much better. :)

That's why I used pin 3 - a PWM pin. ;) You can see on the 'scope the pulses. It's showing about a 50:50 mark space ratio, so the light is at 50% brightness. It takes about two seconds to go from fully off to fully on. I think it looks cool.

## Step 4: Code

Here's the code I used for this section of the upgrade work...

(Code hacked from an RGB LED cross fade example by Clay Shirky <clay.shirky@nyu.edu>).
N.B. The led controller PCB turns the LEDs on when low, not high.

=============================================

/*
• Intelligent Solar Powered Garden Light version 0.01 zzpza<at>truenames.co<dot>uk
• Original code example by Clay Shirky <clay.shirky<at>nyu<dot>edu>
*/

int ledPin = 3; // LED, connected to digital pin 3
int ledVal = 0; // value to send to pin
int wait = 20; // 20ms (.02 second) delay; shorten for faster fades
int solarPin = 0; // pin solar panel is connected to
int analogval; // value read from solarpanel
int ledState=1;

void setup()
{
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH); // turn leds off
ledState=0;
delay(500);
}

{
digitalWrite(ledPin, LOW);
for (int i=0; i <= 255; i++)
{
analogWrite(ledPin, i);
// Serial.println(i);
delay(20);
}
digitalWrite(ledPin, HIGH);
ledState=0;
}

{
digitalWrite(ledPin, HIGH);
for (int i=255; i >= 0; i--)
{
analogWrite(ledPin, i);
// Serial.println(i);
delay(20);
}
digitalWrite(ledPin, LOW);
ledState=1;
}

void turnOffLed()
{
digitalWrite(ledPin, LOW);
ledState=1;
}

void turnOnLed()
{
digitalWrite(ledPin, HIGH);
ledState=0;
}

{
Serial.println(analogval);
}

void loop()
{
if (analogval < 100 && ledState==0)
{
}
if (analogval > 100 && ledState==1)
{
}
}

## Step 5: Next

There's more to add to this project, this is only the beginning! ;)

For the next step, proceed to Part 2.

189 10K
81 4.2K
75 4.8K

## 7 Discussions

you can adapt this for charge battery li ion ? :) it must be nice ;)

What is the cost of this? Does this only turn on the lights slowly at dusk? To be honest, doesn't seem worth the bother because the cool factor would be gone after seeing it in action one or two times.

2 replies

Okay, I found part 2 which added PIR. Does it significantly extend the battery life to give light for longer? Can't you add the PIR without the microcontroller? but that might reduce the geek cool factor though :(...

...excluding the battery upgrade, which is definitely a good one.