The Linux Throwie: Powering A Linux Server With A 0.3W Solar Panel

Have you ever had one of those moments, when you’re rummaging through your spare parts heap, and have a rather bizarre project idea that you can’t quite get out of your head? You know, the ones that have no clear use, but simply demand to be born, of glass and steel and silicon?

This time, the stubborn idea in question was sort of like a solar-rechargeable LED throwie, but instead of a blinking light, it has a fully cloud-accessible embedded Linux server in the form of a Raspberry Pi 3 Model B+. Your choice of embedded Linux board should work — I just happen to have a lot of these due to a shipping error.

There were two main challenges here: First, it would have to combine the smallest practical combination of solar panel, power supply, and Li-ion cell that could run the Raspberry Pi. Second, we’ll need to remotely activate and access the Pi regardless of where it is, as well as be able to connect it to WiFi without direct physical access. In this article we’ll be dealing with the first set of problems — stay tuned for the rest.

One time I stuck a bunch together to make a ‘Dyson Lampshade’, which is of course a Dyson Sphere rendered less large, less spherical, and more absurd.

Sipping on Solar

I approached the first challenge from the standpoint that the Raspberry Pi doesn’t need to be on all that often. An ESP8266 (Wemos D1 Mini) running NodeMCU can provide battery management, and receive commands over MQTT to activate it, while staying in deep sleep mode most of the time. This consumes very little power, allowing a small 5 volt solar module to trickle-charge a lithium  ion cell large enough to power the server for a few hours of run time.

The solar modules are worth a quick mention. They are the LR0GC02 (PDF) from Sharp, designed to trickle charge a variety of mobile electronics. Unlike a lot of modules out there, they are both extremely well encapsulated and very thin (about 1mm). They also come with detailed specifications. A single 300mW module is enough for this project, but I used three in parallel during development to speed up various tests. This tiny solar power module would also have been an interesting choice.

Managing the power from these modules is where things get a little hairy. We have a 4-5V power source charging a Li-ion cell that has a nominal output voltage of 3.7V. Then we have an ESP8266 module, which runs at 3.3V but can accept higher through an integrated linear regulator, as long as you watch the dropout voltage. Finally, we need a 5V output that can be easily toggled to power the Raspberry Pi. Also it would be nice to have a 12V line for future expansion.

Magnificence of Modern Modules

Thankfully that all sounds worse than it actually is, and there are some very common modules that will sort this out for us:

From left to right: A USB lithium ion cell charger, a DC-DC boost converter, and a DC-DC buck converter. They cost about a US dollar each, which was great value!

The first stage is a USB lithium ion cell charging module. These accept the ~5 V output from our solar panels, and will safely charge our cell. The output of the module is whatever the Li-ion cell voltage is.

Next in line, I added a DC-DC boost converter module set to output 12V. These modules are better than 90% efficient, accept a range of voltages, and will output a fixed voltage that is set by a trimpot. The 12V output is connected to the linear regulator on the ESP8266. This way, even if the cell voltage drops below around 3.7V, it will continue to function. This is critical as the ESP8266 monitors the Li-ion cell and switches the server on and off. If we were to connect its linear regulator directly to the cell output, it would shut down due to power loss while there was still quite a bit of usable power in the system. We do lose a bit of efficiency here, but the ESP8266 is off most of the time, so I can tolerate that.

The 12V output is then fed into a DC-DC buck converter to drop the voltage down to 5V for the Raspberry Pi. It’s important to use a buck converter with an enable pin, so we can control the output state using the ESP8266 later on. Otherwise you’ll need to add a MOSFET or similar to control the power output.

Responsible Battery Management

At this point, we have all the voltage levels we need, and charge control circuitry to prevent our Li-ion cell from engaging in spontaneous unplanned combustion. However, when lithium ion cells are discharged too far, they cannot be safely charged again. We need to monitor the cell and prevent it from rendering itself into an unusual paperweight.

The solution is quite straightforward: the ESP8266 has an analog to digital converter. It can only accept up to 3.3V, and our cell can supply more than this, so I used a couple of 100kΩ resistors set up as a voltage divider to drop the voltage – we don’t exactly need high precision here.

To start our control program, I set a timer to run the ESP8266 for 11 seconds before sleeping for 10 minutes, this is plenty of time for the chip to check for commands online. Then, if the cell voltage is below 3.4 volts, it will immediately sleep for 16 minutes instead.

function checkvolt()
x = adc.read(0)
print (x)
	if x < 528 then
		print("low battery, sleeping longer")
		node.dsleep(960000000)
	end
end

checkvolt()

function sleeping()
    node.dsleep(600000000)
end

tmr.alarm(0,11000,0,sleeping)

Some rough calculations suggest that the module will consume an average of around 1.5 mA normally, and around 0.2mA if the cell voltage is low. In reality there will be some current consumed by all the parts even while the system sleeps. I’m told that the sun shines at least once every month or so (I’ll check at some point), and the cell should not have trouble maintaining charge. In any case, if the former assumption is wrong, I have bigger problems to deal with.

Regulating the Voltage Regulator

Finally, we need to be able to control the output of 5V from the last voltage regulator. While I purchased a module that had an ‘enable’ pin available, there was no documentation as to how it worked, and the exact chip used in my module was unclear. Looking at datasheets for a few ICs from different DC-DC converters, it looked like it was probably an active-high enable pin that was pulled up with a resistor on the module.

I tried pulling it back down with a 50kΩ resistor, and the voltage output dropped to zero. Supplying 3.3 volts from one of the GPIO pins of the ESP8266 triggered the enable pin, and it output 5V again.

I discharged the cell a little, then left it running in the sun for an hour – it recharged a bit as expected, prompting the requisite maniacal laughter. Power stages… complete!

Where’s the Linux?

It’s small, it’s solar powered, but other than lounging about in the sun, it doesn’t really do anything yet. Most computing hardware requires software and obviously this is no exception — so how do we make this into a lean, green, Linux machine?

In the next article, we’ll cover how to control this system via MQTT, set up remote configuration (for example if I need to change my WiFi password), and set up a reverse-SSH tunnel so we can connect to the Raspberry Pi without having to reconfigure our network to accommodate it.

The irony that my servers now get more sun than I do is not lost on me. I live near the equator though, and sunbathing for extended periods is an activity reserved for tourists – one that they normally learn to avoid pretty quickly!

63 thoughts on “The Linux Throwie: Powering A Linux Server With A 0.3W Solar Panel

    1. Small caps or listing in watts when title styles conflict avoids ambiguity. Though context should tell you that most hobbyists don’t have MWs of solar power at their disposal.

    1. I thought it would be boring to mention, but since you asked… effectively I ordered a fair number of these along with a few thousand dollars of other components needed for a project.

      The “shipping error” in question was that the supplier only delivered the Raspberry Pi boards, folded their company, and vanished with the rest of the order. An international lawsuit would have cost me much more than the value of the parts, so rather than double down on the expense and time, I canceled the project and moved on to other things (there are always a dozen waiting it seems). It’s unfortunate, but also occasionally the cost of doing business. On the bright side, I’m exceedingly well stocked with Raspberry Pi boards.

      I would have written up the tale, but the suppliers in question don’t deserve to be remembered. A warning would have been fruitless, as they no longer operate. Overall my suppliers are fantastic and all this was a blip on the radar.

    1. Funny story, if you use inspect source you see that it is actually written as 300mW. Hackaday uses a CSS ‘text-transform: uppercase’ on their h1 and h2 elements.
      I’m pretty sure they used to use a ‘text-transform: lowercase’ on all of the comments.

      1. Also guilty.
        Since I’m allergic to putting my homestead data aq and control on the internet, I’d change it to talk to one of my always-on servers instead…(which are pies and odroids as NAS and data aq/control)
        But then, the whole place is on solar anyway (~ 6kw array when the sun shines), so what this would save is a piece of wire N feet long…with a few strands for data and power.
        It’s cool anyway. My kind of toys.

    1. That is an interesting question.
      On the external pin it is 1.1v

      But if you ask the kernal to measure its own supply power it can steady measure up to 5v.

      Yes, the SoC can handle 5v.

  1. I have been down the same road with my background radiation monitor using an ESP8266. I started off with a small panel like this that is feeding into one of those Li-Ion charger boards, changed the charge rate resistor to match the output of the panel and was getting a few weeks or so out of it before the daylight could not keep up over last winter. I recently switched to a 12v panel and a 7805 regulator to feed the Li-Ion charger board and it is working much better. Again though, I have pulled it apart to change the 18650 cells because either I have a current draw issue or the cells are bad, possibly even diminished battery capacity due to the low temperatures here now that fall has arrived. The whole thing wakes from a deep sleep every 10 minutes, takes a radiation measurement, reads the temperature/humidity/pressure and solar/battery voltages and then before going to deep sleep fires everything off to my MQTT server. My MQTT server is a nano-pi neo NAS setup and also has node-red installed, that takes care of sending the www data to radmon.org and wunderground for the world to see.

    Interesting project you have and I will follow along!

    1. I’ve used similar setups, the approach works very well! Luckily I’m near the equator and have to deal more with waterproofing than winter, and the angle of the sun doesn’t change as much over the year. Its quite convenient!

    2. You’d probably do much better using a DC-DC convertor, to change the 12V to 5V. A 7805 just converts the unwanted voltage into heat, hence the heatsink. A convertor would convert it into extra amps. Your batteries would charge at pretty much double the rate.

      You can get DC-DC modules online for a dollar or two, not much more than the 7805.

      If you wanted yet more efficiency from the solar, an MPPT controller would do that. It changes it’s input impedance to draw the optimum combination of voltage and current from the panels, giving most power. Since solar panels often end up charging batteries, there are combo circuits that will do MPPT and manage 18650s, providing a simple steady voltage output for your use. You can buy these ready-made boards online from China, Amazon, Ebay etc have loads of them, among other suppliers. They’re not expensive.

      1. I used a cheap <$1 dc to dc converter at first and it took some current from the panel to actually start the converter up when I was watching the daily graphs. I was using the logic that more time charging even at a lower current rate would be very similar. Obviously I should run two of them side by side to make a more scientific comparison!
        At some point I will go looking for a MPTT board for a better solution but had the 7805 on hand.

  2. >Managing the power from these modules is where things get a little hairy. We have a 4-5V power source charging a lithium cell that has a nominal output voltage of 3.7V

    That’s not an issue. The current of a PV cell diminishes to zero at full voltage, and a Li-ion battery can be charged to 4.3 Volts. You also need to add a diode in series with the PV cell to prevent backwards discharge when the cell is dark, which means you already lose about 0.7 Volts off the top anyhow, leaving you with just enough to top up the battery.

    1. According to the data sheet, the maximum open circuit voltage is 5.7 V at a wide range of light input, so all you really need is two silicon diodes in series or a zener directly to the battery.

      It’s technically possible to overcharge the battery, but it will take literally forever at microamp currents. Still, if you’re worried, use NiMH cells instead.

      1. I totally agree, and was coming here to say this (or something similar)

        The charging scheme in this article is over complicated. There is a loss of efficiency at each stage too.

        I was thinking of an LDO instead of a diode, but I’m not certain how it would behave when the cell voltage drops below the battery voltage, so a diode may be smarter.

  3. The almost EOL i.MX23 and i.MX28 include a Li-ion charger and need no external DC-DC converter to run from up to 5.25V, but I don’t know if they continue charging while the ARM core is off. They are still fine for many tasks that don’t need lots of computing power.

  4. It’s already been done. Even built a hat for the Pi-Zero https://hackaday.io/project/26272-pi0w-solar-hat It has power regulation and a fuel gauge. The problem is the Pi is a power hog, To effectively power a Pi on a long term basis it will require a very large solar panel and an absurdly large battery. Sure for a day or two, it will run on 18650 battery and a 3W solar panel but…. It’s so cut down, power wise forget any extras like a camera. I ran a Pi-Zero with camera on a 20w panel 10Amh lithuim battery and it would only last three days at best.

    1. Glad to hear you also got the Raspberry Pi working with a solar panel and battery. It is indeed a power hog and 3 days run time is not bad!

      I’ve taken a different approach here, in that I don’t try to power the Raspberry Pi on a continual basis. Instead, I provide a low-power control system on the ESP8266 that can be powered indefinitely with a modest solar panel and battery. This low-power system activates the Pi only when needed. It’s not designed to be used for more than a couple of hours at a time.

      At this stage our projects are conceptually very similar. I’ll be following up with a second article shortly where our projects diverge quite a bit — I hope you will find it useful!

      The updates are working so far — I can remotely turn the Pi on and off from the cloud — but I’m still stress testing it to see how reliable it is, messing with some scripts, and so on. The last thing I want to do is install this in a remote place then have to go back in a week to fix it.

  5. the tp4056 has over-discharge protection, although it cuts-out at 2.4v at which point your battery is probably toast. no idea why they set it that low, but if you’re willing to risk it you can remove some esp8266 code/circuitry

    1. That is unusual! Also, I suspect the cutoff feature is not implemented on my board. I checked the resistance between the pads where the cell is connected and the output pads on the module, and it was ~0 ohms.

      I’m not completely certain though as I didn’t investigate further. Caveat emptor!

      1. Some boards don’t have that cut-off incorporated. I forget the part numbers of the devices but there should be two extra pieces of silicon on the boards that have that protection, one is a FET package and the other is the voltage monitor. They are easy to spot on the shopping sites, both boards are pretty much the same size and both will show up in a search for the tp4056

  6. Pi takes about 2W (let’s be pessimistic)
    Sun only shines 1/3 of the day, let’s say 1/4
    So to gather that amount of energy I’d need an 8 Watt solar panel.
    To store it, I’d need 2W over 24hrs (being pessimistic again.) = 48 Wh, let’s say 50Wh Battery.

  7. If you’re close to the equator it’s probably not such an issue, but for those of us in more seasonal climates, one other consideration for Li-Ion batteries is temperature. Charging one below or even near 0 degrees Celsius causes lithium plating on the anode similar to the effect of over charging. This has the potential for catastrophic failure over time. It’s worth adding a temperature sensor and charge enable to the ESP to allow it to shut off charging under such conditions – a not uncommon in the UK, frosty, but clear winter’s morning. Alternately use a different battery chemistry (NiMH or SLA) or keep it well away from flammable structures!

Leave a Reply to MartinCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.