Designing the Solar Bauble Kit
Posted by Matthew Little on
This blog post covers the design and prototyping of the recent Solar Bauble festive flashing LED kit. I have designed a few simple solar powered LED kits before (the solar dice, solar torch and solar magic 8 ball kits). All these kits are quite similar, using a small solar photovoltaic panel and an ultra-capacitor. Here I explain my design decisions and problems I encountered, which might be interesting to others!
Initial prototype
My first design used an older solar magic 8-ball kit. This uses an ATTiny85 microcontroller and has 8 LEDs attached to 4 digital output pins. The LEDs are 'Charliepexed', which is a technique to control more LEDs from fewer output pins. The ATTiny85 only has 6 general purpose input/output pins, so I can't control each LED from a pin. This technique worked well with the solar 8 ball and, through a conversion routine in code, means I can control any of the LEDs attached. The solar 8-ball also used the same power supply design with the solar panel charging the capacitor via a diode. The diode chose (1N4148) is able to carry enough current (150mA max) but also have a small voltage drop (around 0.4-0.7V) to knock down the maximum voltage of the solar panel (around 5.6V) to ensure we do not have an over-voltage on the capacitor which would degrade its lifetime.
I added couple of wires to the capacitor so I could measure the current consumption of the unit with a multimeter:

This shows the back with the hacked on testing idea for PNP transistor:

LED choice
My first item was to reduce as much as possible the current to each LED, but ensuring the LED is bright and looks good. I used high-brightness red and green LEDs. As they are high brightness I was able to reduce the current to the LED (by changing the resistor values from 330ohm to 1k ohm). The new LEDs were very bright and looked great even with brief pulses of lower currents.
The other design issue to take into account was the different forward voltages of the red and the green LEDs. Red LEDs only needed around 1.8V to light up, while the green LEDs needed a bit higher voltage at around 2.1V. Any lower voltage then the LED will not light up. We also need to take into account the voltage drop across the resistors. In order to take this into account I added some code which checks the supply voltage (which is the capacitor voltage) and, when this is lower than 2.4V, only the red LEDs will flash. Under 2.1V then the unit will shut down - there is not enough voltage to correctly switch on the LEDs.

Twinkling high brightness green LED in action!
Monitoring Light Levels
The solar 8 ball has an input switch which uses a tilt switch to wake it up and run the code. With the solar bauble I needed to know the solar panel voltage and check this in order to decide when to wake up and flash. My original design used a 2N3906 PNP transistor which is controlled by a resistor from the solar panel voltage. When the solar panel voltage is low then the output of the PNP transistor will be high. This can be read and used to figure out if the sun has gone down and if the unit should start to flash. I realised that the input for the tilt switch was also an analogue input pin, so I can check if the solar panel is dark and also use that input to know what the capacitor voltage is. In my code I wake up every so often (every 8 seconds) and quickly check this pin. If it has gone dark then it sets a flag to know that the unit can flash.
One issue with directly reading this voltage using the supply voltage as the reference is that, as the supply voltage goes down, so does the reading and we don't know the absolute value. In order to stop this, I set the analogReference to the internal 1.1V reference. This means I can read an absolute value as it will use a stable internal 1.1V reference.
Monitoring Supply Voltage
While I can read the supply voltage by reading the analogue input pin, this only works when the solar panel is dark (and the PNP transistor input goes high). I found a nice way of checking the supply voltage using the (slightly obscure) function: readVccInternal(). This is a feature of the ATTiny85 (and other micrcontrollers). This means I can always read the capacitor/supply voltage and I know when it has gone dark (from the analogue input pin). So when the unit is fully charged (but its still sunny) then I can apply an overvoltage control code. I can also know the supply voltage which lets me know when to just flash the red LEDs and also when the supply voltage is very low and the unit should go to sleep and stop flashing.
Power Savings
I wanted to have a nice flashing sequence which also lasted for a reasonable length of time after the sun goes down. This meant looking at any power saving I can make.
Short flashes
The first thing was to reduce the flashes to brief but random times. I used either 30mS or 60mS as the flash period (random choice). I then have a random delay between the pulses of 120mS up to 2S. This gave me a nice twinkling effect, but sometimes having quite a long pause which saves power.
Two capacitors
The next thing I added was another ultra-capacitor. This doubles the energy stored, but it does mean it takes longer to fully charge. Two capacitors was a good balance between the small solar panel input being able to charge the capacitors and a decent run time of flashes. I calculated (with the help of AI!) that, with the energy stored from a full capacitor at 4.9V down to the switch off point of 2.1V then the run time of the unit should be in the region of 1.5 hours.
Sleep modes
The last thing I used in the code were the sleep modes for the ATTiny85. Putting the unit into various sleep modes can save huge amounts of power. Typically then the ATTiny85 is awake then it will consume about 1-2mA, but when it is in deep sleep the current consumption is reduced to 70 micro-amps. So between wake ups to check the various PV and supply voltages then the unit is in deep sleep. I use an 8 second timer so the unit will be asleep for 8 seconds, then wake up, check voltages and figure out what to do, then go back to sleep.
During the 'twinkling' LED flashing times then I use the watch dog timer to create small delays where the unit is in a sleep mode. So LED will switch on, then do a 'micro sleep' then switch off then do another 'micro sleep'.
Doing all of this reduced the current consumption of the unit when twinkling to an average of about 0.5 mA.
Final Circuit Schematic
Here is a pdf of the final circuit schematic:
Hopefully this post has been interesting to you and may help with design of simple solar powered devices. I hope that it also explains my design decisions and the firmware in case you want to adapt the firmware for your project or if you buy one of our kits!
Full Design Files
The full design files (firmware, PCB design and instructions) is available in this GitHub repository:
Share this post
0 comment