Originally I got the idea for this project some time in June 2014 with a very optimistic pricepoint of 500 dkk (~67 euro).
The first sketch for the SunPi system: a fully self-contained solar powered raspberry pi
Overview of the system
Overview of the working system
Wiring up current sensors to the Raspberry Pi B+
Adafruit offers a very nice guide, showing how to assemble the board here
The wiring and coding info they have concern the Arduino so to use the Raspberry Pi you need to do the following instead:
Wiring diagram for connecting INA219 to RPi
which looks like this in real life
The INA219 current sensor in a breadboard
Cables connected to the Pi
Coding the Pi
The following is copy pasted from the SunPi github.
First we need to configure i2c on the Pi.
and activate i2c. Then go back to the terminal and run
sudo nano /etc/modules
Then run these commands one line at a time
sudo apt-get update sudo apt-get install -y python-smbus i2c-tools
When it's done, restart the Pi.
Now we'll test if the installation worked by running
lsmod | grep i2c_
which should return something like
This means installation was successful !
To test the hardware, run
sudo i2cdetect -y 1
which should return a grid. There should be one entry in this grid with the number "40"
If yes, the Pi is successfully connected to the INA219 board.
Now to read from INA219 you need to download the ported Arduino files to your Pi
After doing that, test if everything is working by running (be sure you are in the right folder)
sudo python ina219_example.py
which should return something like
Shunt : 14.820 mV Bus : 12.800 V Current : 150.000 mA
and that's it!
Cronological order of setups
1st round stuff:
Quite a few meters of wire that I had lying around, some skill and patience.
1st round measurements
As can be seen from the stuff, the system had a basic purpose of monitoring its own status via the three current sensors.
- Wattage from solar panel
- Wattage going in (or out) of the battery
- Wattage used by the attached load (i.e. the raspberry pi, the converter and even the charge controller itself draws a small current) The 3rd sensor was DOA so I could not measure this.
Measured current for the battery, the solar panel and the total mismatch.
In the above plot we see that the current received from the solar panel is zero at night time (not surprising) and there is a more or less constant discharge from the battery. This difference can be seen as the current draw stemming from the raspberry pi, the converter and the controller, as stated earlier.
At around 6 0'clock the sun rises and the battery charges according to the input from the solar panel. At around 9.30 the charge controller dials down the incoming current for the battery (it effectively does so by limiting the current received from the solar panel). This is expected.
However, at around 5 o'clock I plugged in my phone for charging. The current going into the battery doesn't change, but the current received from the solar panel increases, because of this extra load. A little while after, the sun sets, effectively giving us a deeper discharge from the battery since the phone is charging.
The increasing line in the left of the plot is actually the phone being nearly fully charged - the closer a battery is to being fully charged, the slower it charges. That's why a Tesla charges relatively quickly to 80 % capacity but the last 20 % takes considerably longer.
The bad times
One day I decided to clean up the installation and in the process I managed to fry the two woking sensors and the raspberry pi (model A+).
It was basically my own fault, since my soldering had left small pieces of wire sticking out, thereby accidentally shortening the system.
Furthermore, I realised that the panel was simply too small and would not be enough to charge the battery in wintertime or on cloudy days.
Time went on..
The good times
Money rolled in and I finally bought a 100W panel and soon after a new controller as well. This time I went with some proper products, sold in Denmark.
The old charge controller simply couldn't handle the new panel (although it was rated for 10A). I should have know since the description text said MPPT eventhough it's simply not possible to get MPPT for that kind of money. Or I might have fried it together with the other stuff, who knows.
In total, these additions consisted of the following
2nd round stuff
So now the SunPi is up and running again. Only with one current sensor this time around, though.
2nd round measurements
Measured current going in (or out) and voltage of battery.
In the above plot we can see the sunrise at 5.30 in the morning, thus current flows into the battery. At around 10.30 the new charge controller begins to slow down the charging, as explained earlier.
We see that the voltage of the battery climbs to around 14.3 V until it drops to 13.7 V, which is the trickling voltage predefined by the charge controller.
This voltage is kept constant until the sun begins to set or some extra load is attached to the system (in this case I attached my phone).
3nd round stuff
Added some fuses and replaced the battery.
Add a relay in a reliable way, thereby enabling better use of the solar panel during the day.