Online monitor for Victron BMV-600S and BMV-602S: Installation and code
In this post I'm going to explain how to install my online monitor for Victron BMV-600S and BMV-602S battery monitor. To use it you need to connect your BMV to a computer, read this post to know how to do: “Connect Victron BMV battery monitor to a computer”.
Requeriments:
- Computer running Linux, Mac or Windows.
- Python 2.7(Python 3.X not working)
- PySerial installed.
- Web server with PHP and MySQL.
The software consist in two parts, a Python script that receive data from serial port and a web PHP app that show data and record it in a MySQL database.
- Download the software from github: http://github.com/jepefe/bmvmonitor
- Extract files from zip.
- Copy “Serial scripts” folder to the computer connected to the BMV
- Run bmv_mon.py script in this way to be sure you are receiving data from the BMV:
-
python bmv_mon.py -p /dev/ttyUSB0 -j #(replace “ttyUSB0” to correct device or “COMX” for Windows)
- If all is going well you will get something similar to this:
{"FW": "211", "ALARM": "OFF", "SOC": 78.0, "H10": 41, "BMV": "600S", "TTG": 5103, "I": -3.314, "H11": 29, "H12": 0, "CE": -116.175, "AR": "0", "V": 24.095, "H8": 29801, "H9": 2.18881944367398, "RELAY": "OFF", "H2": -116.175, "H3": 0.0, "H1": -259.107, "H6": -8832.716, "H7": 18.677, "H4": 1, "H5": 0.0}
- Copy the “Web server” content to the desired folder in your web server, we will use bmvmon/ for this tutorial.
- Import database.sql to your MySQL server.
- Edit bmvcfg.php to match your configuration, don't forget to set timezone for accurate records.
- Go back to the PC connected to the BMV and run bmv_monitor.py in this way:
python bmv_mon.py -p /dev/ttyUSB0 -j -c -i3 -u http://YOURSERVER/bmvmon/regstatus.php -tYOURTOKEN #Replace “-i3” with the read interval(in seconds) and the token you have set in bmvcfg.php
Now you can go to your browser, access to monitorbmv.html and check that data is being displayed.