Softwareinstallation

If you purchased a SmartPi with preinstalled software, you can skip this chapter.

You have two options to install the SmartPi software on your computer:

  • Install a finished image
  • Installation via the software repository

We recommend that you use our ready images for installation. All important programs for smooth operation are installed and pre-configured.
If you want to install the software yourself, you must install and configure some programs yourself, as they are not included in the repositories.

These includes:

RaspAP-WebGUI: https://github.com/billz/raspap-webgui
Influxdb: https://www.influxdata.com
Grafana: https://grafana.com

Installing a prepared image

The easiest way is to install a prepared image.
You can download a ready configured image at http://files.enerserve.eu/smartpi/smartpi.7z.
In contrast to the original Raspbian, the image has many log files moved to the ramdisk and some partitions are write­protected. Download the image and unpack the file. You need a program which can extract 7­Zip files (Windows: http://www.7­zip.org/).

Installation on Windows:

  • Download the Win32DiskImager program from https://sourceforge.net/projects/win32diskimager/

  • Insert the SD card into the SD card reader of your PC

  • Note the drive letter of the SD card. You will see the drive letter in the Left column of the Windows explorer, eg G:

  • Run the previously downloaded program.
  • In the "Image File" field, select the unpacked file (* .img)

  • In the "Device" selection box, select the drive letter of the SD card and click "Write"
    ­ Wait until the writing is finished

     

Installation on Linux:

Use the dd command.
Dd bs = 4M if = path_of_your_image.img of = / dev / sdX conv = fsync
For more information, please visit: https://www.raspberrypi.org/documentation/installation/ installing­images/linux.md

Mac OS X:

Follow the instructions below:
https://www.raspberrypi.org/documentation/installation/installing­images/mac.md

 

Installation from the repository

In order to make the installation easier for you, we offer an installation script at http://files.enerserve.eu/smartpi/installsmartpi.sh.
Proceed as follows:

Log on using ssh and execute the following commands to add the SmartPi repository:

sudo su
sudo apt install apt-transport-https

For Stretch:
wget https://repro.enerserve.eu/packages/Release.key && apt-key add Release.key && rm Release.key echo "deb https://repro.enerserve.eu/packages stretch main" /etc/apt/sources.list.d/enerserve.list apt-get update

Download the script, make it executable and execute it:

wget http://files.enerserve.eu/smartpi/installsmartpi.sh
chmod a+x installsmartpi.sh
sudo ./installsmartpi.sh

The script will guide you through the installation.

Use the following commands to add the SmartPi­repository hinzu:

sudo su
apt install apt-transport-https

For Stretch:
wget https://repro.enerserve.eu/packages/Release.key && apt-key add Release.key && rm Release.key echo "deb https://repro.enerserve.eu/packages stretch main" /etc/apt/sources.list.d/enerserve.list apt-get update

 

Installation RasAP-WebGUI:

Execute the following command:
wget -q https://git.io/voEUQ -O /tmp/raspap && bash /tmp/raspap

The script will guide you through the installation. Please also note the installation instructions and the default passwords on the website (https://github.com/billz/raspap-webgui).
 
 
Installation InfluxDB:
 
Execute the following command:

curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
echo "deb https://repos.influxdata.com/debian stretch stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt update
sudo apt install influxdb telegraf

Then edit the InfluxDB configuration file:

sudo nano /etc/influxdb/influxdb.conf

Check in section [http] whether the following lines are commented out and have the corresponding values:

enabled = true
bind-address = „:8086“
auth-enabled = true

Activate and start the database:

sudo systemctl enable influxdb
sudo systemctl start influxdb
 
Then create the tables and users of the database:
 
influx -execute "CREATE USER smartpi WITH PASSWORD 'smart4pi' WITH ALL PRIVILEGES"
influx -username admin -password smart4pi -execute "CREATE DATABASE MeteringData"
influx -username admin -password smart4pi -execute "CREATE CONTINUOUS QUERY minmax_1h ON MeteringData BEGIN SELECT max(CosPhi1) AS MAX_CosPhi1,max(CosPhi2) AS MAX_CosPhi2,max(CosPhi3) AS MAX_CosPhi3,max(F1) AS MAX_F1,max(F2) AS MAX_F2,max(F3) AS MAX_F3,max(U1) AS MAX_U1,max(U2) AS MAX_U2,max(U3) AS MAX_U3,max(I1) AS MAX_I1,max(I2) AS MAX_I2,max(I3) AS MAX_I3,max(I4) AS MAX_I4,max(P1) AS MAX_P1,max(P2) AS MAX_P2,max(P3) AS MAX_P3,max(P3) AS MAX_P3,min(CosPhi1) AS MIN_CosPhi1,min(CosPhi2) AS MIN_CosPhi2,min(CosPhi3) AS MIN_CosPhi3,min(F1) AS MIN_F1,min(F2) AS MIN_F2,min(F3) AS MIN_F3,min(U1) AS MIN_U1,min(U2) AS MIN_U2,min(U3) AS MIN_U3,min(I1) AS MIN_I1,min(I2) AS MIN_I2,min(I3) AS MIN_I3,min(I4) AS MIN_I4,min(P1) AS MIN_P1,min(P2) AS MIN_P2,min(P3) AS MIN_P3,min(P3) AS MIN_P3 INTO hour FROM data GROUP BY time(1h),serial,type END"
influx -username admin -password smart4pi -execute "CREATE CONTINUOUS QUERY yield_balanced_day ON MeteringData RESAMPLE EVERY 30m BEGIN SELECT INTEGRAL(P1,1m)/60 AS E1,INTEGRAL(P2,1m)/60 AS E2,INTEGRAL(P3,1m)/60 AS E3 INTO day FROM data GROUP BY time(24h),serial,type END"

 

Installation Grafana:

There is currently no repository for Grafana. So please check at https://grafana.com/grafana/download?platform=arm if there is a newer version than the one used here.

wget https://dl.grafana.com/oss/release/grafana-rpi_6.1.6_armhf.deb
sudo dpkg -i grafana-rpi_6.1.6_armhf.deb
rm grafana-rpi_6.1.6_armhf.deb
 
sudo systemctl enable grafana-server
sudo systemctl start grafana-server
 
 
Installation SmartPi-Software:
 
sudo apt install smartpi
 
 
Finally, change the /etc/lighttpd/lighttpd.conf file to look like this:
 
server.modules = (
       "mod_access",
       "mod_fastcgi",
       "mod_alias",
       "mod_compress",
       "mod_redirect",
       "mod_proxy",
)

server.document-root = "/var/www/html"
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
#server.errorlog = "/var/log/lighttpd/error.log"
server.pid-file = "/var/run/lighttpd.pid"
server.username = "www-data"
server.groupname = "www-data"
server.port = 80

fastcgi.server = ( ".php" => ((
                              "bin-path" => "/usr/bin/php-cgi",
                              "socket" => "/tmp/php.socket"
)))


$SERVER["socket"] == ":443" {
        ssl.engine = "enable"
        ssl.pemfile = "/etc/lighttpd/server.pem"
        proxy.server = ( "" =>
                                     ( "localhost" =>
                                         (
                                             "host" => "127.0.0.1",
                                             "port" => 1080
                                         )
                                     )
                                 )
}



$SERVER["socket"] == ":80" {
        ssl.engine = "enable"
        ssl.pemfile = "/etc/lighttpd/server.pem"
        proxy.server = ( "" =>
                                     ( "localhost" =>
                                         (
                                             "host" => "127.0.0.1",
                                             "port" => 1080
                                         )
                                     )
                                 )
}
$SERVER["socket"] == ":8080" {
                 server.document-root = "/var/www/html"
}

index-file.names = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

compress.cache-dir = "/var/cache/lighttpd/compress/"
compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" )

# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
 

sudo apt install smartpi
sudo reboot

 

To update the software in the future, you only need to execute the following command:

sudo apt install smartpi

Access

By default the SmartPi is delivered with DHCP. That means the SmartPi gets an IP address from your router. In order to find the IP address of your SmartPi, you can either look in the list of registered users on your router or search the IP address with a network scanner Angry IP (http://www.angryip.org) or Netscan.

Hostname must appear at the correct IP "smartpi" or "raspberry". You can now access the website using http: // <IP address>: 1080. An ssh login is also possible:

Username: pi
Password: smart4pi or raspberry

For Internet access (port release), we strongly recommend that you change the user's password for security reasons (command: passwd). The default password is well ­known and allows hackers very easy access to your SmartPi and thus to your home network.

Web interface

The web interface can be found at http: // <IP address>: 1080
The current values of power, current, voltage, cos phi and frequency are displayed on the website.
A bar graph shows the energy of the last 8 days.

A click on Chart at the right side opens the display of the daily course of all measured values. Click on the button of the corresponding value adds the value to the course of the day. A further click removes it again.

Click on the button "Day back" to go back one day. The "Day forward" button jumps forward one day. Using the buttons "Add day back" and "Remove day back" the day view can be extended or shortened to several days.

Table view

The table view can be selected using the pop­up menu at the top left.
This allows you to view or export the table. The date fields allow you to select an exact time period.
Please note that it may take some time before the view is loaded.

Configuration page

The configuration page can be loaded via the pop­up menu. * You need a username and password for access. These can not be changed at this time:
Username: pi
Password: smart4pi

In the "default settings" you can assign a serial number, a name and coordinates to the Smartpi. When using the API (see http://blog.enerserve.eu) this information is already evaluated.
The tab "measurement" contains all settings for the measurement. Here you can select the frequency for your country (50Hz or 60Hz). In addition, it is possible to set which phase is to be measured and which sensor is connected. Here it is also possible to adjust whether the voltage is to be measured or assumed. The corresponding voltage is then adjustable.
The tabs "mqtt", "ftp", and "mobile communication" contain the access data and settings for the respective points. The MQTT and FTP upload can also be switched on and off.
Under "expert settings", you can, among other things, change the port of the web interface and the format of the CSV files.