1
Start with NOOBS.

Install NOOBS and flash a SD-card with Raspian.      

2
Follow the defaut steps.  

To install Raspian you follow the default steps and configure SSH and VNC so you can manage the device from remote 

3
SSH to you raspberry and deploy the following packages:  

sudo apt update -y

sudo apt upgrade -y

sudo apt-get install -y apache2

sudo apt-get install -y php

sudo apt-get install -y mariadb-server

sudo apt autoremove -y

Next, configure the MariaDb (Previously called MySql) with the appropriate rights.    

sudo mysql -u root -p

(just press enter)

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost';
FLUSH PRIVILEGES;
\q

Do you want to see the installation of Raspian?

play

Watch the full installation film of Raspian

Next is the installation of the MySQL management (phpmyadmin).

Run the following scripts:

sudo apt-get install -y php-mysql
sudo apt-get install -y phpmyadmin

play

Grafana is the next element that need to be installed

sudo apt-get install -y adduser libfontconfig1
wget https://dl.grafana.com/oss/release/grafana_6.7.3_armhf.deb
sudo dpkg -i grafana_6.7.3_armhf.deb

play
Make sure to autostart grafana!

sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable grafana-server
sudo /bin/systemctl start grafana-server
pip install mysql-connector-python

Now, lets create the database and tables...?

play

sudo mysql -u root -p
(press 'enter' to logon (no password))

CREATE DATABASE Moonitor16S;
CREATE USER 'Moonitor16S'@'localhost' IDENTIFIED BY 'Moonitor16S';
GRANT ALL PRIVILEGES ON *.* TO 'Moonitor16S'@'localhost' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
\q

Now the last parts...!

Open the PhpMyAdmin page and navigate to the 'Moonitor16S' database. Select the database (or click the + sign and browse it) and you shall see that no tables are there.

Selete the "SQL" tab and past the following code:

Download MySql Script

Now go back to your SSH session and create a new file called: Moonitor.py
sudo vi Moonitor.py

Download Python Script

Press 'ESC' and then type 'wq' and press 'Enter'

play
Lets see if it works!

There are 2 ways to run the python scirpt. First is to run it in the terminal window which allows you to see what is going on:&

python Moonitor.py

Or run it unattended in a background process:

nohup python -u Moonitor.py > Moonitor.log

Now login to Grafana (http://xx.xx.xx.xx:3000) and configure the datasource. Select 'Data source' and then you select 'MySql'. Fill in all the fields and name the connection in the top row. Once this is completed you can download the JSON file from:

Download Grafana Dashboard (JSON)