Smart Solar Lamp

A solar powered led light that turns on at human presence with switch mode configurable charge control and constant current led drive

Similar projects worth following
A simple smart solar powered lamp harvesting most out of that big bright explosion up there, storing every bit of it into batteries and spends it wisely only when illumination is needed with installation as easy as placing a potted plant. Final device will be an indoor outdoor solar lamp which is powerful and cheap enough to replace a conventional light bulb or a desk lamp.

It's board has a boost converter for charging and a buck converter for supplying constant current to led. Board can be used with a variety of batteries, panels and leds as charge algorithm and led driver can be configured over USB.

It aims to be a practical, efficient, budget solar product that can take out one appliance at a time off the grid without any harm or loss in function to provide people the opportunity to try solar out within limited budgets and spaces and open up new opportunities. All hardware and software will be open source.

How it works?

Since I started this project I have made dozens of experiments with a variety of sensors, charging and switching methods, types of batteries, solar panels, inductors, mosfets etc... And the device had usb capabilities from the beginning so I have the opportunity to compare complexity vs. efficiency during these experiments. You can find most of these experiments and design decisions in the project logs. Below are the major building blocks:

  • MCU and switches: Charger, led supply, sensors are all controlled by PIC 16f1455. I chose this one as It's low cost and has a rich set of features such as internal usb module, temperature sensor plus plenty of ports. NDS331N mosfets are used for chargers and led drivers switching supplies.
  • Battery: Main power storage for the device will be 6v SLA battery by default. However as charging algorithm is completely configurable in theory any battery with higher voltage than panel's max. voltage can be used.
  • Solar panels: Main power source for the device will be 2x 6v 1W solar cells by default. However as above any panel setup can be used as long as its max voltage is lower than battery voltage and maximum power doesn't exceed 5W.
  • Charging module: A boost converter controlled by PIC microcontroller with constant current, constant voltage, temperature compensation and battery health check features.
  • Sensors: Device will detect human presence and light conditions and decide to turn on, off or sleep. For now solar panel voltage will be used to detect ambient light. A motion sensor module will also be used by default. Another optional analog sensor will be used (such as a sound or distance sensor) to close gaps of the motion sensor.
  • LED and LED Driver: A 3w warm white led powered by a constant current mode buck converter controlled by the micro.
  • Configuration, debug : Currently device is a custom HID device that can communicate over USB to a piece of java software plotting a couple of values. During the first phase of the project I will improve this software to setup and modify charging algorithm, power saving features such as sensor thresholds and timings and power usage features such as adjusting output current. Having said that I am planning to replace all usb communication with wifi. Starting with usb was a bit easier for me but with modules like esp8266 and usb issues with open source wifi is obviously a better way to go for open source projects.


The end product will be something similar to a conventional desk lamp. Goals below will be success criteria for the project.

  • Design : Final product should have a solid, sleek look and it should be very easy to configure and start using. While in use it should require as little maintenance as possible. (Such as changing batteries, cleaning up solar panels)
  • Functionality : Amount of light produced should compete a conventional light bulb powered by the grid or at least provide a functional replacement for a small desk lamp.
  • Cost : While not being the primary goal, price tag on the final product plus batteries shouldn't scare first buyers.
  • Simplicity: Number of components and complexity of hardware and software should be as simple as possible enabling more people to diy this project easily.

Why Does It Matter?

I am living in a leased unit where I can't install a full blown proper solar system. Assuming that is the case for a majority of people especially living in heavily populated cities where power consumption is highest, a practical, efficient, budget solar product that can take out one appliance at a time off the grid without any harm or loss in function will provide people the opportunity to try it out within their budgets.

If this project or any similar product can successfully make it into the common household then it might start a reaction leading to more industry and scientific attention, more investment, better solar panels, better batteries etc. and most importantly better ideas. Imagine what the light bulb did to electricity but without...

Read more »

  • 1 × PIC 16F1455 Controls charging, sensors, usb
  • 1 × MCP6022 Amplifier and Linear ICs / Operational Amplifiers
  • 1 × LP2950 Power Management ICs / Linear Voltage Regulators and LDOs
  • 2 × 0.01R Resistor Current sense resistor
  • 2 × IRLZ34N Discrete Semiconductors / Power Transistors and MOSFETs

View all 17 components

  • SDSL Alpha Complete

    Gorky06/29/2015 at 14:05 0 comments

    After squeezing every bit of my free time and every word on the pics flash memory I have completed all the major functions I have been planning in software.

    We have two pieces of software in this project with below functionality

    - Firmware with C running on PIC covering below functions

    - Boost converter for charging and battery charging algorithm

    - Driving led with constant current

    - Sleeping and saving power as much as possible while checking motion sensor, analog sensor, solar power and usb connection whether to wake up or continue sleeping

    - Supply status and configuration based on received USB hid data. Saving configuration to PIC's flash memory.

    - Keeps log of battery condition, charge and send them over USB.

    - Control panel software with Java running on any platform with JVM and usb host.

    - Displays battery, panel and charge voltages and charge current

    - Displays battery and charge log

    - Configures device displaying configuration ui and sending saved values over USB.

    Aside from more complex problems of firmware and software I spent most of my time around one completely idiotic comparison mistake and another weird issue about not being able to retain configuration values in flash. I found the solution to the error in flash as well using all my google-fu in a single forum in a super little post. So long story short a certain silicon revision of PIC16f1455 cant write to its flash while working at 48 Mhz which is needed for usb to work. At first was a real disaster for me as the whole point of usb was to send and store device configurations. But then I found a solution which was to get the config values, detach usb module, slow down to 4 mhz store config values and then attach usb module. So after save device gets detached for a while but firmware and software handles that. Besides that newer silicon revisions do not have this problem.

    Here are some screenshot of desktop software. I will publish both firmware and software soon once I have time to start the project on github.

    After all these oranges and reds if still someone manages to explode a battery with this charger or smoke a led it's completely their color blindness.

  • Board Ready

    Gorky06/08/2015 at 12:27 0 comments

    I received the pcb a week ago. Did a few tests and soldered everything on. Everything works happily. Off course a realized a couple of design issues but no show stoppers. Around the power input it got really crowded. Needed to push the caps around a bit and squeezed the inductor in the middle. Voltage divider resistors I have in stock, had slight fitting issues. Terminals I had in stock covered the power labels and I have realized it wasn't a great idea not to put polarity labels as well. ICSP pins are too close to mcu socket and doesn't make it easy to plug pickit3 directly on the board. Used another pin header to ease debugging. Still everything turned out to be far better than I expected.

    Also spent massive amount of time trying to come up with a compact case suitable for 3d printing. I failed so many times and got really frustrated. I tried to

    - Minimize model size to allow printing with small 3d printers
    - Power terminals, usb and sensor pins are accessible
    - Panels can get maximum sunlight while battery stays as cool as possible
    - Motion sensor and light is placed reasonably allowing them to function.
    - Assembling parts is possible and relatively easy.

    And I couldn't come up with anything that makes sense and fits above criteria to a certain level. So I think I will stick with my initial plant design and try to improve it later. I already spent a lot of time on this.

    So now I am trying to finish the software. Fixed the constant current output for led. Had problems sending floats from pic to java.Solved that. Desktop software and mcu share configurations but having problems with storing configuration in flash. PIC16f1455 doesn't have an eeprom but a high endurance flash for that purpose. It seems I still need a bit of reading to do that. I skipped it for now. I am focused on building the main program which

    - Charge if enough current is available
    - Turn on led if human presence detected and it's dark
    - Sleep or consume minimal power if there's no human presence or power to charge
    - Wake up when conditions change

    Trying a couple of methods especially around sleep and wake-up or slowing down the pic considering digital and analog sensors. USB doesn't make things easier at this stage. Here is another image of assembled board and initial charge tests.

  • Shapes and Shades

    Gorky05/20/2015 at 12:29 0 comments

    While waiting for the board to arrive, started working on the shape of the lamp. I really want to come up with something super simple and solid but wanted to try a few things before that.

    I plan to get some parts 3d printed or laser cut but before that I needed some solid stuff to see how design ideas are working. I was really tempted to get a 3d printer but ...

    Any ways so for the following first prototype design I used 1.25mm copper wire, 4mm (diameter) black heat shrink tube and salvaged cat5 twisted pairs. Parts like panel holders, base and light are cut from balsa wood and glued with a glue gun. Also applied a layer of varnish and acrylic paint on it. They still need some finishing but they served they purpose of illustrating a couple of design ideas. I put the 1.25mm wire and twisted pairs into heat shrink to connect panels, sensor and light to the base. This provides great flexibility in terms of adjusting directions.

    Well I ended up with something relatively easy to build and really flexible. Panels, motion sensor and light all require some degree of separate positioning for best performance and this design gives a lot of space to play. Am I happy with this design? Not really. Would really love to come up with something far simpler. But I am thinking this project as an over-engineered teaching experiment. So far I have learned a lot about batteries, panels, charging algorithms.

  • Board complete

    Gorky05/12/2015 at 11:19 0 comments

    I have made a couple of updates on the board like paying a bit of extra attention to power lines. Also made a small change in usb power connection, so device will be powered from usb without batteries.

    Hope everything is all right. The board is quite big and I might have ended up with a much smaller smd design but I think this is way more easy to put together especially for makers who wants to replicate this. An smd board with wifi is hopefully something I will do next.

    So what's next. I am fiddling with Bender to for a casing. Will do the first case from balsa wood if all goes well I will try to get the parts 3d printed. Yes I don't have a 3d printer. Luckily there are plenty of places available where I can get 3d prints.

  • Led Driver

    Gorky05/04/2015 at 15:03 0 comments

    Surprisingly at last I found the chance to type in a few couple of logs.

    So I decided to give a shot for a constant current led driver as the project got used to switching stuff. Of course this idea led to a bunch of problems and caused me to review my mosfet choices ones again. It took me a couple of hours and a bunch of mosfets to realize there was nothing wrong with mosfets but I was just getting confused over driving them and sensing current. I changed the mosfets in any case as the previous ones I was using were smd. These new IRLZ34N fets I chose are packed in good old TO220AB, logic level and can switch a massive amount of current which is completely an overkill for this project. Their internal resistance is a bit higher compared to the smd ones I have used but still extremely small. Anyways I also completed schematics and board. Still need to review it a few times though.

    Any comments or feedback is extremely appreciated as this is the second pcb I have designed.

  • materializing...

    Gorky04/07/2015 at 14:11 0 comments

    Well I guess things started taking shape especially after some Easter work. I have made a lot of trials and errors and made some changes to parts and overall system design. Will try to note down my mistakes, what I have learned and decisions made. Hope they help to someone putting together a similar project.

    1. I decided to use a 6V SLA battery.
      • As in this project weight is not a big deal
      • SLA charging is forgiving, relatively easy and safe.
      • Price
      • 6V is kind of a sweet spot relatively easier to regulate down and up.
    2. I changed 3.3v ldo regulator with a 5v ldo regulator. At first I was thinking mcu will consume less if powered by 3.3v but compared to the power loss based in voltage difference in the regulator going for 5v is better. So
      • Less power loss from linear regulation
      • LDO I have used has max. 300mv drop out. I will keep the SLA lower voltage limit at 5.5v where lower is no good for the battery anyways. So we have plenty of volts there.
      • More devices to chose from when working with 5v instead of 3.3 (such as mosfets, mosfet drivers, op amps)
    3. I was planning to use buck converter for MPPT. I tried buck, cuk, boost and boost-buck charging 6V SLA with a variety of panels ranging from 0.5W 6V, 2W 6V, 1W 12V, 3W 9V. And I decided to go with boost conversion. Why?
      • Considering this projects power requirements lower voltage panels are more suitable as they are relatively cheaper, smaller, easier to obtain and better suited for diy (make your ridiculously high power, low voltage panels)
      • Boost converter is the simplest implementation with less number of components compared to other switching topologies. Using a logic level mosfet, no extra driving circuit, charge pump or bootstrap circuit is required.
      • It's winter here and it rained for 2 days which might have effected me : )
    4. I changed the op amp I was using to measure current to MCP6022. While being around 40 cents more expensive it has a much lower input offset voltage which allows a mA level precision current measurement. I also tried a ACS712 based current sensor but I decided not to use it because charge current will be max. 500mA in this project which means tiny loss on shunt resistor also means too little for ACS712 leading to less precision. Besides ACS712 has a 10ma quiescent power consumption which is kind of bothering for a low power project.

    And here are some pics. Sorry for the mess as usual

    Panel voltage (before boost) and battery voltage (slider adjusts boost pwm duty for debug purposes.) Peaks happened when I disconnected battery to test output voltage of boost converter.

    Current, peaks represent times that I was poking in with the multimeter to check it.

    Mess of board populated with torn apart implementations of different converters. And the inductor is levitating!

    After a bit of cleaning up.

  • Getting Ready for MPPT

    Gorky03/29/2015 at 00:31 0 comments

    Introduced low side current sensing to solar panel which works better than I expected. For voltage measurements I have realized pic's analog input pin is leaking a lot more than expected thus resulting lower voltages than it should. It's seems the voltage dividers input impedance is too much for analog input. Well at the same time I don't want to lose any precious current from voltage divider. Will work on a voltage buffer from op amp later.

    Next I will throw the mosfet IRLD120 in start cooking mppt.

    Panel and battery voltage. After 11:09 panel disconnected from battery and you can see how the voltage jumped. Diodes voltage drop is also pretty visible.

    Current measured from solar panel during a few tests

  • Power status over HID

    Gorky03/25/2015 at 12:17 0 comments

    Even this is like my fourth time doing it still making the usb stack work with XC8 takes a bit of time.

    • Started a c project in MPLAB X, tweaked Microchip's USB stack to come up with a custom HID device. Added a couple of utility methods mainly around USB communication to process commands from pc and reply back.
    • Decided to start with shunt monitoring instead of hall-effect sensors for current measurement as it's simpler, cheaper and I am not planing to use any panels more powerful than 3W. Played a while with lm2902 op-amp and 0.01R sense resistor. Tried high side sensing first and continuously failed till the point where I completely understood why this won't happen. Low side seems to be simple and accurate. Hope it won't cause any problems once sensors are hooked up.
    • Started development of PC control panel application which will be used for configuration and status. Decided to start with a swing based Java desktop application used Jfreecharts for fancy charting. Once I am happy with the hardware I will probably replace this with some a standalone spring web application decorated with angular js.

    Windows' perception of my device

    Java application plotting voltage from a 0.5w small solar panel sunset and turning on off rooms light and desk lamp is quite visible

View all 8 project logs

Enjoy this project?



mr.jb.swe wrote 05/15/2015 at 13:48 point

simple "stupid"

"Wham Bam" regulator ( UVLO ) - modify a buck

"They have a control pin that is either on or off.  The pulse duty never
changes, just the number of pulses.  It is much more efficient  to
design a transformer for a fixed duty cycle than for PWM. With 120,000
or more pulses per second,  an operation with 50 pulses on and 100
pulses off doesn't look any different to the end user than PWM"


The circuit simply fakes the input  sense pin into believing the output of
the regulator is too high thus shutting it down.  Input and output work
in perfect harmony.,144628.msg977808.html#msg977808

  Are you sure? yes | no

Gorky wrote 05/07/2015 at 22:47 point

Thanks a lot great link. I am a bit happier in the sense that their 3w product uses exactly the same default setup I came up with which is 3w led,6v 4.5Ah SLA battery and 6V 3W panel. Bad news is there's this great product and it still needs googlefu to find it. Still it seems their products are lacking the smart turn on, off features instead they supply intensity modes. And hopefully once this project is complete it will be the most over engineered and hackable low power solar device on the planet.

By the way I had a deeper look at lifepo4 batteries. While being great in every aspect  they are needy. Using a single 3.2v battery means a lot of change considering the power requirements of different ICs for the current project. And if I use them in series especially cheap packs will need balancing. A solar light with lifepo4 balancing charger seemed like a sequel project to me.

  Are you sure? yes | no

mr.jb.swe wrote 05/08/2015 at 04:38 point

I think the best way to make a really useful product is to ask the question "would I be willing to use it daily ?" I think a lot of companies like the previous link cuts to many corners ( close but no cigar ). Take an axe for an example once you start to fiddle with the metal quality or other vital aspects will end up as a toy ( or camping tool for people on vacation ;-)  A lot of companies are trying to help "poor countries" but so far I have not yet seen a really durable and easy to repair product.

This battery will probably work for a lifetime  ( >7000 cycles ) and since it is so strong it can be used for more stuff like soldering .. 

10 C  > 1000 cycles

1 C  > 7000 cycles

And in a near future

  Are you sure? yes | no

mr.jb.swe wrote 05/01/2015 at 08:54 point

Take a look at LiFePO4 batteries will simplify the circuit and give you long life ( many charge cycles ). Since you plan to use it for led light....LiFePO4 is perfect....

With 5.5-6V solar panel all you need is a buck converter to charge ...mppt won't make much difference ( but it's fun to play with ). Personally I prefer a robust system ( less is more ).

Since you just want to charge with one small panel you could use a circuit like this

( but you will have to add some logic since it will stop charging below a certain threshold )

  Are you sure? yes | no

Gorky wrote 05/01/2015 at 16:31 point

Thanks for the feedback. I will definitely have a look into LiFePO4 and hopefully final device will support multiple chemistries and I already implemented SLA and NiMh charging with mppt. SLA is still kind of a winner for me even compared to LiFePO4 as first while completely agreeing with less is more I love over engineering stuff a bit, second they are dirt cheap compared to other chemistries and their bulky size is not a problem as this light wont be portable.

  Are you sure? yes | no

mr.jb.swe wrote 05/01/2015 at 17:51 point

On ebay the cheapest 6V 4.5Ah is around 10$

A cheap no name 3.2V LiFePO4 3.3 AH 11$

My guess is you should not drain the SLA more than max 30-40% if you want to ensure "long life"  < 500 cycles !?

The LiFePO4 will probably last  >2000 cycles and you can take out close to 100%  ( cut off 2V...but 3V is more energy below 3V anyway )

The brand A123 will probably last 7000 cycles with your use case....

NiMH is a pain to work with..not worth the effort ;-)

The cheapest solution is li-ion ( but it has just 4-5 years shelf life )

A tp4056 + 18650 battery ....

I have big hopes for graphene batteries...

  Are you sure? yes | no

Gorky wrote 05/04/2015 at 01:15 point

After a bit of reading it seems that LiFePO4 is the way to go until graphenes are out :) . Thanks again for the suggestion. Still I need to complete the software and make sure its safe and have concerns over shipping of batteries. Do you know how they treat to batteries at customs for ebay chinese batteries? Here in Australia I have no way of sending a battery not sure about receiving though.

  Are you sure? yes | no

Debasish Dutta wrote 03/15/2015 at 08:10 point

Its really cool.Keep it up.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates