Howto install InfluxDB and Grafana on a Raspberry Pi 3

Inspired by a friend I’ve decided to install InfluxDB and Grafana on my Raspberry Pi 3. InfluxDB is a database optimized for storing time related data like measurements of my recently installed particle sensor. Grafana is used to create beautiful graphs to display the stored data.

The InfluxDB installation can be done in a few simple steps:

This will install the InfluxDB without a user and any rights. You can read up further on that topic. Ideally you should setup an user for authentication but since some IoT devices do not support this I’m not going to explain it here.

The Grafana installation is similar simple:

Please make sure that you’ll get the most current version from github and replace it in the wget command:

First login to Grafana:

Now you’re ready to configure Grafana. Go to http://<ip-of-grafana-machine>:3000 and setup a new username and password for the webinterface. The default is admin/admin

Configure InfluxDB as datasource in Grafana:

You need to configure a datasource under http://<ip-of-grafana-machine>:3000/datasources

Enter as name the name of the database you’ve created earlier. In this case it was topic.

The type of the database is InfluxDB.

The HTTP connection URL is http://localhost:8086

Hit Save & Test, once you’ve configured everything to your liking. The connection to the database should work now.

Howto setup local DNS domains and adresses in pihole

If you use the AVM FritzBox you’ll now about this dreaded DNS suffix „fritz.box“ which every device will get in your network, if you decide to use the DNS server of the FritzBox. I wanted to have something different which doesn’t collide with domains on the internet, e.g. „stuff.local“. As I already use pihole as adblocker on DNS level I needed a solution to configure it in pihole. The following info is based on the pihole forum.

Create a file called lan.list in /etc/pihole and fill it with content in the following format:

<ip-address> <hostname>.stuff.local <hostname>

Create a second dnsmasq config file which references the file we’ve just created:

echo "addn-hosts=/etc/pihole/lan.list" | sudo tee /etc/dnsmasq.d/02-lan.conf

Restart the dns services in pihole:

sudo pihole restartdns

You should now be able to lookup your stuff.local hostnames on your pi with e.g.

nslookup box.stuff.local
Server:		127.0.0.1
Address:	127.0.0.1#53

Name:	box.stuff.local
Address: 192.168.100.1

Howto ensure automatically mounted NFS volume on Raspbian Stretch

I’ve tried to setup NFS on my old Raspberry Pi 1 with Raspbian Stretch. I assumed that I just need to add an entry to the /etc/fstab file and the NFS volume on my Synology NAS would be mounted automatically.

So I’ve added this

mynas:/volume1/databases /mnt/databases nfs defaults 0 0

and thought I would be done. I’ve created the /mnt/databases folder with

mkdir /mnt/databases

and tried to mount everything with

mount -a

and my volume showed up as mounted. After reboot the volume wasn’t mounted anymore and the service couldn’t find its data. So what shall we do? After some research I’ve found these options, which fixed the problem:

mynas:/volume1/databases /mnt/databases nfs defaults,noauto,x-systemd.automount 0 0

The NFS volume now shows up even after a reboot. I’ve also tried to change the configuration of Raspbian so that it waits for the network before any services start but that didn’t fix the problem. Interestingly the entry with only defaults seems to be working on a Raspberry Pi 3 B.

DIY HomeKit with Raspberry Pi and Xiaomi Robot Vacuum

Inspired by tweets of Steven Troughten-Smith, people started to experiment with Raspberry Pi’s as DIY HomeBridge devices. One of them is Wojtek Pietrusiewicz. He wrote a nice article which I used as base for this post.

Introduction

I own a Xiaomi Robot Vacuum. This robot can be controlled by the Xiaomi app, however, I don’t like it very much. The idea is to control this robot over HomeKit. To use HomeKit, I use an old Raspberry Pi 1B. The software will be HomeBridge.

Setting up the Pi

Installation and Configuration of Raspbian

Use Etcher to write the image to the SD card. Remount that SD card and add a file called „ssh“ in the root of the mounted partition. This will enable SSH from the beginning so that you can login directly to the Pi. I don’t want to attach a screen or keyboard to that machine so it will only be reachable over the network. Now boot your Pi from this SD card.

Identify the Pi’s IP (e.g. by looking at the network overview in your router). Now connect to that IP with user „pi“. The default password is „raspberry“. Please change the password now with passwd and assign a new user password.

Update everything with apt:

 

Install nodejs 8.9.4

According to Wojtek only this version works currently with HomeBridge. I did not test any other version so I’m just describing what I did on my machine:

  1. Download nodejs for the PI into your users homefolder, e.g. with wget https://nodejs.org/dist/v8.9.4/node-v8.9.4-linux-armv6l.tar.xz
  2. Unpack the file with tar -xvf node-v8.9.4-linux-armv6l.tar.xz
  3. cd node-v8.9.4-linux-armv61
  4. sudo cp -R * /usr/local/
  5. add export PATH=$PATH:/usr/local/bin to e.g. ~/.bashrc
  6. node should be now available

Install HomeBridge

  1. Install the necessary libraries: sudo apt-get install libavahi-compat-libdnssd-dev
  2. Install HomeBridge with npm: sudo npm install -g --unsafe-perm homebridge
  3. open /etc/default/homebridge and safe it with this content:
  4. open /etc/systemd/system/homebridge.service and safe it with this content:

Setting up HomeBridge with Xiaomi Robot Vacuum

  1. sudo npm install -g homebridge-xiaomi-mi-robot-vacuum miio
  2. open ~/.homebridge/config.json and safe it with this content:

    Generate a new MAC address separated by : using this website. You’ll need the IP address of your Xiaomi robot as well as the token. There are several ways to get the token. I’ve extracted mine from the iOS backup. Instead of uploading the token I’ve used this command on the token taken from the sqlite database:
  3. Check if everything is working by starting homebridge for the first time. It should show a QR code. If it does, cancel the process with ctrl+c

Automate HomeBridge startup

Adding the HomeBridge to iOS devices

  1. Install the Home app, if you’ve removed it from your device. You can reinstall it from the App store.
  2. Open the Home app and add a new device
  3. If you’ve give the app access to your camera, you can scan the QR code you’ve seen earlier. However, HomeBridge is now running as a daemon in the background so you won’t see that QR code. You can add the bridge manually by using the PIN you’ve set in the config.

Raspberry Pi 3 with Kodi, Netflix, Spotify Connect, Hyperion and RetroArch

I’m currently using an old Mac Mini from 2009 as my media center. I’ve updated it recently with more RAM and an SSD but it has its problems with Bluetooth, regardless my used bluetooth card or USB adapter. Before this setup I’ve used a Raspberry Pi 3 with LibreElec which I’ve now reactivated successfully.

I’m using the Mac Mini for hearing Spotify, watching Netflix and Sky Go Connect, SNES Emulator with Xbox 360 and PS3 Gamepads and of course Kodi as media center in combination with Hyperion on a Raspberry Pi 1 as Ambilight clone. I’ve had to replace all this functionality with the Pi 3, but luckily it is possible!

I’ve started with LibreElec (8.0.2 stable) and installed it on the Pi 3. I had to copy the necessary Kodi files for setting the used sources and mysql database, so that I get my existing library and its viewing status.

Hyperion was easy to install via HyperionRemote. I only had to enable guest control for external resources in Kodi, so that Hyperion could properly shut down the backlight while the main menu is being displayed.

The SNES emulator can be used on LibreElec using the Kodi add-on Gamestarter. Just follow the GitHub instructions.

My Xbox 360 Gamepads where installed without problems. I just had to connect them via the USB adapter and pair them with the adapter. They are usable in Kodi as well as in Gamestarter without further configuration. I think that PS3 gamepads will probably behave similar.

The Bluetooth Mac Keyboard and Trackpad can also be paired with the Pi 3 via LibreElecs system settings. This allows a better search since you don’t need to use the onscreen Keyboard.

For Spotify I’ve just wanted the Pi 3 to appear as a Spotify connect speaker. The mobile apps and my other machines in the network are a better solution to select the music I want to hear, so I just wanted the Pi 3 to appear as a target. The Librespot provides this cool feature and also enables you to add easily Spotify connect to other rooms in your house with just a Raspberry Pi. Just search in the add-on for Librespot and install it. After a restart its active. Spotify connect is available immediately and stops automatically once a movie is started. It will be available again once the movie is really stopped (being paused is insufficient). Connecting to Librespot is really fast and works even better than with my Heos speakers!

Netflix is a completely different beast. Netflix is relying on a library called WideVine which handles the DRM. Google created a version for Chrome on ARM devices and some LibreElec and Kodi developers found a great way to integrate all this into the next version of LibreElec 9 and Kodi 18. So you need to update to  LibreElec 9 alpha. Copy the downloaded update file for Raspberry Pi 2 and 3 and put it into the update folder of your Pi 3. Now just restart and you’ll get the new version. However, be sure to make a backup of your library, just in case anything doesn’t work as expected!

You’ll now need the WideVine libs, you can install them with this command on your Pi:

You’ll now only need the plugin.video.netflix add-on. Once it is started you’ll be asked for your Netflix credentials. If you enter everything correctly you’ll have all the options of Netflix displayed as nice library entries in Kodi. Really comfortable if you ask me! It even works directly with the Hyperion Ambilight which is a cool feature. I was able to use 720p without problems, 1080p is too much for the Pi 3 to decode only in software.

Now with LibreElec 9 you’ll have problems starting RetroArch via Gamestarter. Luckily there’s a version for LibreElec 9 which you can just install and update your existing add-on.

 

Congratulations! You’ve got now a Rasperry Pi 3 with Kodi 19, Hyperion Ambilight, RetroArch Emulator, Xbox 360 Gamepad support and Spotify Connect. Only thing not working is Sky Go Connect Ticket, due to a missing browser and probably DRM related issues. But since I’m just using it for 3 months to see Game Of Thrones I can workaround this with connecting my MacBook to the TV.