How to Use InfluxDB and Grafana on Raspberry Pi
InfluxDB and Grafana on a Raspberry Pi, first install InfluxDB to store time-series data, then install Grafana to visualize that data. Configure InfluxDB to accept data and connect Grafana to InfluxDB as a data source for creating dashboards.Syntax
Here are the main commands to install and start InfluxDB and Grafana on Raspberry Pi running Raspberry Pi OS (Debian-based):
- Install InfluxDB:
sudo apt install influxdb - Start InfluxDB service:
sudo systemctl start influxdb - Enable InfluxDB to start on boot:
sudo systemctl enable influxdb - Install Grafana: Add Grafana repo and install with
sudo apt install grafana - Start Grafana service:
sudo systemctl start grafana-server - Enable Grafana on boot:
sudo systemctl enable grafana-server
These commands set up the services and make sure they run automatically after reboot.
sudo apt update sudo apt install influxdb sudo systemctl start influxdb sudo systemctl enable influxdb sudo apt install -y software-properties-common wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add - sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main" sudo apt update sudo apt install grafana sudo systemctl start grafana-server sudo systemctl enable grafana-server
Example
This example shows how to insert sample data into InfluxDB and create a Grafana dashboard connected to it.
1. Insert data into InfluxDB using its command line:
influx write -b mybucket -o myorg 'temperature,sensor=room1 value=23.5'
2. Open Grafana in your browser at http://raspberrypi.local:3000 (default login: admin/admin).
3. Add InfluxDB as a data source in Grafana with your bucket and org details.
4. Create a dashboard and add a graph panel to visualize the temperature data.
# Insert sample data into InfluxDB influx write -b mybucket -o myorg 'temperature,sensor=room1 value=23.5' # Start Grafana server (if not running) sudo systemctl start grafana-server # Access Grafana at http://raspberrypi.local:3000 and login # Add InfluxDB data source with bucket 'mybucket' and org 'myorg' # Create dashboard and add graph panel to show 'temperature' measurement
Common Pitfalls
Some common mistakes when using InfluxDB and Grafana on Raspberry Pi include:
- Not starting the services after installation, so InfluxDB or Grafana won't respond.
- Forgetting to enable the services to start on boot, causing loss of data collection after reboot.
- Incorrect InfluxDB bucket or organization names when configuring Grafana data source.
- Firewall or network issues blocking access to Grafana's web interface on port 3000.
- Using outdated versions of InfluxDB or Grafana incompatible with Raspberry Pi architecture.
Always check service status with sudo systemctl status influxdb and sudo systemctl status grafana-server.
### Wrong: Not starting services sudo apt install influxdb grafana # Forgot to start services ### Right: Start and enable services sudo systemctl start influxdb sudo systemctl enable influxdb sudo systemctl start grafana-server sudo systemctl enable grafana-server
Quick Reference
Summary tips for using InfluxDB and Grafana on Raspberry Pi:
- Always update your system before installing:
sudo apt update && sudo apt upgrade - Use
systemctlto manage services: start, stop, enable, and check status. - Configure InfluxDB buckets and organizations before sending data.
- Access Grafana via
http://raspberrypi.local:3000or your Pi's IP address. - Secure Grafana by changing default passwords after first login.