GithubHelp home page GithubHelp logo

optio50 / victron_modbus_tcp Goto Github PK

View Code? Open in Web Editor NEW
24.0 2.0 6.0 4.55 MB

Victron Modbus & MQTT Example

Python 100.00%
victron modbus tcpmodbus python cerbo victronenergy solar inverter multiplus battery

victron_modbus_tcp's Introduction

Victron_Modbus_TCP

Victron Modbus TCP & MQTT Example

Confirmed working with pymodbus 3.6.3

These file's are based on a system that has victron equipment in an "ESS" system. Multiplus, Solar charger, BMV

Regarding the GX MQTT keepalive.
run the keep-alive on the cerbo (or Pi) its self.

The file's are provided above, named Keep-Alive.py and Forever.py
The Keep-Alive.py is run via a kind of pseudo monitoring script (forever.py).
Place both files in the cerbo /data directory and make sure they are set executable. edit the /data/rc.local file (nano rc.local) and make an entry that looks like this

#!/bin/bash   
sleep 30   
/data/forever.py /data/keep-alive.py &

ctrl+o to write the file to disk and ctrl+x to exit
reboot the cerbo and the keep-alive should do its job.
the sleep command is to ensure the cerbo has had time to accomplish a full startup routine.

If you want to run the keep-alive in the script instead of the standalone keep-alive you will need the MQTT request in the update_value function with a counter or timer.

An example of the Victron TCP Modbus.
If you intend to use this example for yourself it will require tweaking a few things.

For starters you should download the victron xlsx register file from https://github.com/victronenergy/dbus_modbustcp/blob/master/CCGX-Modbus-TCP-register-list.xlsx
Check the tabs for the relevant information. Especially tab #2 Unit ID Mapping

Change the GX device IP address. Port is standard 502

Check Instance #'s from Cerbo GX and cross referenced to the unit ID in the Victron TCP-MODbus register xls file.

Change the the instance #'s to their correct values

You likely dont have the 3 temperature sensors included. Change the variable to turn them on and off.

alt text

alt text

PyQT5-Multiple-Chargers.py
PyQT5-Multiple-Chargers.ui
alt text
alt text

TK-VictronSolar.py
alt text

PyQT5-No-Multiplus-Single-Charger-JBD-BMS.py
This file is for a Raspi and a single Victron SmartSolar Charger. Also includes a Serial UART BMS (JBD in my case).
I have no idea if this works with the other compatiable BMS's. I only have a JBD.
Venus OS Serial BMS info
https://github.com/Louisvdw/dbus-serialbattery
USB Serial interface https://overkillsolar.com/product/usb-module-for-bms/
The connector included did not fit my BMS, YMMV. I cut the BMS BlueTooth cable in half and soldered the UART wire's to the connector wire's
alt text

To install
git clone https://github.com/optio50/Victron_Modbus_TCP
cd Victron_Modbus_TCP
chmod +x MODBUS_Example.py
chmod +x MQTT_Example.py
pip3 install paho-mqtt
pip install pymodbus
Change the VRMid and ip address, turn the analog sensors on or off in the script.
./MODBUS_Example.py
or
./MQTT_Example.py

To use the PyQt files you will need to.

pip install paho-mqtt
pip install pglive
install PyQT5 with your package manager.
such as sudo apt install python3-pyqt5
and sudo apt install python3-pyqt5.qtwebengine

The PyQT5-Multiple-Chargers.py and PyQT5-Multiple-Chargers.ui are PYQT5 files that are used together.
Same with PyQT5-Single-Charger.py and PyQT5-Single-Charger.ui
Just run the .py file and the .ui file will auto load.
execute in the cloned directory as the icon file is in that location.
Your system theme / font will dictate the style and appearence of the Pyqt program.

You must have the correct Victron equipment. such as Multiplus with ESS, BMV, Solar charger, Venus GX device.

victron_modbus_tcp's People

Contributors

optio50 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

victron_modbus_tcp's Issues

No issue - have a enhance request for Example.py

Hi,

I'm very happy to foundthis script.
My plan are use the MultiPlus at external mode and give's him the GridSetPoint depends from the SoC.
so I reduce the script and try this

   # Battery value color
    if BatterySOC >= 95:
        print(clear,colors.fg.cyan,f" Battery SOC............. ",colors.bold, colors.fg.green,f"{BatterySOC:.1f}", " %", colors.reset, sep="")
    elif BatterySOC <= 95 and BatterySOC >= 12:
        print(clear,colors.fg.cyan,f" Battery SOC............. ",colors.bold, colors.fg.yellow,f"{BatterySOC:.1f}", " %", colors.reset, sep="")
    elif BatterySOC < 25:
        print(clear,colors.fg.cyan,f" Battery SOC............. ",colors.bold, colors.fg.red,f"{BatterySOC:.1f}", " %", colors.reset, sep="")
        **client.write_registers(address=2700, values="0" , unit=VEsystemID**
        continue
        #print("\033[K", end="")
        print(clear,colors.fg.green,f" Grid Set Point Watts.... {GridSetPoint}", sep="")

but thsi won't work.

my wish is that I feed-in start if the SoC are >94% until the SoC >11% with GridSetPoint 170 Watt.
otherwise the GridSetPoint are "0"

thx for some hints
regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.