Install Grafana on Raspberry Pi

Introduction

The Raspberry Pi is a tiny, affordable, yet capable computer that can run a range of different applications. Even Grafana!

Many people are running Grafana on Raspberry Pi as a way to monitor their home, for things like indoor temperature, humidity, or energy usage.

In this tutorial, you’ll:

  • Set up a headless Raspberry Pi using Raspbian.
  • Install Grafana on your Raspberry Pi.

Prerequisites

  • Raspberry Pi
  • SD card

Set up your Raspberry Pi

Before we can install Grafana, you first need to be configure your Raspberry Pi.

For this tutorial, you’ll configure your Raspberry Pi to be headless. This means you don’t need to connect a monitor, keyboard, or mouse to your Raspberry Pi. All configuration is done from your regular computer.

Before we get started, you need to download a couple of things. Don’tt install them yet.

  • Raspbian Lite image

    Raspbian is a Debian-based operating system for the Raspberry Pi. Since you’re going to run a headless Raspberry Pi, you won’t need the desktop dependencies.

  • balenaEtcher.

    We’ll use balenaEtcher to flash the Raspbian image to the SD card. It’s available for Linux, macOS, and Windows.

Copy necessary files to the SD card

Once you’ve downloaded both items, we can get started with installing Raspbian.

  1. Install balenaEtcher.
  2. Start balenaEtcher and follow the instructions to flash the Raspbian Lite image to the SD card.
  3. Eject the SD card from your computer, and insert it again.

While you could fire up the Raspberry Pi now, we don’t yet have any way of accessing it.

  1. Create an empty file called ssh in the boot directory. This enables SSH so that you can log in remotely.

    The next step is only required if you want the Raspberry Pi to connect to your wireless network. Otherwise, connect the it to your network by using a network cable.

  2. (Optional) Create a file called wpa_supplicant.conf in the boot directory:

    ctrl_interface=/var/run/wpa_supplicant
    update_config=1
    country=<Insert 2 letter ISO 3166-1 country code here>
    
    network={
     ssid="<Name of your WiFi>"
     psk="<Password for your WiFi>"
    }
    

All the necessary files are now on the SD card. Let’s start up the Raspberry Pi.

  1. Eject the SD card and insert it into the SD card slot on the Raspberry Pi.
  2. Connect the power cable and make sure the LED lights are on.
  3. Find the IP address of the Raspberry Pi. Usually you can find the address in the control panel for your WiFi router.

Connect remotely via SSH

  1. Open up your terminal and enter the following command:
    ssh pi@<ip address>
    
  2. SSH warns you that the authenticity of the host can’t be established. Type “yes” to continue connecting.
  3. When asked for a password, enter the default password: raspberry.
  4. Once you’re logged in, change the default password:
    passwd
    

Congratulations! You’ve now got a tiny Linux machine running that you can hide in a closet and access from your normal workstation.

Install Grafana

Now that you’ve got the Raspberry Pi up and running, the next step is to install Grafana.

  1. Add the APT key used to authenticate packages:

    wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
    
  2. Add the Grafana APT repository:

    echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
    
  3. Install Grafana:

    sudo apt-get update
    sudo apt-get install -y grafana
    

Grafana is now installed, but not yet running. To make sure Grafana starts up even if the Raspberry Pi is restarted, we need to enable and start the Grafana Systemctl service.

  1. Enable the Grafana server:

    sudo /bin/systemctl enable grafana-server
    
  2. Start the Grafana server:

    sudo /bin/systemctl start grafana-server
    

    Grafana is now running on the machine and is accessible from any device on the local network.

  3. Open a browser and go to http://<ip address>:3000, where the IP address is the address that you used to connect to the Raspberry Pi earlier. You’re greeted with the Grafana login page.

  4. Log in to Grafana with the default username admin, and the default password admin.

  5. Change the password for the admin user when asked.

Congratulations! Grafana is now running on your Raspberry Pi. If the Raspberry Pi is ever restarted or turned off, Grafana will start up whenever the machine regains power.

Congratulations

Congratulations, you’ve made it to the end of this tutorial!

Learn more