Last week we had some really nice days of solar production. Unfortunately, the car has been fully charged so I have not been able to put much energy in to it.
In about 2 weeks, we will install energy storage at home. Gonna be really fun. But I have wondered if I can somehow predict tomorrow's solar production so that I do not have a full energy store when the sun rises, then it would have been better to sell the energy before, for example at breakfast time when there is usually a great demand for energy on the grid.
Then comes the follow-up question, how do I know that we will produce any electricity during the day? If not, it may be better to save it and use it during the day.
So what I need to know now is basically 2 things; 1.) What is my optimal effect on the panels per hour during this time of year? 2.) What will the weather be like? Or rather, what does the predicted cloud density look like each hour?
This problem can be divided in to multiple steps·:
Where is the sun in the sky right now? Here I first thought that i would calculate it by my self in a simple way. But I never had to do that because I found a nice library that does just that, Pysolar! With just one simple command with your longitude, latitude, date and time, you get in return the sun's position in the sky. Awesome!
What will be the angle to the panels? Easy! ... after I found a sensible library to help me with all the vector math, Vectors.😇 (Linear algebra math is not my strong point, but I know the logic behind it without problems!) Our roof slopes 20 ° to the south and the panels are turned about 10 ° to the east. Take the normal on the panels and measure the angle to the position of the sun, and bam (!) You have the angle of incidence of the sun!
What do the panels produce at different angles? Uh, yeah, here I found lots of scientific reports on how to figure it out. But I did not understand much of it. So I took a small game developer angle on this; if I can fake fair values, and then come pretty close to reality, then I'm happy! This will still not be the weak point in my prediction of solar production, it will be the weather forecast! But I found a sensible graph with power vs angle that I copied into a simplified list, normalized and multiplied by our facility peak production. I had to adjust the values a bit to get a curve that is similar to real production.
From Pysolar you get the suns position in two values, altitude och azimuth.
There is a certain difference between my simulated curve and reality. But the sum of energy produced is very close. In the example above from 16 April, the production was about 32 kWh and my simulation was about 31.2 kWh. That's good enough for me!
This was also solved quite easily as SMHI has an open API for retrieving weather data. Just send in your latitude and longitude to their web API and you will get back a massive JSON file with all goodies, such as cloud coverage! Perfect!
So, now I only need to take my calculated optimal solar production times percent cloud cover and I get a rough (!) estimate of what I could produce in a specific hour.
Now my newly gained knowledge of generating bar charts comes in handy!
Well, this did not look so interesting, did it?
Typically, right now the weather forecast seems really bad, 100% cloud coverage for the next 3 days.
Typiskt, just nu är prognosen här riktigt dålig, 100% molntäckning närmaste 3 dygnen.
Okay, now we can see that something is happening, but now instead we have really bad resolution of the forecast instead. SMHI only has an hourly forecast for the next 3 days, then it is every 6 hours.
I may come back with a little more sensible graphs when the weather is a little better. So we can see how well I can predict my solar production.
My solution is really not something to trust, it is for only me to get a rough estimate of the next day's solar production.
Ideally, I would have liked to have the forecast sent to my mobile every morning. Can certainly be obtained in some way, for example by generating the graph above and then emailing it.
But right now I already have a basis for later writing logic for the energy store to be able to more easily make a decision to sell or keep the energy for my own use on a day that is not as sunny.