In this new article on the Solar Lamp project, we will finally put everything together and see whether all this performs as expected. Today’s menu: assemble the circuit, firmware description, measurements on the running circuit, etc.

Assembling the electronics

The board is a fairly straightforward design, with the exception that all the components except the LED and switch are SMDs: this makes it slightly more technical to solder, of course, but this can be managed surprisingly easily once you get the hang of it, and this board is actually a very good way to learn if you have no previous experience.

The suggested soldering process is as follows:

U1 Soldered

Start with the MCU: first put a little bit of solder on the tip of your iron, then place the MCU over its pads – check that all pins are aligned properly. Touch the upper left pin with your iron, after a second or so solder will transfer to the pad and pin. Remove your iron, wait a second then release the chip. Check that all pins are well aligned over the pads. You can now solder the opposite pin (lower left), and then move on to solder every pin.

Solder the inductor: this part is tricky, because it does not have pins. No worries though: wet both pads with a little bit of liquid flux – not too much! – melt a little bit of solder over one of the pads, then slide the inductor over the molten solder while keeping on heating with your iron. Once the inductor is well positioned, release your iron, wait a a second and check that the inductor is still in place properly. Move on to the other side: heat the pad with your iron, and add solder carefully, it should melt and get under the inductor thanks to the presence of flux. Once the inductor is soldered, you can check it is not broken with an ohm-meter (should read about 30 to 40 ohms).

Solder resistors: my prefered way is to put a tiny bit of solder on one pad and slide the component over the molten solder, then solder the other side. It is a fast and efficient method which works for 0805 and 0603 components.

Solder capacitors: same method, really nothing special to say there.

Solder diodes: those are sensitive components with very small pins, but are surprisingly easy to solder. For those, my advice is to wet the pads with a tiny bit of flux, then put solder on the tip of your iron, position the diode – careful about orientation – and barely touch the pin: solder should transfer almost immediately. Avoid overheating!

Solder larger components: ICSP header and battery holders, as well as the small push button. Nothing to say for those.

LED: now solder the LED. I like to position it so that the base of its package is at the same height as the top of the battery, so that the battery does not cast a shadow.

Once the circuit is soldered, remember to thoroughly clean it using a PCB cleaner such as isopropyl alcohol: the lamps will be exposed to humidity, and wet flux is sure to cause all sort of trouble on your boards if not totally removed.

Lamp firmware

Now that the board is finally built, it is time to write the firmware .

It is working at all?

The first thing to do on a new board, is to insert a fresh AA battery, and check that there is a 3V voltage on the ATtiny’s VCC pin. If this is not the case, remove the battery right away, and double-check all your solder points.

Quick test

Before getting into writing the actual firmware, let’s just write a very small bit of software to check that the ATtiny is working properly: a simple blinking program for the LED. This also lets us test the cross compilation toolchain.

This “hello world” looks as follows :

#include ;
#include ;
#include ;

#define LED PB1

* A simple 1 second LED blinking loop to check everything is working fine
* on the hardware side (boost converter and so on)
int main(void) {
DDRB |= (1<AVR Eclipse Plugin which works very well. You can refer to the Wiki of this project for details on how to setup your environment. The only difficulty resides in the fact that avrdude does not natively support the ATtiny43u MCU. I am a lucky guy, someone already documented how to solve this problem. The archive of the firmware contains an avrdude.conf which is updated to support the 43u.

Complete firmware

The final firmware, as described in the initial article, is written to make sure as little power will be spent on anything else than lighting. For this reason, I decided to put the chip in power down mode as often as possible. In that mode, the only programatic way of waking it up is to use the watchdog, so that’s what  I did. Also, it is possible to make the watchdog generate interrupts rather than resets, which makes life easier too.

That way, the ATtiny is powered down nearly all the time, and only wakes up every 8 seconds to check the light level by reading the solar cell voltage. If that level is above the e2prom-stored “dark threshold”, then it goes back to sleep immediately. Otherwise, it starts the ligthing program that is stored in e2prom.

The firmware code is fairly well documented, so you can read it for further details. The only trick I used is changing state from “running” (lit up) to “not running”, or making the lamp react to button press immediately: whenever the lamp detects light, or whenever it acts on a switch press, it then sets the watchdog for “reset” instead of “interrupt”, and powers down right away. This enabled me to simply write the lighting patterns as infinite loops which made my life easier.

Another neat feature, is that the firmware checks battery voltage regularly: under 0.9V, the LED max brightness will be reduced, in order to prolong battery life. This is the case for every lighting mode (see below) except the first one which just switches the LED on at maximum brightness.

LED “brightness” is actually simulated using PWM, this is the most common way of driving LEDs and is very easy to do on AVRs.

TODO: link to firmware here (github ?)

Using the lamp

Now that the lamp is fully working, we can check whether it performs as expected:

Calibration of dark level

In order to calibrate the “Dark Level”, first place the lamp under a light level where it should switch on, remove the battery, then keep the button pressed when inserting it again. The LED will blink twice, pause then blink twice again. At this point it is calibrated, and will switch on a few seconds afterwards (up to 8). You can test that things are working fine by moving the lamp into a stronger light, it should switch off within 8 seconds.

Changing the light program

Just press the button to switch from one program to the next. There are seven programs all in all, with different patterns:

  1. Fully lit
  2. Half-lit
  3. “Dynamic”: goes dimmer when battery level goes lower, to enhance lighting time
  4. Candle-like flicker, “windy”
  5. Candle-like flicker, not windy
  6. Firefly 1: slow pulse every 5 seconds
  7. Firefly 2: one short pulse, one longer then a pause
  8. Firefly 3: Five pulses from strongest to dimmest, then a pause
… and that’s about it, really! How far can you go on a solar lamp?
OK, you might be wondering where these “Firefly” patterns come from: the whole idea was to create nice flashing patterns modeled after actual patterns from existing Firefly species. I was able to find one page on the subject on the Internet, written in 2005 by a Canadian professor of Genetics, which contained everything I needed:

Flashing patterns of Fireflies

“Firefly 1” is modeled after species #10 in the above diagram. “Firefly 2” is modeled after species #12 and “Firefly 3” is modeled after species #6. In reality, fireflies use more sophisticated flashing repertoires depending on their activity, but this goes beyond what I am intending to do here!

Performance testing

After this brief foray into biology, back to electronics. With the lamp firmware written, it is time to test whether the circuit is performing as expected

Boost converter modes

One of the great benefits of using the ATtiny43u, is that its boost converter is able to minimize power consumption a great deal in case the circuit does not require much current. This mode is called “Active Low Current” and switches on automatically. Time to test that this is really the case: below are screen captures of Vcc (yellow) and boost converter switch node (green) with the lamp in standby mode – LED off, checking light level every 8 seconds upon watchdog wake-up:

Sleep Mode, boost converter in Active Low Current mode

As expected, Vcc is kept loosely around 3V, with the boost converter switching on very briefly only every second or so to pump up a bit of power into the storage capacitor.

We can do more precise measurements on the boost converter switch on period, and check how the voltage varies:

Boost converter switch on period

We can see on this screenshot that the boost converter triggers every 1.6 seconds, except once every 8 seconds when the ATtiny wakes up to measure the light level, as can be seen on the second screenshot as well.

Voltage swing in low power mode

Last, the above screenshot shows the voltage swing when the boost converter is in active low current mode.

Current consumption

One of the features of this lamp, is its very low current consumption when it is off, so that all the power from the cell is used to charge the battery, so let’s test it. I also used the µCurrent designed by Dave Jones in order to minimize voltage dropout from the multimeter (1.8mV/mA on the Fluke 289) and see whether it made any difference – it didn’t at such low currents, that device is only useful when you are around the top of your range, not at the bottom.

This is using a PMEG2005J/CoilCraft LPS4018:

  • Measured standby current: negligible outside of boost converter running. Could not measure anything significant.
  • Measured running current (LED off): 1.7 mA (µCurrent)
  • Measured running current (LED on 100%): 23.7mA (µCurrent)
  • Measured running current (LED on 50%): 6.5 mA (µCurrent)
  • Average current when using ‘candle light’ mode 1 and 2: 13.4mA (10m average / Fluke 289)
This means that the lamp will spend anywhere from 78mAh to 285mAh for a 12 hours lighting period.
I also experimented with other diodes/inductors:
Using a BAT20J / CoilCraft LPS4018:
  • Measured standby current: 4.0µA (Fluke 289, when boost converter not running)
  • Measured running current (LED off): 2.2 mA (Fluke 289)
  • Measured running current (LED on 100%): 25.7mA (Fluke 289)
Interestingly, the boost converter in low power mode seems to switch on less often in this configuration:

Period is 2.96s

Using a BAT20J / WE-TPC 4828:
  • Measured standby current: 4.0µA (Fluke 289, when boost converter not running)
  • Measured running current (LED off): 2.7 mA (Fluke 289) / 1.26V 2.3mA (05.02)
  • Measured running current (LED on 100%): 33 mA (Fluke 289) / 1.26V 35mA (05.02)

Power Measurements: does it really charge ?

I took the following measurements:

  • 2012.04.03 Evening – lamp switching on: 1.41V after a sunny day
  • 2012-04-04: morning. Lamp switching off at 1.35V
  • 2012-04-04: Evening : 1.42 after a cloudy day
  • 2012-04-15: fully discharged battery in the morning, cloudy day. The lamp switches on at sunset, but is exhausted around midnight.

Cloudy sky

Besides those simple voltage measurements, I also used my Fluke 289 in recording mode, to get a reading of current going out of the battery on a mildly cloudy/sunny day, as seen on the left: high wind with cloud and sunny intervals. The graph below shows how the circuit behaved during a one-hour recording session from 11:00 AM to 12:00 PM at the end of April 2012. There was constant current going into the AA battery, from around 5mA when cloudy, all the way to max 50mA in sunny intervals. Average current was -22.35 mA.

Solar lamp battery output current - charging

This means that on a spring day like this, with about 6 hours of sun exposition, the battery will easily get over 110 to 120mAh in the course of the day. On a cloudy day, on the other hand, we will only get 30 to 50mAh, which means that the lamp will not last for the whole night unless the battery was already partly charged at the beginning of the day.

Performance issues & debugging

A few days after putting the lamps together, I noticed that some of them  remained fully discharged at the end of the day: the boards looked fine, and I didn’t understand what was going on, until I used an ohm-meter and noticed that there was an almost complete short circuit on the battery terminals, but there was no obvious reason for this when visually inspecting the boards. After spending some more time on the problem, I traced it down to humidity getting on the capacitors, and mixing with flux residues which were not cleaned properly: re-heating the capacitors with a soldering iron gave out a characteristic crackling noise with a tiny bit of smoke as the water evaporated.

The fix for this was to increase pad spacing for the 0805 and 0604 capacitors, as the pads I used first were really close together. Also, of course, very thorough board cleaning is absolutely key, which is something I did not do well enough in the beginning.

Assembling the lamp

This is mostly a matter of personal taste, in my case I used glass jars which look nice:

Tagged on:     

One comment on “Solar Light project: putting it together

  • May 10, 2016 at 16:12

    Hi Edouard,

    Did you ever get round to putting the source code for your Solar Garden Lights anywhere as i’d love to see how you did the watchdog etc. I’m trying to use the same chip to change a battery powered clock to tick every 2 seconds so that it runs at half speed and want to use the 43u since it has the boost converter and 0.7v operating voltage.

    Any help much appreciated.

    Great work on the solar lights by the way.



Leave a Reply

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