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.

$ crontab -l
*/5 * * * * python /home/solarpi/
*/5 * * * * python /home/solarpi/
*/15 * * * * python /home/solarpi/

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:

class PVData(SurrogatePK, Model):
__tablename__ = 'pv_data'
id = Column(db.Integer(), nullable=False, primary_key=True)
created_at = Column(db.Text(), nullable=False, default=dt.datetime.utcnow)
dc_1_u = Column(db.Integer(), nullable=True)
dc_1_i = Column(db.Float(), nullable=True)
ac_1_u = Column(db.Integer(), nullable=True)
ac_1_p = Column(db.Integer(), nullable=True)
dc_2_u = Column(db.Integer(), nullable=True)
current_power = Column(db.Integer(), nullable=True)
daily_energy = Column(db.Float(), nullable=True)
total_energy = Column(db.Integer(), nullable=True)

While using an ORM is very helpful for CUD operation I decided to keep my read queries using raw SQL instead.

The main view is a dashboard presenting all kinds of interesting KPIs like yielded, imported, exported Energy and how much money was received for the sold energy:

SolarPi Dashboard

Furthermore there are detailed charts available for each day at a five minute interval, or the last 7 days and 30 days, respectively:

<a href="”>SolarPi Daily Chart

The project is live at:

The code is on Github at

PikoPy: A python package for working with a Piko Inverter from Kostal

The first step of my plan, building a Raspberry Pi based photovoltaic monitoring solution, is finished. I created a python package that works with the Kostal Piko 5.5 inverter (and theoretically should work with other Kostal inverters as well) and offers a clean interface for accessing the data:

import pikopy

#create a new piko instance
p = Piko('host', 'username', 'password')

#get current power
print p.get_current_power()

#get voltage from string 1
print p.get_string1_voltage()

The next steps are collecting the data and processing it.

The library can be downloaded from
The code is on Github: https://github viagra en ligne

A Raspberry Pi photovoltaic monitoring solution

A friend of mine had a photovoltaic system (consisting of 14 solar panels) installed on his rooftop last year. As I was looking for another raspberry pi project I convinced him I would setup a reliable monitoring solution that will lead him to an access to the data in real-time data. The current setup comes with an inverter by the company Kostal.

Kostal Piko 5. 5 Inverter

The Kostal Piko 5.5 runs an internal web server showing statistics like current power, daily energy, total energy plus specific information for each string. However, the visual layout of the the web page and the bundled software look like they were designed in the late 90s and development has been abandoned:

Kostal Piko 5.5 Web Interface

The power inverter itself logs data at either a 15 minutes interval for about 100 days or at an hour interval for about 400 days. At the current setting the 15 minutes interval has been selected. Furthermore my friend took notes irregularly from the built-in liquid-crystal display.

The final plan is now set. A Raspberry Pi would fetch data from the inverter, store it in a database and a web application would render the results to a browser:

SolarPi SetUp

The project is live at