Software-Install

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

You have 2 different possibilities to install the SmartPi ­software on your computer:

  • Installation of a ready-made image
  • Installation via the software repository

Own installation vs ready image

We recommend you to take our prefabricated images for installation. All programs that are important for smooth operation are installed and configured there.
If you want to install the software yourself, you will have to install and configure some programs yourself, as they are not included in the repositories.

These include:

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

Installing a ready image

The simplest variant is to install a ready-made image.
At http://files.enerserve.eu/smartpi/smartpi-buster.7z you can load a ready configured image.
In contrast to the original Raspbian, many log files are moved to the ramdisk and some partitions are write-protected. Download the image and unpack the file. You need a program which can unpack 7­zip­files (Windows:http://www.7­zip.org).

Installation under Windows:

  • Download the program Win32DiskImager 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 can see the drive letter in the left column of Windows Explorer, e.g. G:
  • Run the program you downloaded earlier.
  • Select the unzipped file (*.img) in the "Image File" field.
  • Select the drive letter of the SD­card in the "Device" selection field and click on "Write".
  • Wait until the writing is finished

 

Installation under Linux:

Use the command dd.

dd bs=4M if=path_of_your_image.img of=/dev/sdX conv=fsync

More detailed information can be found at:
https://www.raspberrypi.org/documentation/installation/installing-images/README.md


Mac OS X:

Follow the instructions at:
https://www.raspberrypi.org/documentation/installation/installing-images/README.md

 

Installation from the repository

To make the installation easier for you, we offer an installation script at http://files.enerserve.eu/smartpi/installsmartpi.sh ein Installationsskript an.

Proceed as follows:

Log in via ssh and execute the following commands to add the SmartPi repository:

sudo su
sudo apt install apt-transport-https

For Stretch:
sudo 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 run 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 SmartPiRepository:

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

 

Install InfluxDB:

Run 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 configuration file of InfluxDB:

sudo nano /etc/influxdb/influxdb.conf

In the [http] section, check that the following lines are commented out and have the appropriate 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"

 

Install Grafana:

There is currently no repository for Grafana. Therefore, check https://grafana.com/grafana/download?platform=arm to see 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
 
 
Install SmartPi software:
 
sudo apt install smartpi
 
 
Finally, please modify the /etc/lighttpd/lighttpd.conf file so that it looks 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. This means that it is assigned an IP­address by your router. To find out the IP­address of your SmartPi, you can either look in the list of registered on your router or search the IP­address with a network scanner Angry IP (http://www.angryip.org) or Netscan.

The hostname of the correct IP must be "smartpi" or "raspberry". You can now access the website with http://<IP­address>:1080.
A ssh­login is also possible:
Username: pi

Password: smart4pi or raspberry

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

Web interface

You can reach the web interface at http://<IP­address>:1080
The web page currently displays the current values of power, current, voltage, cos phi and frequency. A bar display shows the energy of the last 8 days.

A right click on Chart opens the display of the daily history of all measured values. A click on the button of the corresponding value adds the value to the daily history. Another click removes it again.
The button "Day back" can be used to go back one day. The button "Day forward" jumps one day forward. The "Add day back" and "Remove day back" buttons can be used to extend or shorten the day view to several days.

Table view

The table view can be selected via the drop-down menu at the top left. Here a view or an export of the table is possible. Via the date fields an exact period can be selected. Please note that it may take some time until the view is loaded.

Configuration page

The configuration page can also be loaded via the drop-down menu. For access you need user name and password. These cannot 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 (at http://blog.enerserve.eu) this information is already evaluated.

The tab "measurement" contains all settings for the measurement. Here you can select the appropriate frequency for your country (50Hz or 60Hz). Furthermore you can set at which phase the measurement should be done and which sensor is connected. Here you can also set whether the voltage is to be measured or assumed. The corresponding voltage can then be set.

The tabs "mqtt", "ftp", and "mobile communication" contain the access data and settings for the respective points. Also the MQTT­ and FTP­upload can be switched on and off there.
 
Under "expert settings" you can change the port of the web interface and the format of the CSV­files.