Apologies for the rather basic post, but I wasn’t able to find the more general info in a search.
So I’m looking to build a semi-industrial setup with multiple BMS of different brands, a variety of sensors and actuators from different brands (motors, encoders, accelerometers, etc), multiple controllers, an MPPT, etc. I’ll have a primary controller doing most of the heavy lifting but, while looking at Victron hardware for MPPT and BMS interfaces, I was told that the CerboGX can implement custom logic and have custom communications if implemented through Venus OS and Node-RED. Therefore, I’m curious if I can offload some of the more generic control strategies onto the Victron hardware. However, I’m having a little difficulty wrapping my head around how complex this task might be.
So far as I could tell, a typical arrangement might be: put Venus OS on a CerboGX if all your devices have Victron interfaces OR put Venus OS on a RasPi if you need a more custom gateway; for non-standard I/O, either create a custom Node-RED node and then run code on the Pi to generate the node input data OR interact with the I/O via an embedded controller like an Arduino and pipe communications to and from the Node-RED flow using some standard node (I couldn’t figure out what this might be); and use Node-RED to implement what logic you’re after.
Does this sound right? Are there examples of folks implementing non-typical industrial or vehicle (marine / automotive / etc) sensors and actuators this way?
Thanks for helping get me up to speed, and apologies if this thread is redundant.
Hi. I’ve not done anything with Cerbo GX but have been impressed by how easy it is to implement some quite complex logic in NodeRed on Raspberry Pi. I’ve got relays controlling chargers and an immersion heater based on solar power input and battery voltage. Next step is to use a temperature sensor on an Arduino to provide a feedback loop on the heater circuit. I control my power relays via the internal relay in the SmartSolar MPPT which doesn’t have sufficient current rating for 1kW loads but at some point I may have to use a relay board on the RPi for more channels. Hope this helps. Interested to know more about your system.
I think what I’m looking for is to reduce the total number of processors / controllers overall, so I’m hoping to use whatever comms the Cerbo (or similar unit) has to communicate to another device that’s handling other tasks in parallel.
Has anyone here seen or built gateways to go between Victron’s protocols and a more standard industrial communication protocol like Modbus / EtherCAT / MQTT / OPCUA / CANopen / etc?
In general, Node-RED is a very suitable tool for that, especially when part of Venus OS since you have al Victron protocols then ready and available in it.
Just as a confirmation about the lower layers: both MQTT and OPCUA can run on the Eth port, and the user doesn’t need to worry about intermediate layers like Transport/Network/Data, correct?
I have installed a Raspberry Pi 3B running VenusOS with a USB dongle connection to my MPPT charge controller. In the Settings interface I have enabled the MODBUS interface. I run a number of python scripts on my Macbook to do many things. Throughout my install I have incorporated the TP-Link TAPO smartplugs so that I can systematically turn on/off things.
Here’s an example of a script which can monitor the PV voltage every five minutes. It’s called MonitorPVWattage.py.
#!/usr/bin/env python3
from threading import Event
import signal, os, subprocess
from datetime import datetime
exit = Event()
def main():
while not exit.is_set():
x = subprocess.check_output(['./GetPVWattage.py'])
now = datetime.now()
print(now.strftime("%H:%M:%S"), ' PV Wattages:',
x.decode("utf-8"), end='')
os.system('say -v Alex ' + x.decode("utf-8")) # If you don't have MacOS then comment this line out
exit.wait(300) # Check once every five minutes
def quit(signo, _frame):
print("\n\n")
exit.set()
if __name__ == '__main__':
signal.signal(signal.SIGTERM, quit)
signal.signal(signal.SIGINT, quit)
signal.signal(signal.SIGHUP, quit)
main()
And here’s the script it calls to get the value from the MODBUS interface. This one is called GetPVWattage.py. You have to do a `pip install pymodbus` into your Python application space.
#!/usr/local/bin/python
# GetPVWattage is a command line utility to query the current PV wattage on a VenusOS system.
# Requirements: python 2.7 and the pymodbus module (https://github.com/bashwork/pymodbus).
from pymodbus.client.sync import ModbusTcpClient
from pymodbus.constants import Defaults
from pymodbus.exceptions import ModbusIOException, ParameterException
try:
Defaults.Timeout = 3
client = ModbusTcpClient(host='venus.local', port=502) # Adjust hostname as necessary for your Raspberry Pi computer
result = client.read_holding_registers(address=776, count=1, unit=239) # The unit number here is for my charge controller
voltage = float(result.registers[0]) / 100.0 # The Settings screen for MODBUS will tell you
result = client.read_holding_registers(address=777, count=1, unit=239) # what yours is.
current = float(result.registers[0]) / 10.0
print('{} watts'.format(int(round(voltage * current, 0))))
except Exception as e:
print('Error connecting: {}'.format(str(e)))
Here’s an example script that I can use programmatically to turn off the smartplug that’s connected to my crockpot. You’d need to `pip install …` the KASA library seen below to control the TAPO devices.
#!/usr/bin/env python3
import asyncio
from kasa import SmartPlug
from pprint import pformat as pf
async def main():
# HS100 larger type
tplink = "192.168.11.117" # Obviously, you'd need to adjust this IP address
plug = SmartPlug(tplink)
# plug.timeout = 20
await plug.update()
# print("Hardware: %s" % pf(plug.hw_info))
# print("Full sysinfo: %s" % pf(plug.sys_info))
if (plug.is_on):
await plug.turn_off()
else:
print("Plug was already OFF")
if __name__ == "__main__":
asyncio.run(main())