Categories

Blogroll

Meta

SolarPi – A Flask powered photovoltaic monitor

After collecting some photovoltaic data using PikoPy and a some readings from the residential meter it was time to put everything together. The data is collected by a couple of scripts triggered by a cronjob every five minutes.

The results are then written into a SQLite database. I chose SQLite over PostgreSQL for its lighter footprint on the Raspberry Pi. And since we will have no concurrent writes SQLite should be capable serving as a database backend.

The sole purpose of the web application is to fetch data from the database and render the results. I decided to use Flask, a microframework for Python based on Werkzeug and Jinja 2. For the Frontend I used the Bootstrap based SB Admin 2 Theme.

Initially I used SQLAlchemy as an Object Relational Mapper where I defined my models in Python:

This should be possible. Technically the fetching of the data is totally independent from the visualization. In my case I fetch the data from a Kostal Piko using my own library pikopy and store it in a SQLite database. You would need a script that that gathers the data from the MPPT controller. Once it is in the database it should be easy to connect the SolarPi application.

Joao Ferreira

I have a kako 7900 and a raspberry pi.I would be the happiest man in the world if i could communicate between the pi and the kako. If i could put this info in a web server would be even better. Can you help or at least show me the way?…

Björn Rathjens

I’m missing some kind of documentation how to get it up and running. i did not even find a howto setup the code, especially the sh-files aren’t findable for me. it would be great if you could give a short howto

Rüdiger Hopper Bentz

Very interested in getting this to run with my SMA.
In spite of reading up a lot about flask, gunicorn and the like I don’t manage to start the application.
Can you give a clue with what parameters to start the application?
Thanks in advance ?

Thx for the reply. I figured that out by now 😉
Got it running so far, the challenge for me is to remove the electricity meter since our older solar system sells all energy and we don’t have a smartmeter.
Thanks to the well structured code it shouldn’t be too difficult.

Juergen Schorb

Hi, a very nice and interessting application. i would use your application to visualizing my
Solaredge inverter. Can you give me some hints, to get your application up and running in a apache web server?
– apache config ( mod_python )
– copy your files only in the document root?
– …

If you just run it yourself on a local machine just use the development server with “python manage.py server”. If you want to run it in “production” I would use nginx and gunicorn.

Rampušák

Dear Tafkas, I launched server from folder solarpi via “manage.py –host 0.0.0.0 runserver” but I not have created SQL tables. Exist any script for create tables used in this excellent project? Where exists the PY scripts: kostal_piko.py, collect_meter.py, collect_weather.py ? Many, many thanks for Your help.

I worked my way backwards looking at the models.py and created the tables manually.

Rampušák

Dear Tafkas, I am tried to run this project on Windows machine with Python and other extras too. I am get same results that like on RPi. I do not have script for create DB in SQLite. The web server with run python returning error about missing table weather_data. Do you can help me with other information how I can made the tables for data ? Many, many thanks for your help.

A problem with AttributeError was that the tables was empty. I fill data with calling collect_kostal.py, collect_weather.py.
But in publicviews.py I retype code and add test data with if… that any data I don’t in tables. For example electricity_data, last year data, etc.

Now this project is working on Windows machine. I test it on RPi later.

Great Man Tafkas, I wish you nice day!

Rampušák

Problem with AttributeError was that the tables was empty. I fill data with calling collect_kostal.py, collect_weather.py.
But in publicviews.py I retype code and add test data with if… that any data I don’t in tables. For example electricity_data, last year data, etc. Now this project is working on Windows machine. I test it on RPi later.
Great Man Tafkas, I wish you nice day!

Rüdiger Hopper Bentz

Thx a lot

Rampušák

On pages with graphs is not be rendered. If I look to the datail of content web page in client then I see that in html page are values from data but client not render lines and columns of graphs. Do you have any idea why the graphs is not rendered?

Rampušák

Dear Tafkas, do you have any idea why is not rendering the graphs on tab charts? And sub tab yearly cahrt generate web page with error 500. I am import data to table pvdata for last 3 years back.

Hi tafkas! Well done for this work! I want to try this project but for a big pv plant with many inverters (more than twenty). Do you think RPI can do this ?
Thanks a lot!
John

Saamir

I got solarpi working on my Raspberry Pi, and wrote a howto to document the steps. It might be good to include a howto in the repository, and perhaps the source code changes I had to make. The howto is at:http://infrontpower.com/solarpi/howto-en.txt
If you have any problems with it, or suggestions to improve, reply here.

I believe the error with line 148 is just a warning, and shouldn’t cause the patch to fail.
Line 47 is a failure, and the only reason I can think of is that you don’t have the same Solarpi version that I used. Try the “git checkout 23aa8c4” as mentioned in the howto.
The KeError traceback is because the settings.py file was not patched. That may be due to the previous problem.

Please let me know how this turns out, so I can modify the howto for others. Thanks.

You are in ‘detached HEAD’ state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

OK, I figured it out. The problem is cutting and pasting from the web page. I think there’s a unicode character in it that won’t copy. So I updated the howto on the web page. Anybody who tries it, please let me know how it worked so I can continue to update the howto. Next time I’ll try to respond a little more timely. :/