diy solar

diy solar

Active balancer, make it smart!?

In my setup the ESP queries the BMS for all its running statistics every few seconds, and then uploads the data to InfluxDB. It also operates the balancer relay if the necessary cell voltage conditions are met.
While this was coded to work online/while connected to WiFi, it'd be trivial to modify the code to remove this function such that in runs in an offline mode. If this is all you needed you could get away using a cheaper and simpler microcontroller without the WiFi capability.


I built a very simple serial multiplexer using a separate STM32. It allowed both the bluetooth adapter and ESP to communicate with the BMS at the same time, with the bluetooth interface taking precedence if it is connected.

If I get a bit of time this weekend I'll upload my code and notes.
I checked out your work on GitHub and it truely looks amazing, especially your all in one board!

I don't have wifi (living in rather remote and simple lodgings) so yes an offline mode is all i would need.
Simpler and cheaper is generally always preferable but wouldn't that be less trivial (cause more work) for you!?
Do you by chance have an esp01 and its relay board? This looked to me always like the ideal combo to control the balancer.
IMG_20230303_222935.jpg
 
I checked out your work on GitHub and it truely looks amazing, especially your all in one board!

I don't have wifi (living in rather remote and simple lodgings) so yes an offline mode is all i would need.
Simpler and cheaper is generally always preferable but wouldn't that be less trivial (cause more work) for you!?
Do you by chance have an esp01 and its relay board? This looked to me always like the ideal combo to control the balancer.
View attachment 137721

I bought a couple similar to this a few weeks ago, however didn't end up using them. There's a few variants of these ESP01 relay boards, it's important to use the type that exposes the UART interface (TX, RX, GND) so you can connect it to the BMS.

1677869365270.png

I personally dislike working with the ESP01. Their excessively minimalistic design makes programming them a real pain, and they can be a bit unstable due to a lack of sufficient power decoupling capacitors.
That being said, it wouldn't take much effort to strip down my code to have one of these work in an offline, single purpose mode. If there's enough interest I could release another version for this purpose.
 
I bought a couple similar to this a few weeks ago, however didn't end up using them. There's a few variants of these ESP01 relay boards, it's important to use the type that exposes the UART interface (TX, RX, GND) so you can connect it to the BMS.

View attachment 137740

I personally dislike working with the ESP01. Their excessively minimalistic design makes programming them a real pain, and they can be a bit unstable due to a lack of sufficient power decoupling capacitors.
That being said, it wouldn't take much effort to strip down my code to have one of these work in an offline, single purpose mode. If there's enough interest I could release another version for this purpose.
Didn't know that, well it shows smaller and simpler is not always better! ;) Then better forget the esp01.

Forgive me my ignorance, suppose you would remove the esp from your all-in-one board, would the stm32 multiplexer board alone be able to do all it did before (allowing Bluetooth module to access to the uart) + control a relay in the way you described before (starting the balancer at 3.4v etc)?
Or what would be the easiest and most prefered way for an possible offline version be?
 
Last edited:
Didn't know that, well it shows smaller and simpler is not always better! ;) Then better forget the esp01.

Forgive me my ignorance, suppose you would remove the esp from your all-in-one board, would the stm32 multiplexer board alone be able to do all it did before (allowing Bluetooth module to access to the uart) + control a relay in the way you described before (starting the balancer at 3.4v etc)?
Or what would be the easiest and most prefered way for an possible offline version be?
The STM32 would be well suited to the job by itself if you have no need for interaction with other systems. They're cheap, powerful and most importantly, 3.3v logic level to match the BMS.
 
The STM32 would be well suited to the job by itself if you have no need for interaction with other systems. They're cheap, powerful and most importantly, 3.3v logic level to match the BMS.
That sounds really great! Please if you find the time and muse to retrifit your code for an pure offline version, i would highly appreciate it!

If i am interested i guess there are also other noobs like me who would appreciate your professional guidance and help.
Maybe it would be a useful resource to open a dedicated thread (or here of course since it fits) where you could share and teach how you did (hardware and software) the online and offline solution.
 
Last edited:
That sounds really great! Please if you find the time and muse to retrifit your code for an pure offline version, i would highly appreciate it!

Because you asked so nicely, I've started porting the code over to the STM32.
It'll take a bit of time as it's quite different to the ESP, and several of the components and functions need to be modified. I'll also need to set up a test battery with my JBD BMS as it's no longer in use for my main solar system. My spare time is limited so it'll take a while to get it all up and running again.

The initial bill of materials (to be finalised):
  • STM32F103 "blue pill" board (or clone)
  • ST-Link v2 programmer (only if you don't have one already)
  • ADUM1201 dual channel digital isolator
  • 2 x linear voltage regulator modules, 1 x 3.3v, 1 x 5v.
  • Optoisolated relay module
  • ILI9341 SPI TFT screen (optional, but very useful - must be the 3.3v version)
 
Last edited:
Because you asked so nicely, I've started porting the code over to the STM32.
It'll take a bit of time as it's quite different to the ESP, and several of the components and functions need to be modified. I'll also need to set up a test battery with my JBD BMS as it's no longer in use for my main solar system. My spare time is limited so it'll take a while to get it all up and running again.

The initial bill of materials (to be finalised):
  • STM32F103 "blue pill" board (or clone)
  • ST-Link v2 programmer (only if you don't have one already)
  • ADUM1201 dual channel digital isolator
  • AMS1117 voltage regulator module
  • Optoisolated relay module
  • ILI9341 SPI TFT screen (optional, but very useful)
That is super kind of you!
I will get the hardware you mentioned immediately. Nevertheless, it will take 10 days to arrive by slow boat.

- I noticed there are two different f103 boards, one that ends with c8t6 and the other one c6t6. Which one should i order?
- Yes Stlink i already have.
- Asm1117, from which voltage to which? 12v to 3.3v?
- ADUM1201 ok clear
- Couldn't find the relay with your search words.. do you know its precise name or do you have a picture?
- the tft display info looks indeed enticing, would make accessing the app almost obsolete.
Speaking of which they have a new accessory released, similar to your tft but less info
https://a.aliexpress.com/_mPV71dG
 
Last edited:
- I noticed there are two different f103 boards, one that ends with c8t6 and the other one c6t6. Which one should i order?
- Asm1117, from which voltage to which? 12v to 3.3v?
- ADUM1201 ok clear
- Couldn't find the relay with your search words.. do you know its precise name or do you have a picture?
- the tft display info looks indeed enticing, would make accessing the app almost obsolete.
Speaking of which they have a new accessory released, similar to your tft but less info
https://a.aliexpress.com/_mPV71dG

  • The the C8T6 and C6T6 are very similar and often interchangeable, however the STM32F103C8T6 is preferable. This is the one I will be developing and testing on. Note that most of the "STM32" boards shipping from China actually have a CS32F103 chip. These are a clone of the STM32, they work well, they just need a special command line switch to program them.
  • The AMS1117 should be the 3.3v type. It will convert the voltage output from the BMS on the bluetooth port (which is around 14v) to power one side of the ADUM1201.
  • I've attached a picture of the relays I prefer. They have an optocoupler which helps avoid any problems or interference from the inductive flyback when the relay opens. Cheaper relay modules without the optocoupler would also work, they just have a diode/transistor combination and therefore less isolation.
    1678052397614.png
 
Last edited:
  • The the C8T6 and C6T6 are very similar and often interchangeable, however the STM32F103C8T6 is preferable. This is the one I will be developing and testing on. Note that most of the "STM32" boards shipping from China actually have a CS32F103 chip. These are a clone of the STM32, they work well, they just need a special command line switch to program them.
  • The AMS1117 should be the 3.3v type. It will convert the voltage output from the BMS on the bluetooth port (which is around 14v) to power one side of the ADUM1201.
  • I've attached a picture of the relays I prefer. They have an optocoupler which helps avoid any problems or interference from the inductive flyback when the relay opens. Cheaper relay modules without the optocoupler would also work, they just have a diode for the flyback and therefore less isolation.
Many thanks! That cleared things up.

  • Will order the STM32F103C8T6 and see what i get. They clearly list both (CS32F103 as well) so i hope they also send the stm32 if selected so (bit more expensive).
  • IMG_20230306_121538.jpg
  • AMS1117 4.5v-12v to 3.3v
  • IMG_20230306_091457.jpg
  • Optocoupler relay module, 5V
  • IMG_20230306_092906.jpg
  • Optional 240*320 TFT screen with SPI interface ili9488
  • IMG_20230306_093421.jpg
  • Adum1201
  • IMG_20230306_093846.jpg
 
Last edited:
  • Will order the STM32F103C8T6 and see what i get. They clearly list both (CS32F103 as well) so i hope they also send the stm32 if selected so (bit more expensive). It looks a bit different though... Is this a new version or should i get the one with the yellow jumpers?
  • Optional 1.8" spi tft lcd without touch ili9488
I'm using the older style board with the micro-USB interface and the yellow jumpers, but I think either would work fine.

If you're buying a TFT, make sure you get the ILI9341 240*320 TFT screen with SPI interface (unless you want to alter the code to suit a different type, but that won't be easy).
 
Last edited:
I'm using the older style board with the micro-USB interface and the yellow jumpers, but I think either would work fine.

If you're buying a TFT, make sure you get the ILI9341 240*320 TFT screen with SPI interface (unless you want to alter the code to suit a different type, but that won't be easy).
Ok thanks for the clarification!

Will then better order the older style board.

That wouldn't be just "not easy" but actually impossible for me right now. I only learned how to install, upload, set and change parameters etc in Arduino.
Since i already have a coulombmeter display which shows me some of the important parameters, i will skip the tft option for now.
 
I have a 16s 48v golf cart pack that I currently has a rocker switch soldered to the run wires on my heltec style active balancer... if I am understanding this correctly I can just wire this voltage controlled switch up to have the balancer kick on when the pack reaches say 54v right?
 
Quick update: I have the STM32 code version running, it's communicating with the BMS reliably and reporting on all the expected metrics. I've made some improvements to the code at the same time to better handle different battery sizes.
My BMS is currently running from a 5S1P test battery, which it isn't detecting properly so I haven't been able to test all features properly yet. Once I get this sorted out I'll post the code and start documenting how it all goes together.

@Vi s , what model of BMS are you using? I'm testing against a JBD AP21S001, I'm not sure if there's much protocol variation between different models.
 
Quick update: I have the STM32 code version running, it's communicating with the BMS reliably and reporting on all the expected metrics. I've made some improvements to the code at the same time to better handle different battery sizes.
My BMS is currently running from a 5S1P test battery, which it isn't detecting properly so I haven't been able to test all features properly yet. Once I get this sorted out I'll post the code and start documenting how it all goes together.

@Vi s , what model of BMS are you using? I'm testing against a JBD AP21S001, I'm not sure if there's much protocol variation between different models.
Gosh already?... It will take 10days or so till the parts arrive from china.

I use following two:
JBD-SP04S010 V1.1 4s 30A Uart+Rs485 and
JBD-SP04S020 V1.1 4s 60A Uart
Both manage Lifepo4s.
As well i use these 5A flying capacitor active balancers.
Well we will probably know once i got the hardware part ready.
 
  • I've attached a picture of the relays I prefer. They have an optocoupler which helps avoid any problems or interference from the inductive flyback when the relay opens. Cheaper relay modules without the optocoupler would also work, they just have a diode/transistor combination and therefore less isolation.
A question on the side, you don't happen to know as much about electronics as coding? Since you mentioned "optocoupler" and you seem to know well what happens behind the curtain of electronics, do you by chance have a confident guess where mullerEnergy could have soldered their optocoupler so that its relay gets closed once the passive balancing circuit of the jbd bms gets energized? I somehow can't quite get their seemingly ingenious solution to switch the active balancer on and off out of my head. Too bad ? that i am also too ignorant in the hardware department...
 
Last edited:
A question on the side, you don't happen to know as much about electronics as coding? Since you mentioned "optocoupler" and you seem to know well what happens behind the curtain of electronics, do you by chance have a confident guess where mullerEnergy could have soldered their optocoupler so that its relay gets closed once the passive balancing circuit of the jbd bms gets energized? I somehow can't quite get their seemingly ingenious solution to switch the active balancer on and off out of my head. Too bad ? that i am also too ignorant in the hardware department...
I wouldn't expect to find a single point on the BMS that could be used to determine whether balancing is active, because logically this isn't necessary for the operation of the passive balancer. I suspect mullerEnergy have worked with JBD to produce a custom variant with an additional logic output for this purpose.

If I was going to consider this, I'd look at using a 4072 "OR gate", the inputs of which could be placed across each of the balancing transistors to produce a single output indicating whether any of the balancing circuits are running. This would be possible for the smaller BMS (e.g. 4S or even 8S), however would become quite cumbersome for larger 16S systems. There's also a challenge of the base voltages for the transistors not being equal.
When considering the complexities of this approach, interfacing with the BMS over the UART port becomes a lot more appealing as you can do a lot more useful things with the information you receive than just switching a external balancer on and off.
 
Parsing the UART serial data from the BMS is the method of determining if passive balancing is active, that I plan to use for this type of addition. That info is available in the serial data.
 
I wouldn't expect to find a single point on the BMS that could be used to determine whether balancing is active, because logically this isn't necessary for the operation of the passive balancer. I suspect mullerEnergy have worked with JBD to produce a custom variant with an additional logic output for this purpose.

If I was going to consider this, I'd look at using a 4072 "OR gate", the inputs of which could be placed across each of the balancing transistors to produce a single output indicating whether any of the balancing circuits are running. This would be possible for the smaller BMS (e.g. 4S or even 8S), however would become quite cumbersome for larger 16S systems. There's also a challenge of the base voltages for the transistors not being equal.
When considering the complexities of this approach, interfacing with the BMS over the UART port becomes a lot more appealing as you can do a lot more useful things with the information you receive than just switching a external balancer on and off.
Many thanks for your valuable input and evaluation!

Seems only my imagination was simple, not actually their solution. I thought if passive balancing is active, current flows, if not, nothing flows. So if an optocoupler is soldered on that circuit, once current flows, its relay closes and the active balancer starts, if current stops, active balancer stops. So i thought one just has to find with a multimeter where in the balancing circuit current flow can be detected (through opening and closing balancing via the app) and voila, an optocoupler's new home would have been found. Since i don't know how current flows in these smd components, i am not confident where to place the probes safely without causing possible damage.

Unfortunately @MullerEnergy-Australia couldn't share with us yet a glimpse (a picture) of where they actually soldered the optocoupler on to in order to quell our burning diy curiosity. *Subtlehint* ?

Certainly, tapping into the Uart opens a new whole world of possibilities like you said, not just only controlling an active balancer.
 
Last edited:
Quick update: I have the STM32 code version running,
I just got a delayed answer of the vendor where i ordered the ams1117 3.3V. i inquired about the input range.

He replied:
DC input voltage: 4.5V--7V
DC output voltage: 3.3V
Output current: within <700ma

Further i read in the product description of a different vendor following:

"AMS1117 3.3V regulator. It is capable of regulating a wide range of input voltage (4.0 to 12V) down to a fixed 3.3V output at up to 1A (Vin = 4.5V).
Note: Do not exceed absolute maximum input voltage (12.5V) or output current. Exceeding maximum specifications can result in permanent damage to this module or any connected devices."

Ams1117 datasheet says up to 15V though.

My batteries are usually in the 12.8v-14v area. Am i understanding correct that i only need a voltage regulator from my battery voltage down to 3.3v? Does it have to be the ams1117? Is there something special about it?
I actually already have a few different adjustable voltage regulators like the
Mp2307dn mini360 4.75v-23v to 1-17v or
mp1584en 4.5v-28v to 0.8v-20v.
Could i also use one of them or are they not as reliable or good as the ams1117? Doesn't my battery voltage exceed the recommended maximum input voltage of the ams1117?
 
Last edited:
Back
Top