Solar powered pond - part 6

Actually, this isn't exactly related to the Solar Powered pond... it's more to do with the collection of DATA and viewing it.


Previously, I was using a node-red dashboard to output the current / live status of the data fetched (via modbus) from the MPPT controler.  This worked a treat...however.... it did tend to crash after a day or so.  Digging a bit deeper; whilst I was saving the data to a stats.csv file (gets re-created upon the RPi restart), this was always a temporary solution and the data should be saved into an InFluxDB... turns out the node-red charts are okay for showing data "for a bit"... but not the 1000s od data points I was giving it every second for days on end, something has to give... analysing the webpage content, the dashboard could grow from a 20-ish MB page up to 400+ MB page; just to show live data.

Something had to be done about this....and well, a midday overcast Sunday proved to be the solution.

Behold GRAFANA presenting data from an InFluxDB (is it with a  capaital F, I should really check) :


I installed InFluxDB (I've started now, so I be consistent!) onto the RPi 3+ device, I also installed Grafana and then set it into anonymous-authentication mode - shock!horror! run for the hills screaming!!! yes, as this is running from localhost and I only want/need to use this at home, I really don't care about the added security layer (for now....)

I suppose in true tradition, I should record the steps that I followed here, so I can re-do it again when I blow this RPi 3 device up, or upgrade or change it out to run on a PICO W or something else :-)

Turns out it actually is: InfluxDB.... I've been adding the capital F, because, well, because, I'll stop it now...

I was looking at following this article:

https://learn.pimoroni.com/article/enviro-and-influxdb#installing-influxdb-and-grafana

I got tot he first link and followed the "excellent tutorial" here:

https://sandyjmacdonald.github.io/2021/12/29/setting-up-influxdb-and-grafana-on-the-raspberry-pi-4/

That in a nut-shell tells you to do the following:

Install InfluxDB:

$ wget -qO- https://repos.influxdata.com/influxdb.key | gpg --dearmor | sudo tee /usr/share/keyrings/influx-archive-keyring.gpg >/dev/null

$ echo "deb [signed-by=/usr/share/keyrings/influx-archive-keyring.gpg] https://repos.influxdata.com/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/influxdb.list

$ sudo apt update && sudo apt install -y influxdb


That's it.  you've got it installed now.  However, you might want o run it as an auto-service, so do:

$ sudo systemctl unmask influxdb.service

$ sudo systemctl start influxdb

$ sudo systemctl enable influxdb.service


From a command-line, you can literally type:

$ influx

That gets you into a prompt, then type the following:

create database home

use home

create user grafana with password 'grafana' with all privileges

grant all privileges on home to grafana

Yeah, I did that...I set the grafana password to be that simple - come hack me :-D

just to check, now type:

show users

and it should show that grafana user is an admin.


Install Grafana:

Within the same Terminator window, type the following:

$ wget -O- https://packages.grafana.com/gpg.key | gpg --dearmor | sudo tee /usr/share/keyrings/grafana-archive-keyring.gpg >/dev/null

$ echo "deb [signed-by=/usr/share/keyrings/grafana-archive-keyring.gpg] https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list


$ sudo apt update && sudo apt install -y grafana


Now, there will be some comment at the end about you needing to do some stuff...basically it is this:

$ sudo systemctl unmask grafana-server.service

$ sudo systemctl start grafana-server

$sudo systemctl enable grafana-server.service


You now have Grafana installed locally and as an auto-starting service too. sweet.

As the previously linked article states, now you open up a web-browser to http://IP:3000


change the password to something like grafanaadmin - or something so easy to hack/crack it's painful.

...and that's it, you can now start creating a dashboard.

I found the 2nd part of this ARTICLE:

https://sandyjmacdonald.github.io/2021/12/29/logging-raspberry-pi-environmental-data-to-influxdb/

rather helpful in setting up access to the data to show in a panel.

I now just have to figure out how to display gauges as well as bar charts - I love a good gauge!



Oh, as to anonymous-access? why did I do that?

Well.... I have the RPi set up to auto-boot into chromium and display the dashboard, so I can have an instant panel visible to give me an indicator of status - what dashboards are useful for.  However, by default grafana is setup to have login access; quite rightly.  It's a very powerful feature, you can share dashboards with different teams of people in different organisations (that you define - basically groups), it's pretty nifty & I would totally use it in a work environment like that...however, this is just me, so it is not needed here.


On the RPi device:

$ cd /etc/grafana

$ sudo nano grafana.ini

Then scroll down 5-6 screens and then make the edits as shown here:

https://grafana.com/docs/grafana/v9.0/setup-grafana/configure-security/configure-authentication/grafana/#anonymous-authentication

You will need a device / service restart - just easier to bounce the RPi.

I changed the Chromium auto-start webpage to be the SHARE link of the dashboard and lo-and-behold, it shows up in KIOSK mode on the screen - it's been running now for an hor or so and hasn't crashed yet!  I'll get access from my phone on the network too and a few other devices, just to replicate what I was doing with node-red dashboard.


Absolutely no dig at node-red here, it does what it does and does it well, I was just abusing it and always knew I needed to move to a different dashboard - I've done that now & it wasn't as painful as I thought!  That's always a bonus.

Displayed on a web-browser (yes, I found the [gradient / opacity] setting!)


and nicely rendered on my Android phone:

will need to jiggle around as I say to make gauges and to change the size of the panels etc.. that'll come later - might also look into overlaying the Volts and Current values into single panels... we'll see.

yeah - I couldn't let it lie - here's the snazzy version:



Comments