Solar Panel Monitoring

Software for Arduino Yun (Linux side)

I will not explain the initial setup of the Arduino Yun here. You can find good tutorials on the web about this. What you need to remember is the username, password and IP address you assigned to the Arduino board during the initial setup. I recommend strongly to apply a fixed IP address to the board to make communication easier.

The Arduino Yun is basically two independent systems on one board. You have an 8bit AVR micro controller and a Linux system based on the Atheros AR9331. The Atheros runs a Linux distribution based on OpenWrt named OpenWrt-Yun (Aka Linino).

I use the AVR controller for the measurement of currents, voltage and light. This data is then transferred to the Atheros system which performs the communication part to distribute the data. The communication between the AVR and the Atheros is done by a serial connection and a software called the “bridge“. There are several tutorials on the web that explains how the two systems communicate with each other using the “bridge“. I will explain only the few functions of the “bridge” I use in this application.

Very first important step before we go on.

The memory of the Linux system is limited. Therefor it is recommended to expand the memory by using a SD card. Detailed steps can be found at How to expand the Yún disk space. Please follow this tutorial before going on with the next step.

Additional software needed on the Linux system

The standard installation of the OpenWRT-Yun is missing some functions that we need for this application. For storage of the data we use Sqlite, for the communication we use PHP5 and for displaying the recorded data we use GD. Some of these moduls are missing and need to be installed. To do this we need a SSH connection to the Linux system. A SFTP connection to transfer some files will be helpful as well. As my development system is Windows, I use Bitvise SSH client which provides both the SSH terminal and the SFTP client. If you are using Linux or MacOS, then you need a similar tool.

First open a SSH connection to the Arduino Linux. Then install the necessary packages with opkg:

After installation it is necessary to change some settings for PHP and the UHTTPD server. Edit /etc/php5.ini and enable the following extensions:

Edit /etc/config/uhttpd as well and change the following lines:

After that restart the web server with

Create the database

The easiest way is to copy the file create.sql to the root of the SD card with SFTP. The file can be found on my Github repository. Then use SSH and enter the following commands:

This creates an empty Sqlite database on the root of the SD card. The database has one table named “s” and four columns named

This database will be filled with records from the AVR micro controller and accessed by PHP pages to transfer or display the records.

PHP scripts

The PHP pages to access the data from a local network or to display the data in a web browser will be automatically uploaded when you install the Arduino sketch on the board. To achieve this the PHP pages must be located in a folder called www in the path where the Arduino sketch files are saved. If you clone my Github repository the files will be automatically placed in the correct folder.

That’s all setup to be done on the Linux side to access the data from a local network.

The next page shows details about the PHP scripts that are used.

Loading...
Facebooktwittergoogle_plusredditpinterestlinkedintumblrmail

Leave a Reply

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

Free Link Directory