InfluxDB on Raspberry

Hi,
I’ve installed InfluxDB on my raspberry.
I have a wonderful script running that stores data from my sound sensor in my influxdb Database.

Now, I want to connect my laptop to the database on my Raspberry, where I want to use a python script to get the data.
How should I configure influx on the Raspberry so I can get my data out?

Hi @MichielBbal,
Nice to meet you digitally and welcome to the community. Have you tried our Python client?

You can use this to query InfluxDB and pull out the data in a variety of forms:

Here is an example of where I used the client to pull data into a flask server that I am hosting:

Check out, my influx_helper class. There are also really great examples located here: influxdb-client-python/examples at master · influxdata/influxdb-client-python · GitHub

So I created this script:
from influxdb import InfluxDBClient, DataFrameClient

client=InfluxDBClient(host=“raspberry-ip”,port=“8086”)
client.create_database(“TEST”)
client.get_list_database()

reesulting in the following error:
ConnectionError: HTTPConnectionPool(host=‘http’, port=80): Max retries exceeded with url: // raspberry-ip:8086/query?q=CREATE+DATABASE+%22TEST%22 (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x00000231CD7466A0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed’))

Hope you can help me out! Thanks a lot.

First of all, we should clarify which version you have installed on the Raspberry:
InfluxDB Version 1.x or Version 2.x ?

Hi Franky1,

pi@raspberrypi:~ $ influx --version
InfluxDB shell version: 1.8.10

ah sorry, @MichielBbal I did not realise you were using 1.8. Could you try this library instead?

Also, could you try using the exact IP of the Pi, to begin with before trying the hostname? Let’s see if we can get you connected.

Hi, my hostname is http://192.168.178.50:8086 and I’ve also tried this library, however still without success. Hope to hear from you.

We don’t get anywhere with such imprecise information.
What exactly is not working? Error messages?
I assume both devices are on the same internal network? Can you ping the Raspberry from the Laptop?
Before I would start with a Python script - which itself can contain errors - I would first check the basics!?

Off course, I always ssh into my RPi. I can ping it as well, no worries. And yes, they are on the same internal network.
I even have Grafana installed on hass.io that can connect to my Raspberry to retrieve all the data from the RPi.

Hope to get some good suggestions on how to connect to the InfluxDB on my RPi remotely.

What do you get if you call the url in the browser of your laptop?

http://192.168.178.50:8086

Do you get a

404 page not found

response?

If yes, start with a very simple python client example:

from influxdb import InfluxDBClient

client = InfluxDBClient(host='192.168.178.50', port=8086)
pong = client.ping()
print(pong)

You should you get something like

1.8.10

Thank you, indeed my response was: 1.8.10 !
Look forward to your next suggestion.

Then the connection works.
I don’t know what you have in mind, so I don’t know what the next steps would be.
Read the documentation and expand this simple script bit by bit:

https://influxdb-python.readthedocs.io/en/latest/

I’ve got everything working now.
I can retrieve data using the python library.
Thank you again, Franky1 and Jay_Clifford!

1 Like