Git Product home page Git Product logo

ai-republic / bms-to-inverter Goto Github PK

View Code? Open in Web Editor NEW
26.0 6.0 3.0 10.39 MB

Use, monitor and control any battery brand with any inverter! Application to read and monitor data from BMSes and write data to an inverter using any protocol (e.g. UART, RS485, ModBus or CAN)

Home Page: https://github.com/ai-republic/bms-to-inverter

License: Other

Java 83.93% HTML 15.08% CSS 0.33% Shell 0.64% Batchfile 0.01%
bms daly daly-bms deye inverter sma solar solar-system sunny-island victron

bms-to-inverter's Introduction

BMS to Solar Inverter communication

(Use, monitor and control any battery brand with any inverter)

This application is reading data from a BMS and sending it to an inverter. This way you have no restriction on what battery brands you can use with your inverter. Many inverter manufacturers only allow batteries from certain battery manufacturers and certain models. This project enables you to read your BMS's data via different protocols - RS485, RS232, UART, ModBus or CAN - and write the battery data to the inverter in a specification that the inverter supports - Pylontech, SMA, Growatt, Deye, SolArk, etc. You can monitor each of your battery packs cells and view alarm states on the included webserver or hook up via the MQTT broker on your smart home. Or you can just read out your BMS's data and use the optional MQTT broker or Webserver to monitor your batteries packs and cells wherever you are.

The (reference) project uses a Raspberry Pi 4B with a Waveshare RS485/CAN hat or Waveshare 2-Channel CAN FD HAT module but you can use any CAN or RS485 module for your PI that provides ports like can0 or /dev/ttyS0 or similar. It will also work on older/newer PI's such as 3 or 5. The appplication supports multiple BMS (even mixes from different manufacturers), aggregating them and sending the data to the configurable inverter.

This way you control what gets send to the inverter.

A wide range of BMS and inverters already supported (see below). Any BMS or inverter can be supported in a very short time by just mapping the manufacturers protocol specification in an own implementation of the BMS or Inverter.

NOTE: If you would like me to add a BMS or inverter module just let me know! I would appreciate support to test the BMS and inverter bindings in all variations. Please let me know if you would like to support this project - Testers are very welcome! :)


Supported protocols:

  • RS485 / UART / RS232
  • ModBus
  • CAN

Currently implemented BMS:

  • BYD BMS (CAN)
  • Daly BMS (CAN / RS485 (& UART / RS232))
  • Growatt high voltage (CAN)
  • JK BMS (CAN / RS485 (& UART / RS232))
  • PylonTech low voltage BMS (CAN / RS485)
  • PylonTech high voltage BMS (CAN)
  • Seplos BMS (CAN)
  • SMA BMS (CAN)

Currently implemented inverters:

  • SMA Sunny Island (CAN)
  • Growatt low voltage (12V/24V/48V) inverters (CAN)
  • Growatt high voltage inverters (CAN)
  • PylonTech low voltage inverters (CAN)
  • PylonTech high voltage inverters (CAN)
  • Deye inverters (CAN)
  • SolArk inverters (CAN)
  • any other inverters using the PylonTech (CAN) protocols

NOTE: If your BMS or inverter is not in the list just open an issue!


Supported architectures

The following architectures are supported:

  • x86_32
  • x86_64
  • armv6
  • armv7
  • armv7a
  • armv7l
  • aarch64
  • riscv32
  • riscv64

NOTE: There are restrictions using CAN on Windows as SocketCAN library is NOT available on Windows OS


How to use

See the Wiki page How to use for details on how to install and configure your system using the Configurator.


Notes

If you have questions or need support feel free to contact me or raise an issue or discussion. If you like to support me testing the application on all different BMSes and inverters please contact me!

--> Finally, if you like this project and like to support my work please consider sponsoring this project Sponsor button on the right :)

bms-to-inverter's People

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  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

bms-to-inverter's Issues

Webserver module

I noticed a bug that after sometime 24 hours the webserver is working but do not refresh values like SoC and other correctly. Actually they stay as they were previous day. App seems to work no crash. I stop and start it and everything is displayed normal updated. If you need more info you can email me for live access.

Latest code not working

Trying the latest version throws the following error:

e.remoting.impl.netty.NettyServerConnection@4cfeae[ID=b311cd28, local= /127.0.0.1:61616, remote=/127.0.0.1:40888]], true, true, false, false, null, org.apache.activemq.artemis.core.protocol.core.impl.CoreSessionCallback@59f6d4, true, {}]
Exception in thread "main" jakarta.enterprise.inject.CreationException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128)
at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:347)
at java.base/java.lang.Class.newInstance(Class.java:645)
at org.jboss.weld.security.NewInstanceAction.run(NewInstanceAction.java:33)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
at org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:40)
at org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:50)
at org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:90)
at org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:127)
at org.jboss.weld.injection.ConstructorInjectionPoint.invokeAroundConstructCallbacks(ConstructorInjectionPoint.java:92)
at org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:78)
at org.jboss.weld.injection.producer.AbstractInstantiator.newInstance(AbstractInstantiator.java:28)
at org.jboss.weld.injection.producer.BasicInjectionTarget.produce(BasicInjectionTarget.java:112)
at org.jboss.weld.injection.producer.BeanInjectionTarget.produce(BeanInjectionTarget.java:186)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:160)
at org.jboss.weld.contexts.AbstractContext.get(AbstractContext.java:96)
at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
at org.jboss.weld.bean.ContextualInstanceStrategy$ApplicationScopedContextualInstanceStrategy.get(ContextualInstanceStrategy.java:140)
at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:684)
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:666)
at org.jboss.weld.injection.producer.AbstractMemberProducer.getReceiver(AbstractMemberProducer.java:123)
at org.jboss.weld.injection.producer.AbstractMemberProducer.produce(AbstractMemberProducer.java:158)
at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:180)
at org.jboss.weld.contexts.unbound.DependentContextImpl.get(DependentContextImpl.java:64)
at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:684)
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:666)
at org.jboss.weld.manager.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:784)
at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:92)
at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:345)
at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:356)
at org.jboss.weld.injection.producer.ResourceInjector$1.proceed(ResourceInjector.java:69)
at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48)
at org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:71)
at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:117)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:161)
at org.jboss.weld.contexts.AbstractContext.get(AbstractContext.java:96)
at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
at org.jboss.weld.bean.ContextualInstanceStrategy$ApplicationScopedContextualInstanceStrategy.get(ContextualInstanceStrategy.java:140)
at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:102)
at org.jboss.weld.bean.proxy.ProxyMethodHandler.getInstance(ProxyMethodHandler.java:131)
at com.airepublic.bmstoinverter.BmsToInverter$Proxy$_$$_WeldClientProxy.start(Unknown Source)
at com.airepublic.bmstoinverter.BmsToInverter.main(BmsToInverter.java:73)
Caused by: java.util.ServiceConfigurationError: com.airepublic.bmstoinverter.core.InverterDescriptor: Provider com.airepublic.bmstoinverter.inverter.pylonhv.can.PylonHVInverterCANProcessor not found
at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:593)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass(ServiceLoader.java:1219)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1228)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1273)
at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1309)
at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1393)
at java.base/java.lang.Iterable.forEach(Iterable.java:74)
at com.airepublic.bmstoinverter.core.InverterProducer.(InverterProducer.java:27)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:119)
... 37 more

and sits there ...

Outback Power Skybox Inverter BMS Canbus

outback has a limited list of batteries it supports. It has support for Simpliphi, Blue Ion, Discover, Fortress, Active BMS, Energycell PLR and XLC, Kilovault.

Skybox runs on an industrial beagleboard and has an RJ12 connector to connect to the BMS RJ45 Can port.

JK BMS RS485 doesn't work

2024-03-14 18:46:34.633 | INFO | Thread-2 | verter.BmsToInverter:164 | Reading BMS #1 JK_RS485 on /dev/ttyAMA0...
2024-03-14 18:46:34.645 | INFO | Thread-2 | stoinverter.core.BMS:120 | ---------------------------------> Thread 44
2024-03-14 18:46:34.647 | ERROR | Thread-2 | stoinverter.core.BMS:139 | Error requesting data!
java.lang.UnsupportedOperationException: null
at java.nio.ByteBuffer.array(ByteBuffer.java:1471) ~[?:?]
at com.airepublic.bmstoinverter.protocol.rs485.JSerialCommPort.sendFrame(JSerialCommPort.java:115) ~[protocol-rs485-0.0.1-SNAPSHOT.jar:?]
at com.airepublic.bmstoinverter.bms.jk.rs485.JKBmsRS485Processor.collectData(JKBmsRS485Processor.java:27) ~[bms-jk-rs485-0.0.1-SNAPSHOT.jar:?]
at com.airepublic.bmstoinverter.core.BMS.process(BMS.java:127) ~[core-api-0.0.1-SNAPSHOT.jar:?]
at com.airepublic.bmstoinverter.BmsToInverter.lambda$start$2(BmsToInverter.java:165) ~[bms-to-inverter-main-0.0.1-SNAPSHOT.jar:?]
at java.lang.Thread.run(Thread.java:840) [?:?]

Daly BMS - ttl

Hello,
Currently you are supporting Daly BMS (RS485 or CAN).
I have bad luck with my daly bms and i am missing the hardware parts in my Daly for CAN/RS485.
I have only TTL usb.

daly-ttl-usb

Maybe i should use USB to RS-485 but how i am gonna connect it to my PI ? Now i can connect directly via USB
and read data like cells , soc and all of this.

Raspberry Pi 5 compatibility

Not really important to fix since Pi 4's are still easily obtainable.
It might be worthwhile putting a warning that the Pi 5 and Waveshare RS485/CAN adapter may (probably) not work and still a work in progress.

Just in case anyone (like me :) ) think to get a Pi 5 because it's the newest.

configuration issues

After latest commits seems like webserver and email is broken. Also there are many errors in cleanrepo.sh

Building on PI4

Hello,
I am trying to build this on a PI4 device.
Here is the error i got:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project core-api: Fatal error compiling: error: release version 17 not supported -> [Help 1]

Maybe my mvn is too new ?

root@sol:~/bms-to-inverter # mvn -v
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 11.0.18, vendor: Raspbian, runtime: /usr/lib/jvm/java-11-openjdk-armhf
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "6.1.31-v8+", arch: "arm", family: "unix"

Hardware connection to the Growatt Inverter

Hello,
I have little technical question about connecting Growatt to PI.
I have 3 ways to connect it. One is via RS-485 to USB but as i see you started only CAN. Next way is connecting via CAN from the inverter to USB port in the PI device. Growatt has one USB port too which i have already once connected to my PI for reading inverter data. Now i am wondering how exactly to connect it to the inverter. I have received CAN to USB modules so i can use that too. Also i think growatt has some kind of password which is growatt+current_date. Can you give a little help how exactly you are expecting the data from the inverter via CAN ?

mqtt with authentication?

Hello,

is there any way to use mqtt with authentication?

I was trying tcp://login:password@server_ip:1883 but no luck
mosquitto reports in logs:
Client disconnected due to protocol error.

cheers

Not working normally

Hi, after today update the software is not working properly.
It does not crash it just stops.
For example these are the last lines:

BMS SOC V A CellMinV CellMaxV CellDiff
1 25.6 53.2 8.0 3.328(#2) 3.333(#15) 0.005

2024-02-12 13:45:48.367 | INFO | $6@96aa05) | ogs.AuditLogger_impl:2299 | AMQ601501: User [email protected]:48790 is consuming a message from energystorage: Reference[158]:RELIABLE:CoreMessage[messageID=158,durable=true,userID=null,priority=4, timestamp=Mon Feb 12 13:45:48 EET 2024,expiration=0, durable=true, address=energystorage,size=11224,properties=TypedProperties[]]@31771282
2024-02-12 13:45:48.372 | INFO | $6@96aa05) | ogs.AuditLogger_impl:2291 | AMQ601500: User [email protected]:39724 sent a message CoreMessage[messageID=158,durable=true,userID=null,priority=4, timestamp=Mon Feb 12 13:45:48 EET 2024,expiration=0, durable=true, address=energystorage,size=11224,properties=TypedProperties[]]@31771282, context: RoutingContextImpl(Address=energystorage, routingType=null, PreviousAddress=energystorage previousRoute:null, reusable=true, version=-2147483646)
..................................................
***** durable queues energystorage:

  • queueID=4 address:energystorage name:energystorage filter:null
    ***** non durable for energystorage:
    ..................................................
    , transaction: null
    2024-02-12 13:45:48.377 | INFO | 2-thread-1 | verter.BmsToInverter:225 | BMS alarms:
    NONE
    2024-02-12 13:45:53.378 | INFO | 2-thread-1 | stoinverter.core.BMS:128 | ---------------------------------> Thread 43
    2024-02-12 13:45:53.585 | WARN | 2-thread-1 | alyBmsRS485Processor:127 | Command 0x90 to BMS 1 successfully sent and received!
    2024-02-12 13:45:53.793 | WARN | 2-thread-1 | alyBmsRS485Processor:127 | Command 0x91 to BMS 1 successfully sent and received!
    2024-02-12 13:45:54.000 | WARN | 2-thread-1 | alyBmsRS485Processor:127 | Command 0x92 to BMS 1 successfully sent and received!
    2024-02-12 13:45:54.208 | WARN | 2-thread-1 | alyBmsRS485Processor:127 | Command 0x93 to BMS 1 successfully sent and received!
    2024-02-12 13:45:54.416 | WARN | 2-thread-1 | alyBmsRS485Processor:127 | Command 0x94 to BMS 1 successfully sent and received!

Not updating. If i stop the webserver it prints info so it is not crashed

waveshare CAN expansion hat compatibility

Does it also work with the Waveshare 2-Channel Isolated Can Expansion Hat or does it only work with the flexible data rate (FD) version ?

Nice project by the way.

Running on Windows

Hi,

I am trying to run the solution on Windows 10. I managed to build the project but running bms-to-inverter throws below error:
Exception in thread "main" org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Inverter with qualifiers @default
at injection point [BackedAnnotatedField] @Inject private com.airepublic.bmstoinverter.BmsToInverter.inverter
at com.airepublic.bmstoinverter.BmsToInverter.inverter(BmsToInverter.java:0)

    at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:367)
    at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:285)
    at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:141)
    at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:162)
    at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:515)
    at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:64)
    at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:62)
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:62)
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:55)
    at org.jboss.weld.executor.CommonForkJoinPoolExecutorServices.lambda$wrap$0(CommonForkJoinPoolExecutorServices.java:70)
    at java.base/java.util.concurrent.ForkJoinTask$AdaptedInterruptibleCallable.exec(ForkJoinTask.java:1461)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

Unfortunately I am not a Java expert. Spent 2h googling for solution but could not make it work. Help would be appreciated.

Daly Growatt implementation imminent

Hiya

16 Lishen 272ah @ 1C
Daly 48v 150A
Growatt SPF 5000ES
Solar only, generator backup

No comms to BMS

RS485 (Daly) to RJ45 (growatt) fail. Crimped then inverted pins then removed 2 then inverted again. Could not set BMS to any specific (Pylon) protocol. Speedy email response from Daly support asked where I bought it but hasn't replied to me since I told them it was a small south African online shop that has since closed down, with a very bad reputation.

Daly interface board option but I think I still need to set the battery type on BMS so I don't want to buy it.

RS485 (Daly) to USB windows success
Daly software could also not change battery protocol. But I had full live Conn to BMS, all voltages etc working fine. 3 wire from RS485 to USB. So the BMS is speaking fine. Just need to relay the message.

Tomorrow I'm going to get my first ever Pi. Pi 3 and with your suggested IO. Then I'll follow your guide as best that I can. I'm excited.

I need this. My growatt isn't very good at charging blindly. ๐Ÿ˜…

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.