This project was forlked from https://github.com/fatyogi/epever-upower-tracer and the driver from https://github.com/kasbert/epsolar-tracer plus some fixes I have added myself. My changes are only related to the Tracer side as I only have the Tracer charge controller.
Fixes:
Fixed data types to be fixed as floats as influxdb just takes the first data type it gets and defaults to that then when the script tried to send a float after an initial int or vice versa this resulted in an error retuened from influxdb. This was visable as a hole in the data in grafana but very hard to catch in practive without logging.
Changes:
Added a "BAcurr" value to the output as the original BAamps was misleading. This is not Battery Amps as it mght suggest but the total output current of the charge controller buck converter. Actual battery charge / discharge current is the BAamps value less the DCamps (load) value. Negative for discharging and positive for charging.
TO DO: Port to Python 3
EPSolar Tracer AN/BN devices have been around for a while so this is just another attempt to establish a good monitoring package.
EPSolar UPower hybrid inverters are great at what they do, however it is difficult to get them monitored if you have a Linux machine as they are still new and the protocol is not publicly available. Out of my communication with EPSolar I managed to obtain the list of registers and develop a UPower Python module.
- Python 2.7 (standard Python coming with Raspberry Pi) - NOTE: in the future versions of Raspbian - Python 3 will be used, however the code should work fine with this version too - just make sure you use pip3 instead of pip.
- Influx DB and its Python 2.7 modules
- Grafana - latest, whatever is availabe in your Raspbian
- To communicate with the devices you will need Minimal Modbus module for Python
The xr_usb_serial_common directory contains the makefile and instructions that will compile properly on Rasbian OS on a raspberry pi 3. Before compiling be sure to install the linux headers with
sudo apt-get install raspberrypi-kernel-headers
After installing the headers be sure to sudo bundle
then sudo make
.
The resulting xr_usb_serial_common.ko
file will need to be moved to /lib/modules/YOUR_LINUX_VERSION/extra/
.
After building and moving the module, remove the cdc-acm driver that automatically installs for the usb-485 adapter.
rmmod cdc-acm
modprobe -r usbserial
modprobe usbserial
You will also need to add the cdc-acm to the system blacklist:
echo blacklist cdc-acm > /etc/modprobe.d/blacklist-cdc-acm.conf
Note: If echo doesnt work you will need to add blacklist cdc-acm
manually to the blacklist with vim vi /etc/modprobe.d/blacklist-cdc-acm.conf
Finally add xr_usb_serial_common
to '/etc/modules' to autoload the module on startup.
After all of this is done make sure that the new driver loads correctly by reloading the linux dependency list depmod -ae
Then load the module with modprobe xr_usb_serial_common
If all goes well you should see ttyXRUSB
when listing ls /dev/tty*
Reboot and enjoy!
-
Protocol for Epsolar Tracer in this repository
-
Protocol for UPower charger/inverters in this repository
Install minimalmodbus first:
pip install minimalmodbus
SolarTracer.py
is the module to communicate with Tracer AN/BN controller
UPower.py
is for communication with UPower inverters
The file logtracer.py
will query the Tracer AN/BN controller for relevant data and store into Influx DB.
The file logupower.py
will query the UPower inverter for relevant data and store into Influx DB.
By default these scripts write the output into the console (as well as the database). Use > /dev/null to make them "silent".
-
First make
logupower.py
andlogtracer.py
executable:sudo chmod +x log*.py
-
Now add the cron job:
crontab -e
- add the line to log the values every minute (this is for the Tracer model):
* * * * * cd /home/pi/epever-upower-tracer && python logtracer.py > /dev/null
- you can add another line if you want it every half a minute:
* * * * * cd /home/pi/epever-upower-tracer && sleep 30 && python logtracer.py > /dev/null
Some very basic knowledge of InfluxDB and Grafana is assumed here.
The grafana/ folder contains the dashboard to monitor realtime and historical solar charging data.
Use this guide to install InfluxDB and Grafana on Raspberry Pi
Run http://raspberrypi.local:3000 (or whatever your name for the Raspberry Pi is) to configure the Grafana console
When you add InfluxDB as a Data Source. Influx DB should be set up with the following parameters:
- user = "grafana"
- pass = "solar"
- db = "solar"
- host = "127.0.0.1"
- port = 8086
At this point you can also import SolarDashboard from grafana/ folder.
Use "solar" dataset to import the values from when setting up the console.
setTracerVoltages.py
will rewrite Tracer AN/BN voltages to support LiFePO4 batteries.
Current settings are for 24V LiFePO4, however the script can be easily changed to set values for 12V and also other types of batteries. There is a pre-filled array for LiFePO4 and a Lead-Acid flooded battery in the script. See the comments on how to choose it.
See Battery voltage settings in this repository
ivctl.py
may be used to switch the inverter off/on for the night