In the last blogpost SolarPi experiment 1: The PiJuice Fiasco, I’ve tried PiJuice Raspberry Pi hat with 40W PiJuice solar panel, and concluded that either the solar panel, or the PiJuice hat is not working as expected.
Just to confirm the theory, I’ve decided to purchase another Solar panel, as the PiJuice solar panel seemed to be the most likely cause of the problem.
Goowei Energy SN-ME-SC60W 60W
I’ve installed it on the outside part of the balcony doors instead of the old one, and started testing. For that, I also added some features to the pijuice_historgrams script, which I wrote to monitor the state of the PiJuice hat, battery and solar power status.
Here is how it looks like:
It may be a bit confusing, I know. The blue line shows the status of the solar panel, which may be either Present (green dotted line), Weak (yellow dotted line), Bad (red dotted line), or Not present (purple dotted line). This basically shows if there is solar power, but mostly just “Present” counts as solar power.
The red / green (RG) line is the state of the battery, with values on the right Y axis going from 0-100%. It is red if the grid power is active, and green when there is only solar power. At the time, I was using a timer which turned off the grid power roughly from 6am to 5pm.
Ideally, the graph would look in a way, that the blue line would go straight up, and the green line would be all the time on the 100%, until the grid power comes back on. Something like this:
Instead, typically it looked like this:
Which means spotty coverage of solar which goes from Present to Weak all the time. And the Red/Green line for battery status sometimes holds, but most of the time dives. This means that the solar power cannot provide enough power to charge the battery, although I am using a 60W solar panel for ~5W Raspberry Pi.
This overall “Present” and “Weak” thing is annoying by itself, since solar panels are analog devices and should provide some level of power all the time. As one of my friends put it, his solar panel makes some energy even during the night, just from the moonlight. USB solar panels make power only when they feel like it, and PiJuice can’t really charge the battery when it drops under “Present”.
I must say that the new solar panel was better than the old one, since it would stay in the Present state much longer and didn’t deadlock itself. But it seemed that a lot of the time, the PiJuice cannot charge the battery, and also I discovered that it randomly restarts when the charge drops below 26%. And this was in the middle of the summer.
The last straw was the measurement I did over weeks, where I measured how much the average grid consumption dropped. It almost didn’t. Long-term average power consumption with the solar was something like a 3.6W/h of the grid electricity.
Well. It was time to get more serious.
“Stupid” solar & MPPT charger
So far, I was trying only “high level” consumer hardware, powered by USB ports and PiJuice hat, thinking that it would be user-friendly and work out of the box. Since that failed, I’ve decided to buy the following components:
Photovoltaic solar panel 12V/50W polycrystalline 700x510x30mm
This is just a “bare” solar panel, without any electronics.
I would have bought the 60W version, but that was sadly out of stock and the 100W version seemed too big.
GWL/POWER ELERIX LiFePO4 battery 12V 12Ah
LiFePO4 has the advantage that it shouldn’t be flammable (datasheet says “Stable up to +130°C. No fire.”).
+ connector (XT60 male).
PWM solar regulator CY-K20A, 12-24V/20A for various batteries
The important part is “for various batteries”, as I need it to support LiFePO4 battery.
It has 2A USB output, so it should work for powering rPI directly.
And also various cables and connectors (more specifically, the battery connector and 3 meters of blue and red cables). All of this was surprisingly cheap, definitely much cheaper than PiJuice hat and PiJuice solar panel (around 3304 CZK €139/$152, compared to 6197 CZK €250/$255 for PiJuice combo).
The connection is actually super simple:
Solar panel to solar panel connections, battery to battery, making sure in both cases, that
+ is connected to the red wire, and
- to the black one. Then just plug in the Raspberry to the USB output of the regulator.
Proof of concept assembly
I just connected everything to where it belonged, and the Raspberry Pi started running from the battery and connected to Wi-Fi. The only thing I’ve set up on the regulator was the battery type to LiFePO4, and the rest worked out of the box. So, I have just thrown everything into an old lunch box:
Then I was thinking about the solar panel because it is massive and proper installation will require some kind of mounting point. Instead of thinking about some smart way how to mount it on my balcony, or the window, I took an old garden chair and fixed the panel to it with wires.
The whole process literally took me maybe 10 minutes. And it has worked since then, providing more or less 24/7 power. The server is running, it is connected to Wi-Fi and everything seems to be working as expected.
The first day, I was quite nervous about the temperature because the quick measurement at 9am showed that it was running quite hot (52 °C). But the datasheet said “Stable up to +130°C. No fire.” and it really was.
I’ve noticed that sometimes, the server restart itself, so far, only when there is a cloudy day, and the battery can’t keep it running during the night. Since I run basically everything as a Systemd services, this doesn’t bother me much, since when I wake up, it is actually back again running.
Problems and challenges
It finally works, but there are still some challenges I need to solve in the long term:
Obviously, I am delighted with it during the summer, but in the winter, I can’t realistically expect this to work 24/7. There will be outages. I have basically two options:
- Implement some kind of automatic grid backup.
- Invest into bigger solar and bigger battery.
The first option is painful, since I expect that I will have to design something myself. Basically, a power monitoring circuit, which will enable grid power when it detects low voltage. My friend suggested just putting two diodes on the outputs. But I don’t really expect it to be that simple, especially given that the Raspberry is actually powered from the USB output of the controller, and I still need the battery to be able to charge itself.
A simple implementation may be adding back the PiJuice hat and using its second micro USB input powered by a standard charger, which will be turned on when required. But this is finicky. For some reason, no one sells MPPT regulator with grid backup. *Sigh*.
The second option may be better. The battery power is something like 12V * 12Ah = 144Wh. This can in theory power raspberry for something like a day (5-6W/h = 120 - 144Wh). In reality, I expect that real usable power for powering both the regulator and RPi is something like a half of it.
This option is also kind of complicated, since it will some smarter way of mounting the solar panel, and if there are more cloudy days in a row, it will still fail.
Okay, so there is a cloudy day, and the battery dies overnight. It will start charging the next day and the rPI will boot up, right. Right??
Of course not. As the manual puts it in broken english:
It basically means that you need to physically press any of the buttons to continue, since it deadlocked itself as a protection. What a lovely idea. My only regret is that you can’t power the raspberry from frustration, because my levels are lately spiking so high, that I am continually wondering why isn’t reality bending around my hate.
Moreover, I don’t understand how this works, since sometimes it triggers and sometimes not. Maybe it depends on how much it lets the battery discharge? I’ll need to investigate.
One obvious disadvantage of having a cheap solar regulator is that it doesn’t have any data outputs, except for a display, which is mostly for settings and some stats about current power outputs (= useless).
Not having a power monitoring is bad for two reasons;
- You can’t check status remotely (except for binary status on/off).
- You can’t plan and debug the system as a whole.
For example, the pijuices_histograms project which drawn the images from the beginning of the article here was why I was even able to reason about my problems, and see where are the shortcomings.
Planning is also important, since when the Pi knows there will not be enough power, it can shut down itself automatically without loss of data, and so on.
I am thinking about some kind of power monitoring shield for RPi, but that has its drawbacks. For example, none of the shields I found can handle the amps I need, and I suspect it would generate countless sighs from my side and solve only half of the issues.
The right way would be to get a regulator with proper data output, but the only ones I found so far were expensive, and there will be problems with reading the values. Some of the cheap ones come with Bluetooth and a phone app, but I don’t really like reverse engineering bluetooth protocols and none of them seemed to be open.
The manufacturer also suggests balancing the battery every 6 months or so. Internally, it consists of 4 cells, and they need to be rebalanced to the same parameters every now and then. It seems like you can just buy a device, a bunch of other crap and you are good:
For now, I will leave the system as it is, since it mostly works and doesn’t really bother me that much. That is, compared to the previous version.
In the near future, I would like to build a better box, most probably from some kind of metal, so it will be able to dispose of the heat more effectively. Maybe copper, since I have quite a bit of experience with soldering it. Ideally, it would also better separate the components, so for example RPi would be thermally insulated from the charger, as well as the battery.
In the winter, I will need to address the power switching, or upgrade to a bigger cell. But as I plan to move out of this flat, I will see what I will have to work with then.