What do you need to make a very basic real time reporting of temperature, humidity and air pressure? Not much.
- Rasbperry PI, number three (oh, it rhymes). You’ll find one from Teknikmagasinet for 32.90€)
- a mouse and a keyboard with USB ports and screen with HDMI port (check you stashes)
- a package of ruuvi’s, – I have six ( 69€/ 3 pieces)
- Microsoft Power BI for desktop (free)
- Android mobile phone – not necessarily needed, but helps testing
Few things… First of all, be sure to have the Raspberry PI number 3, it has built-in bluetooth and WiFi. Create an account for Microsoft Power BI. Creating account is free and downloading and installing Microsoft Power BI is free. Also publishing your report for your own workspace is free, but when and if you want to share your report with someone, let’s say, with your mom or colleague, you will need a license.
To have the Do It Yourself monitoring system requires following steps:
- Install and configure your Raspi.
- Install apache
- install php
- install mysql
- install phpmyadmin
- install python
- Configure you ruuvi’s
- make the tags ready
- configure the ruuvi libraries
- Make your report
To keep things organised, instructions are divided into five posts. We’ll start with the Raspberry PI and it’s configuration. In my case, I don’t have extra mice and keypads laying around in my apartment, so I prefer using the remote connection to my PI. To do this, check this guide. Also, if you are familiar with LAMP, you can move to the next post.
Install and configure your Raspberry PI
You can have your PI pre-installed. If this is the first time you hear about PI, I suggest you order it pre-installed. Next, you need to have web server on your Raspberry. At this point
Before installing the server, make sure you have an up-to-date PI. To do this you must have administrator rights, either because of the sudo command.
sudo apt update
sudo apt upgrade
sudo apt update
Install Apache
Once the Raspberry Pi is up to date (you will see “All packages are up to date” note), you will want to install the Apache server.
sudo apt install apache2
You will want to give rights to the apache file that you can easily manage your sites. To do this, run the following:
sudo chown -R pi:www-data /var/www/html/
sudo chmod -R 770 /var/www/html/
Check that Apache is working properly by opening Raspberry web browser and type “http://127.0.0.1”. You will see a page saying something like “it’s working”.
Install PHP
Next you need to install PHP. Run the following:
sudo apt install php php-mbstring
Check if PHP is working by creating a file “index.php” file in your web server root directory, meaning “/var/www/html”. I like pico editor, but use whatever you like.
cd /var/www/html/
sudo pico index.php
The contents of the file index.php are the following: <?php phpinfo(); ?>
If you get a page like the one in the picture below, you are good to go.
Install MySQL
Next you will need a database – MySQL
To do this, you will install mysql-server and php-mysql (which will act as a link between php and mysql and makes your life easier)
Run the following;
sudo apt install mysql-server php-mysql
Install phpmyadmin
Next phpmyadmin… You don’t need phpmyadmin, but if you don’t know any SQL, then this is what you want to do.
Run the following:
sudo apt install phpmyadmin
The installation program will ask, whether to use Apache or something else. Be sure to choose Apache and click OK. The root password is the one you set for MySQL. To check that PHPMyAdmin works, you will try to access it at http://127.0.0.1/phpmyadmin.
That’s it. Next we need to install python. Run the following:
sudo apt-get install python3
I’m not a fan of python myself, but there’s a ready-made ruuvi tag library in Github, you will love that and everything will go smoothly.
To be continued.