Epever/Epsolar output to InfluxDB/Grafana

I setup reporting for my EPever solar charge controller a while ago using  using the following guide at sporadic projects.  It works but have been hankering for something a little more/different and saw a posting recently of someone using grafana and influxdb to report on their PIP based solar setup so i set about recreating this and in all honesty it wasn't as bad as i thought and after a few days i've gotten something up and running.



The first step was setting up my pi, i decided to reuse a aging pi1 which caused some issues as i couldn't install things from the standard repo's so it needed a little more tinkering.  I documented this as i went so i hope this helps others using it on a pi1 also.

The below shall download a precompiled influxdb setup and install it.  It will then add a custom repo to your sources list and install grafana and then start it up and enable it at startup.  Lastly it shall install php and the curl library for php and then install the influxdb library for php using composer.  Socat is optional but if your using one of my rs485 to wifi devices you shall need it to connect to the serial port over the network, if your using a physical connection you can update the code accordingly with the correct serial port.

wget https://dl.influxdata.com/influxdb/releases/influxdb_1.2.0_armhf.deb
sudo dpkg -i influxdb_1.2.0_armhf.deb

echo "deb https://dl.bintray.com/fg2it/deb-rpi-1b jessie main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
sudo apt-get update
sudo apt-get install grafana

sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable grafana-server
sudo /bin/systemctl start grafana-server

sudo apt-get install socat

sudo apt-get install php5-fpm
sudo apt-get install php5-curl

So you can get to the influxdb web interface you need to first enable it with the below.
sudo nano /etc/influxdb/influxdb.conf
Change enabled = false to enabled = true under the [admin] section.

Next you need to conenct to the wifi serial adaptor so this is done using socat which we installed earlier
sudo socat pty,link=/dev/ttyUSB21,unlink-close=0,raw,echo=0 tcp:WirelessDeviceIPAddress:23&
sudo chmod 777 /dev/ttyUSB21


Once this is done you shall need to launch a web browser and go to

http://IP of your Pi:8083/

from here you can create a db called powerwall, it's self explanatory and very easy.  Then create a user called root with password root for the DB, i created it as an admin but that is optional.

Once you have done this you shall need to go to the web interface of the new grafana installation at the following address

http://IP of your Pi:8083

From here you configure the datasource as per below


Once this is done the database and grafana initial configuration is done.  You now need to download a few files from github.  I use the php library which toggio kindly wrote which made this possible, i'd say easier but possible is a more honest answer.

https://github.com/toggio/PhpEpsolarTracer
https://github.com/chickey/Epever-influxdb

Place the files into one directory together and run

php logger.php

If it works it should print out the current realtime and statistical information.  If you receive a could not connect error then please check that socat is still running correctly, i find it can drop out for.  If it's working ok then put it into crontab to run as frequently as required.

Lastly you then need to go back to grafana and start to create some dashboards which is simple and very wyswig.  If you want/need an example let me know and i can upload my dashboard.

Comments

Unknown said…
Where do you put the GitHub files?
chickey said…
Hi Scott, you can place them in any directory, doesn't have to be anywhere specific.

Col
Unknown said…
I run it and get:
PHP Warning: require(vendor/autoload.php): failed to open stream: No such file or directory in /home/pi/logger/logger.php on line 10
PHP Fatal error: require(): Failed opening required 'vendor/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/pi/logger/logger.php on line 10

I am on a Pi3 running Jessie lite, maybe something is different.
chickey said…
Are you running logger.php from the same dir which contains the PhpEpsolarTracer files?
Unknown said…
Yes, copied all files from both GitHubs to one folder
chickey said…
What do you get if you run

php example_cli.php

from the directory.
Unknown said…
I get, Cannot open serial port /dev/ttyUSB0 ... I am using /dev/ttyUSB21 for the Tracer Dashboard
chickey said…
that is what i use in my code also so it should work. To get it to work in the example code i mentioned though you just need to open up that php file and find the line

$tracer = new PhpEpsolarTracer('/dev/ttyUSB0');

and modify it to

$tracer = new PhpEpsolarTracer('/dev/ttyUSB21');

then try the cli example again.
Unknown said…
so that works fine, It actually gives me a nice condensed page to view on my phone .... LOL

I guess there is something wrong with my Influx/DBGrafana.

Let me try and debug and I will let you know how I make out....Thanks
Anonymous said…
I have an original pi as well I might try this on. I am currently logging with a pi zero. Did you go with Raspbian as the OS or something else?

Thanks
Anonymous said…
Hi,

very thanks for Epever dashbord, I have a tracer 2210A and I try to monitor. I did each step but I have a problem all data from the tracer are empty. ( I have a MT50, it works, I also connected the USB dongle and the Epever software it works )

The epever is connected to the USB dongle and RPI2
When i get : php example_cli.php it return :
Info Data
----------------------------------
00 Manufacturer: EP

Cannot get Rated Data
Cannot get RealTime Data
Cannot get Statistical Data
Cannot get Settings Data
Cannot get Coil Data

Discrete Data
----------------------------------
00 Over temperature inside device: 0
01 Day/Night: 0

and when I get sudo php logger.php


Realtime Data
Cannot get RealTime Data

Statistical Data
Cannot get Statistical Data

I don't know where is the problem

Thank for you help
Fred
sparkiie said…
Hey,

I have Scotts problem too.

I run the php and get:
PHP Warning: require(vendor/autoload.php): failed to open stream: No such file or directory in /home/pi/logger/logger.php on line 10
PHP Fatal error: require(): Failed opening required 'vendor/autoload.php'

If I commtent out this line I get the error: PHP Fatal Error: Uncaught Error: Class 'InfluxDB' not found in /home/user/epeverlogger/logger.php:16

I'm using Debian in an VMWare!
Anonymous said…
Works for more than 1? I have two.
Anonymous said…
Hi. Can I have a copy of your dashboard? :)

Popular posts from this blog

Installing episode butler and sabnzbd on the Seagate Dockstar.

Assembling the Power bank Keep-alive based on 555 Timer