{"id":2433,"date":"2018-11-03T00:46:34","date_gmt":"2018-11-03T00:46:34","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=2433"},"modified":"2018-11-04T07:55:27","modified_gmt":"2018-11-04T07:55:27","slug":"the-linux-throwie-powering-a-linux-server-with-a-300mw-solar-panel","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/11\/03\/the-linux-throwie-powering-a-linux-server-with-a-300mw-solar-panel\/","title":{"rendered":"The Linux Throwie: Powering a Linux Server with a 300mW Solar Panel"},"content":{"rendered":"<p>Have you ever had one of those moments, when you\u2019re rummaging through your spare parts heap, and have a rather bizarre project idea that you can\u2019t 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?<\/p>\n<p>This time, the stubborn idea in question was sort of like a <a href=\"https:\/\/hackaday.com\/2017\/09\/01\/an-environmentally-conscious-solar-powered-throwie\/\">solar-rechargeable LED throwie<\/a>, 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 \u2014 I just happen to have a lot of these due to a shipping error.<\/p>\n<p>There were two main challenges here: First, it would have to combine the smallest practical combination of solar panel, power supply, and battery that could run the Raspberry Pi. Second, we\u2019ll 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\u2019ll be dealing with the first set of problems \u2014 stay tuned for the rest.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hackadaycom.files.wordpress.com\/2018\/10\/sharp-solar-module-1.jpg?w=242&amp;h=400\" alt=\"\" width=\"242\" height=\"400\" \/>One time I stuck a bunch together to make a \u2018Dyson Lampshade\u2019, which is of course a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Dyson_sphere\" target=\"_blank\" rel=\"noopener\">Dyson Sphere<\/a> rendered less large, less spherical, and more absurd.<\/p>\n<h2>Sipping on Solar<\/h2>\n<p>I approached the first challenge from the standpoint that the Raspberry Pi doesn\u2019t 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 battery large enough to power the server for a few hours of run time.<\/p>\n<p>The solar modules are worth a quick mention. They are the <a href=\"https:\/\/hackadaycom.files.wordpress.com\/2018\/10\/lr0gc02-sharp-microelectronics.pdf\" target=\"_blank\" rel=\"noopener\">LR0GC02<\/a> (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. <a href=\"http:\/\/hackaday.io\/project\/159139-tiny-solar-energy-module-tsem\" target=\"_blank\" rel=\"noopener\">This tiny solar power module<\/a> would also have been an interesting choice.<\/p>\n<p>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. 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.<\/p>\n<h2>Magnificence of Modern Modules<\/h2>\n<p>Thankfully that all sounds worse than it actually is, and there are some very common modules that will sort this out for us:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hackadaycom.files.wordpress.com\/2018\/10\/power-stages3.jpg?w=800&amp;h=179\" alt=\"\" width=\"800\" height=\"179\" \/>From left to right: A USB lithium cell charger, a DC-DC boost converter, and a DC-DC buck converter. They cost about a US dollar each, which was great value!<\/p>\n<p>The first stage is a USB lithium cell charging module. These accept the ~5 V output from our solar panels, and will safely charge a lithium cell. The output of the module is whatever the battery voltage is.<\/p>\n<p>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 battery voltage drops below around 3.7V, it will continue to function. This is critical as the ESP8266 monitors the battery and switches the server on and off. If we were to connect its linear regulator directly to the battery 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.<\/p>\n<p>The 12V output is then fed into a DC-DC buck converter to drop the voltage down to 5V for the Raspberry Pi. It\u2019s important to use a buck converter with an enable pin, so we can control the output state using the ESP8266 later on. Otherwise you\u2019ll need to add a MOSFET or similar to control the power output.<\/p>\n<h2>Responsible Battery Management<\/h2>\n<p>At this point, we have all the voltage levels we need, and charge control circuitry to prevent our battery from engaging in spontaneous unplanned combustion. However, when lithium cells are discharged too far, they cannot be safely charged again. We need to monitor the battery and prevent it from rendering itself into an unusual paperweight.<\/p>\n<p>The solution is quite straightforward: the ESP8266 has an analog to digital converter. It can only accept up to 3.3V, and our battery can supply more than this, so I used a couple of 100k\u03a9 resistors set up as a voltage divider to drop the voltage \u2013 we don\u2019t exactly need high precision here.<\/p>\n<p>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 battery voltage is below 3.4 volts, it will immediately sleep for 16 minutes instead.<\/p>\n<p>function checkvolt()<br \/>\nx = adc.read(0)<br \/>\nprint (x)<br \/>\nif x &lt; 528 then<br \/>\nprint(&#8220;low battery, sleeping longer&#8221;)<br \/>\nnode.dsleep(960000000)<br \/>\nend<br \/>\nend<\/p>\n<p>checkvolt()<\/p>\n<p>function sleeping()<br \/>\nnode.dsleep(600000000)<br \/>\nend<\/p>\n<p>tmr.alarm(0,11000,0,sleeping)<\/p>\n<p>Some rough calculations suggest that the module will consume an average of around 1.5 mA normally, and around 0.2mA if the battery is low. In reality there will be some current consumed by all the parts even while the system sleeps. I\u2019m told that the sun shines at least once every month or so (I\u2019ll check at some point), and the battery should not have trouble maintaining charge. In any case, if the former assumption is wrong, I have bigger problems to deal with.<\/p>\n<h2>Regulating the Voltage Regulator<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hackadaycom.files.wordpress.com\/2018\/10\/power-stages.jpg?w=400&amp;h=285\" alt=\"\" width=\"400\" height=\"285\" \/><\/p>\n<p>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 \u2018enable\u2019 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.<\/p>\n<p>I tried pulling it back down with a 50k\u03a9 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.<\/p>\n<p>I discharged the battery a little, then left it running in the sun for an hour \u2013 it recharged a bit as expected, prompting the requisite maniacal laughter. Power stages\u2026 complete!<\/p>\n<h2>Where\u2019s the Linux?<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hackadaycom.files.wordpress.com\/2018\/10\/square-summary.jpg?w=400&amp;h=400\" alt=\"\" width=\"400\" height=\"400\" \/>It\u2019s small, it\u2019s solar powered, but other than lounging about in the sun, it doesn\u2019t really do anything yet. Most computing hardware requires software and obviously this is no exception \u2014 so how do we make this into a lean, green, Linux machine?<\/p>\n<p>In the next article, we\u2019ll 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.<\/p>\n<p>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 \u2013 one that they normally learn to avoid pretty quickly!<\/p>\n<p><a href=\"https:\/\/hackaday.com\/2018\/11\/02\/the-linux-throwie-powering-a-linux-server-with-a-300mw-solar-panel\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever had one of those moments, when you\u2019re rummaging through your spare parts heap, and have a rather bizarre project idea that you can\u2019t 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, &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/11\/03\/the-linux-throwie-powering-a-linux-server-with-a-300mw-solar-panel\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;The Linux Throwie: Powering a Linux Server with a 300mW Solar Panel&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2433","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/2433","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=2433"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/2433\/revisions"}],"predecessor-version":[{"id":2514,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/2433\/revisions\/2514"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=2433"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=2433"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=2433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}