Solar Panel Monitoring

The PHP scripts

The system uses 3 PHP pages and a graphic library for the communication and display of the data.


This PHP page is only to check the setup of the PHP configuration on the Linux server. It is not required for daily operation. When you open “IPADDRESS/sd/spMonitor/phpinfo.php” (replace IPADDRESS with the IP address you assigned to your Arduino board) you can see the standard PHP info. Important is that the following packages are available:


When I started this project my main target was to use Android phones/tablets to display the recorded data. But for initial testing I created a very primitive web page that shows the recorded data on a web browser. This is achieved with index.php.

The layout of the webpage is very simple. At the top is a scroll box that shows all available records organized by day.

For every day there are 2 options:

  • YY-MM-DD-filled => displays all records of the day DD at the month MM in the year YY in a graph.
  • YY-MM-DD-zoomable => displays all records of the day DD at the month MM in the year YY in a graph that can be zoomed in and out horizontally and vertically.

One day display, not zoomable

one day, zoomable, zoomed in

The code snippet to get the list of available days from the database. It is doing a query on the column “d” to get all available years, months and days and writes the result into a HTML table:

The date that will be displayed after clicking on a link in the list is send to the PHP page with the parameter day=15-08-21. The second parameter type=zoomline(or filled) defines which type of graph is displayed. To draw the graph I use the FusionCharts library with their PHP wrapper. FusionCharts offers a free (unlimited) trial version. It only shows a watermark on each graph. But if you want to use it in commercial applications you need to buy a license. I will not go into details how to use the library. You can check the file index.php to see how I create the plot.


This PHP page is used from the Android application to send a query to the Sqlite database on the Arduino board and receive the output as a JSON string. The query is initiated with a call to “IPADDRESS/query.php?date=param1&get=all(replace IPADDRESS with the IP address you assigned to your Arduino board).

The first parameter “date” sets the limiter for the query:

The second parameter “get=all” tells the script if all entries newer as defined in “date” should be sent as well.


The key points of the PHP script are:

which gets all rows where “d” contains the substring $dateSelect and

which gets all rows that are newer than the last row found in the first query.

The data submitted from the database by these two queries are then encoded as a JSON array and sent back to the requesting client.

Have a look on query.php to see more details.

The AVR part of the Arduino Yun is responsible for the current and voltage measurement. Check out details on the next page about Software for Arduino Yun (AVR side).


Leave a Reply

Your email address will not be published. Required fields are marked *

Free Link Directory