Giter Club home page Giter Club logo

diybmsv4code's Introduction

diyBMS v4

Version 4 of the diyBMS. Do-it-yourself battery management system for Lithium ion battery packs and cells

If you are looking for version 3 of this project take a look here https://github.com/stuartpittaway/diyBMS

THIS REPOSITORY IS FOR THE ESP8266 BASED CONTROLLER BOARD (ORIGINAL/LEGACY)

The newest ESP32 based code can be found here https://github.com/stuartpittaway/diyBMSv4ESP32

Support the project

If you find the BMS useful, please consider buying me a beer, check out Patreon for more information.

You can also send beer tokens via Paypal - paypal.me/stuart2222

Any donations go towards the on going development and prototype costs of the project.

Videos on how to use and build

https://www.youtube.com/stuartpittaway

Video on how to program the devices

https://youtu.be/wTqDMg_Ql98

Video on how to order from JLCPCB

https://youtu.be/E1OS0ZOmOT8

Help

If you need help, ask over at the forum

If you discover a bug or want to make a feature suggestion, open a Github issue

How to use the code

Master Branch

This release removes the need to manually compile the code yourself, instead GITHUB Actions are now used to build the code for you automatically.

The files you will need are held as a ZIP file in Releases

Download the ZIP file named "Compiled_Firmware_YYYY-MM-DD-HH-MM.zip" and extract its contents and inside the folder you should find:

Files for the controller (ESP8266)

  • diybms_controller_firmware_espressif8266_esp8266_d1mini.bin
  • diybms_controller_filesystemimage_espressif8266_esp8266_d1mini.bin

Files for the modules (ATTINY841)

  • module_fw_V400_attiny841_400_eF4_hD6_l62.hex
  • module_fw_V410_attiny841_410_eF4_hD6_l62.hex
  • module_fw_V420_attiny841_420_eF4_hD6_l62.hex
  • module_fw_V420_SWAPR19R20_attiny841_420_SWAPR19R20_eF4_hD6_l62.hex
  • module_fw_V421_attiny841_421_eF4_hD6_l62.hex
  • module_fw_V421_LTO_attiny841_421_eF4_hD6_l62.hex
  • module_fw_V440_attiny841_440_eF4_hD6_l6C.hex

You can ignore the "filesystemimage" for the esp8266, this is no longer required.

You will need to determine which module HEX file to use (see "Identify which module/board you have" below for help). Most people will have a V4.00 or V4.21 board.

Programming the controller

Both Wemos D1 Mini and Wemos D1 Mini & Pro are supported - minimum of 4MB flash memory.

  1. Connect the WEMOS D1 to the computer using a USB cable
  2. Download the esphome-flasher tool for your operating system
  3. Run the program once downloaded
  4. Select the correct serial port from the list for the Wemos D1
  5. Click Browse and select the file "diybms_controller_firmware_espressif8266_esp8266_d1mini.bin"
  6. Click "Flash ESP" and wait

You should see output similar to below, this is a WeMos D1 Mini Pro (16MB Flash)

Using 'COM3' as serial port.
Connecting....
Detecting chip type... ESP8266
Connecting....

Chip Info:
 - Chip Family: ESP8266
 - Chip Model: ESP8266EX
 - Chip ID: 00123456
 - MAC Address: AA:BB:CC:DD:EE:FF
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
 - Flash Size: 16MB
 - Flash Mode: dout
 - Flash Frequency: 40MHz
Erasing flash (this may take a while)...

Writing at 0x000b0000... (100 %)
Wrote 872784 bytes (728955 compressed) at 0x00000000 in 17.2 seconds...
Hash of data verified.
Leaving...
Hard Resetting...
Done! Flashing is complete!

Programming the modules

Module code runs on the ATTINY841 micro controller, it is important to program the chip with the correct version of code depending on your PCB version.

You will need a programming device capable of programming ATMEL AVR chips - like the USBASP programmer

Setup the programmer

  1. Connect the USBASP programmer to the computer
  2. On the programmer, move the jumper pin (normally marked JP1) to use 3.3 volt programming settings (instead of 5 volt)
  3. Completely disconnect the module from any battery/cell and the TX/RX connectors should also be unconnected.
  4. Connect the programmer to the module using the 6 pin ISP connector on the module - take great care to ensure PIN 1 is aligned to PIN 1 of the programmer. PIN 1 is marked on the PCB.
  5. Download AVRDUDE 6.3 or newer, for Windows other versions are here
  6. Extract the AVRDUDE zip file
  7. Open a console/command window and change to the folder where you extracted the AVRDUDE program, on Windows this looks similar to this
cd C:\temp\avrdude-6.3-mingw32
  1. The standard avrdude tool doesn't include support for ATTINY841 chips. So download and overwrite the file avrdude.conf using the file from here
  2. Lets test connectivity to the programmer and module. Back in the console window, run the command below. On Linux and Mac operating systems, you may need to use a different port insteoad of "usb" - for example /dev/tty1 but this will vary depending on the computer. Note that the parameters ARE case sensitive.
avrdude -C avrdude.conf -P usb -c usbasp -p t841
  1. All being well, it should report something similar to the below. If not, check the wiring and ensure you are using the correct COM port.
avrdude: set SCK frequency to 187500 Hz
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.02s
avrdude: Device signature = 0x1e9315 (probably t841)
avrdude: safemode: Fuses OK (E:F4, H:D6, L:E2)
avrdude done.  Thank you.

Programming the module

Programming the module takes around 12 seconds.

  1. Identify which module/board you have using the details found at the end of this document.
  2. Copy the required ".hex" file to the same folder where you extracted the avrdude tool to.
  3. Now we shall program the module, run the command line similar to below, replacing the "diybms_module_firmware_400" filename where applicable.
  4. The fuse settings are important, and are in the filename for example "eF4_hD6_l62" - means efuse=0xF4, hfuse=0xD6, lfuse=0x62
avrdude -C avrdude.conf -P usb -c usbasp -p t841 -e -B 8 -U efuse:w:0xF4:m -U hfuse:w:0xD6:m -U lfuse:w:0x62:m -U flash:w:diybms_module_firmware_400.hex:i

it should output

avrdude: set SCK frequency to 187500 Hz
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e9315 (probably t841)
avrdude: erasing chip
avrdude: set SCK frequency to 187500 Hz
avrdude: reading input file "0xF4"
avrdude: writing efuse (1 bytes):
Writing | ################################################## | 100% 0.00s
avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xF4:
avrdude: load data efuse data from input file 0xF4:
avrdude: input file 0xF4 contains 1 bytes
avrdude: reading on-chip efuse data:
Reading | ################################################## | 100% 0.00s
avrdude: verifying ...
avrdude: writing hfuse (1 bytes):
Writing | ################################################## | 100% 0.00s
avrdude: 1 bytes of hfuse written
avrdude: reading on-chip hfuse data:
Reading | ################################################## | 100% 0.00s
avrdude: verifying ...
avrdude: writing lfuse (1 bytes):
Writing | ################################################## | 100% 0.00s
avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xE2:
avrdude: reading on-chip lfuse data:
Reading | ################################################## | 100% 0.00s
avrdude: verifying ...
avrdude: writing flash (7718 bytes):
Writing | ################################################## | 100% 6.74s
avrdude: 7718 bytes of flash written
avrdude: verifying flash memory against diybms_module_firmware_XXX.hex:
Reading | ################################################## | 100% 3.43s
avrdude: verifying ...
avrdude: 7718 bytes of flash verified
avrdude: safemode: Fuses OK (E:F4, H:D6, L:E2)
avrdude done.  Thank you.
  1. If programming fails, but the programmer appears to be communicating, try increasing the value of the "B" setting from 8 to 16 to slow down the USBASP device.
  2. Check that the fuses report as "OK" and read E:F4, H:D6, L:E2
  3. That module can now be disconnected from the USBASP programmer, connect the next module and repeat the avrdude command to program the next one.

Hardware

Hardware for this code is in a seperate repository, and consists of a controller (you need 1 of these) and modules (one per series cell in your battery)

https://github.com/stuartpittaway/diyBMSv4

Identify which module/board you have

  • V400 = Original board (marked DIYBMS v4 on silkscreen) - has 8 large resistors (marked 2R20) and likely handsoldered using 0805 sized parts [4.0 boards do have TP2 near the ATTINY841 chip]

  • V410 = JLCPCB built board (marked DIYBMS v4 on silkscreen) - has 8 large resistors (marked 2R00) and machine soldered using 0603 sized parts [4.1 boards do not have TP2 near the ATTINY841 chip]

  • V420 = JLCPCB built board (marked DIYBMS v4.2 on silkscreen) - has 20 small resistors (marked 6R20) and machine soldered using 0603 sized parts (R20 is in middle of resistor array)

  • V420_SWAPR19R20 = JLCPCB built board (marked DIYBMS v4.2 on silkscreen) - has 20 small resistors (marked 6R20) and machine soldered using 0603 sized parts [you have manually resoldered R19 and R20 to swap the positions on PCB to move the thermistor inside the resistor array]

  • V421 = JLCPCB built board (marked DIYBMS v4.21 on silkscreen) - has 20 small resistors (marked 6R20) and machine soldered using 0603 sized parts (R19 is in middle of resistor array)

  • V440 = Marked DIYBMS v4.4 on silkscreen, released Feb 2021 - DO NOT USE THIS CODE WITH OLDER VERSION BOARDS

Open the module code, navigate to platformio environment "env:attiny841_VXXX", (where XXX is the version from above). Connect your USBASP programmer to the module and select "Upload"

WARNING

This is a DIY product/solution so don’t use this for safety critical systems or in any situation where there could be a risk to life.

There is no warranty, it may not work as expected or at all.

The use of this project is done so entirely at your own risk. It may involve electrical voltages which could kill - if in doubt, seek help.

The use of this project may not be compliant with local laws or regulations - if in doubt, seek help.

How to compile the code yourself

The code uses PlatformIO to build the code. There isn't any need to compile the code if you simply want to use it, see "How to use the code" above.

If you want to make changes, fix bugs or poke around, use platformio editor to open the workspace named "diybms_workspace.code-workspace"

License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.0 UK: England & Wales License.

https://creativecommons.org/licenses/by-nc-sa/2.0/uk/

You are free to:

  • Share — copy and redistribute the material in any medium or format
  • Adapt — remix, transform, and build upon the material The licensor cannot revoke these freedoms as long as you follow the license terms.

Under the following terms:

  • Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • Non-Commercial — You may not use the material for commercial purposes.
  • ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
  • No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.

Notices: You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation.

No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.

diybmsv4code's People

Contributors

danielch58 avatar fredm67 avatar hotear avatar kroesche avatar stuartpittaway 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  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  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  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  avatar

Watchers

 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

diybmsv4code's Issues

Last module in second bank has invalid voltage

I’ve just finished connecting my second 14s to the controller and assigned each to the second bank (bank 1) and for some reason the last cell on the second bank has invalid voltage. I’ve substituted a different module for that cell and it also has the same issue. If I assign that module back to the first bank (bank 0) it reads a voltage correctly. I therefore think the issue is in the controller code rather than with the module.

SAVE D3 pin (for reset config) and a delay (3 seconds) at start up

Hi Stuart, in order to save one pin in wemos, you can use double reset detector library instead of D3 pin.

After deleting Wifi settings by pushing D3 at boot during a 3 seconds delay and with the "risky" of bounce buttons you finally restart ESP8266.

So there is no problem to use doble reset detector library, it resets the ESP8266, but is the same, finally you get what you want by only by pusing twice reset button. After detecting that, you can run the SoftAP module.

I hope you can implement this in future, a pin in an ESP8266 is like petrol !!!

ESP8266 version: https://github.com/datacute/DoubleResetDetector
(I have used it in several projects, works fine)

ESP8266 and ESP32 "new version for another guy": https://github.com/khoih-prog/ESP_DoubleResetDetector
(I have never use it with ESP32, but may you you prefer it for future migration to ESP32)
It even has an example of how to use it with WifiManager library. Think also that wifimanager will be ready for ESP32 soon, (it is almost). https://github.com/tzapu/WiFiManager/tree/development

Bye.

missing files when loading minipro

Any input? Cloned the code per the video but only the 32 compiles, the minipro always fails.

:\Users\MadDog.platformio\packages\framework-arduinoespressif8266\cores\esp8266/Arduino.h:238:21: fatal error: algorithm: No such file or directory
#include
^
In file included from src\main.cpp:38:0:
C:\Users\MadDog.platformio\packages\framework-arduinoespressif8266\cores\esp8266/Arduino.h:238:21: fatal error: algorithm: No such file or directory
#include
^
compilation terminated.
compilation terminated.
*** [.pio\build\esp8266_d1minipro\libf31\ESP8266TrueRandom\ESP8266TrueRandom.cpp.o] Error 1
*** [.pio\build\esp8266_d1minipro\libb8f\ESP8266WiFi\BearSSLHelpers.cpp.o] Error 1
*** [.pio\build\esp8266_d1minipro\src\PacketRequestGenerator.cpp.o] Error 1
*** [.pio\build\esp8266_d1minipro\src\PacketReceiveProcessor.cpp.o] Error 1
*** [.pio\build\esp8266_d1minipro\src\main.cpp.o] Error 1
*** [.pio\build\esp8266_d1minipro\src\SoftAP.cpp.o] Error 1
*** [.pio\build\esp8266_d1minipro\src\DIYBMSServer.cpp.o] Error 1
xtensa-lx106-elf-g++: error: CreateProcess: No such file or directory
*** [.pio\build\esp8266_d1minipro\lib0ae\Queue\cppQueue.cpp.o] Error 1
======================================================== [FAILED] Took 2.54 seconds ========================================================

Environment Status Duration


esp8266_d1minipro FAILED 00:00:02.542
=================================================== 1 failed, 0 succeeded in 00:00:02.542 ===================================================
The terminal process "C:\Users\MadDog.platformio\penv\Scripts\platformio.exe 'run', '--target', 'upload', '--environment', 'esp8266_d1minipro'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

Time delay relay rules

#It would be great if there would be an adjustable time delay for the realy rules, so there is no endless loop in certain cases.

INVERT option on the configuration screen

Now I will describe how it actually works (Firmware HysteresisRules, All rules X):
Relay default - OFF -> On the corresponding output, logic 1
Relay default - ON -> On the corresponding output, logic 0
Logically correct to do the opposite.

need a simple INVERT option on the configuration screen.

Amount of Banks

Hi
Thanks for your work

Is their a way to monitor more than 4 banks ?

Maybe 4 per controller and then a master controller to control the controllers?

The controller is having difficulty communicating with the cell monitoring modules.

Hello, I have a problem with communication, the esp8266 "4MB" can not connect to cell models. All cell modules seems to work fine in standby mode the blue LED double flash every 8 second and bypass work when cells voltage exceed 4.1V. But when I connect the TX from ESP to RX in cell model all LEDs turn off in the Module and nothing happen after. I am getting this error from ESP: "The controller is having difficulty communicating with the cell monitoring modules." I have double checked the connection everything seems fine and I tried to connect only one model it did not work too. Any ideas to make it work??

ESP8266 with 4 MB flash memory - WIFI Password issues

If you have an ESP8266 with only 4MB flash memory the controller will enter a loop when configuring the wifi setup - it appears like the password isn't stored (its not!) so the controller attempts to go into a setup loop.

The recommended ESP8266 is the D1 Mini Pro - this has 16MB Flash by default.

buy from here https://amzn.to/2OF7Mzn

To make DIYBMS work on 4MB flash - change the option in platformio.ini

build_flags = -Wl,-Tesp8266.flash.16m15m.ld

to

build_flags = -Wl,-Tesp8266.flash.4m1m.ld

Note that future versions of the controller code may require larger flash sizes to store other information, historic logging etc.

Can't compile 256Modules branch for esp8266 but works for ESP32

I get this error :

Building in release mode
Compiling .pio\build\esp8266_d1minipro\src\DIYBMSServer.cpp.o
Compiling .pio\build\esp8266_d1minipro\src\PacketRequestGenerator.cpp.o
Compiling .pio\build\esp8266_d1minipro\src\SoftAP.cpp.o
Compiling .pio\build\esp8266_d1minipro\src\main.cpp.o
In file included from .pio\libdeps\esp8266_d1minipro\ESP Async WebServer\src/WebHandlerImpl.h:30:0,
                 from .pio\libdeps\esp8266_d1minipro\ESP Async WebServer\src/ESPAsyncWebServer.h:467,
                 from src\DIYBMSServer.cpp:26:
.pio\libdeps\esp8266_d1minipro\Time@src-012c38ce3e6dbfbcfc0f0e65ff7ff9e7/time.h:1:2: warning: #warning "Please include TimeLib.h, not Time.h.  Future versions will remove Time.h" [-Wcpp]
 #warning "Please include TimeLib.h, not Time.h.  Future versions will remove Time.h"
  ^
In file included from .pio\libdeps\esp8266_d1minipro\ESP Async WebServer\src/WebHandlerImpl.h:30:0,
                 from .pio\libdeps\esp8266_d1minipro\ESP Async WebServer\src/ESPAsyncWebServer.h:467,
                 from include/SoftAP.h:15,
                 from src\SoftAP.cpp:2:
.pio\libdeps\esp8266_d1minipro\Time@src-012c38ce3e6dbfbcfc0f0e65ff7ff9e7/time.h:1:2: warning: #warning "Please include TimeLib.h, not Time.h.  Future versions will remove Time.h" [-Wcpp]
 #warning "Please include TimeLib.h, not Time.h.  Future versions will remove Time.h"
  ^
Compiling .pio\build\esp8266_d1minipro\liba99\ESP8266WiFi\WiFiServer.cpp.o
Compiling .pio\build\esp8266_d1minipro\liba99\ESP8266WiFi\WiFiServerSecureAxTLS.cpp.o
Compiling .pio\build\esp8266_d1minipro\liba99\ESP8266WiFi\WiFiServerSecureBearSSL.cpp.o
Compiling .pio\build\esp8266_d1minipro\liba99\ESP8266WiFi\WiFiUdp.cpp.o
In file included from .pio\libdeps\esp8266_d1minipro\ESP Async WebServer\src/WebHandlerImpl.h:30:0,
                 from .pio\libdeps\esp8266_d1minipro\ESP Async WebServer\src/ESPAsyncWebServer.h:467,
                 from src\main.cpp:71:
.pio\libdeps\esp8266_d1minipro\Time@src-012c38ce3e6dbfbcfc0f0e65ff7ff9e7/time.h:1:2: warning: #warning "Please include TimeLib.h, not Time.h.  Future versions will remove Time.h" [-Wcpp]
 #warning "Please include TimeLib.h, not Time.h.  Future versions will remove Time.h"
  ^
In file included from src\PacketRequestGenerator.cpp:1:0:
include/PacketRequestGenerator.h:25:35: error: expected ')' before '*' token
   PacketRequestGenerator(cppQueue *requestQ) { _requestq = requestQ; }
                                   ^
include/PacketRequestGenerator.h:48:3: error: 'cppQueue' does not name a type
   cppQueue *_requestq;
   ^
src\PacketRequestGenerator.cpp: In member function 'void PacketRequestGenerator::pushPacketToQueue(PacketStruct*)':
src\PacketRequestGenerator.cpp:157:3: error: '_requestq' was not declared in this scope
   _requestq->push(_packetbuffer);
   ^
*** [.pio\build\esp8266_d1minipro\src\PacketRequestGenerator.cpp.o] Error 1
In file included from include/DIYBMSServer.h:24:0,
                 from src\DIYBMSServer.cpp:42:
include/PacketRequestGenerator.h:25:35: error: expected ')' before '*' token
   PacketRequestGenerator(cppQueue *requestQ) { _requestq = requestQ; }
                                   ^
include/PacketRequestGenerator.h:48:3: error: 'cppQueue' does not name a type
   cppQueue *_requestq;
   ^
In file included from include/DIYBMSServer.h:24:0,
                 from src\main.cpp:227:
include/PacketRequestGenerator.h:25:35: error: expected ')' before '*' token
   PacketRequestGenerator(cppQueue *requestQ) { _requestq = requestQ; }
                                   ^
include/PacketRequestGenerator.h:48:3: error: 'cppQueue' does not name a type
   cppQueue *_requestq;
   ^
src\main.cpp:232:1: error: 'cppQueue' does not name a type
 cppQueue requestQueue(sizeof(PacketStruct), 16, FIFO);
 ^
src\main.cpp:234:1: error: 'cppQueue' does not name a type
 cppQueue replyQueue(sizeof(PacketStruct), 8, FIFO);
 ^
src\main.cpp:236:54: error: 'requestQueue' was not declared in this scope
 PacketRequestGenerator prg = PacketRequestGenerator(&requestQueue);
                                                      ^
src\main.cpp: In function 'void serviceReplyQueue()':
src\main.cpp:406:11: error: 'replyQueue' was not declared in this scope
   while (!replyQueue.isEmpty())
           ^
src\main.cpp: In function 'void onPacketReceived()':
src\main.cpp:454:8: error: 'replyQueue' was not declared in this scope
   if (!replyQueue.push(&ps))
        ^
src\main.cpp: In function 'void timerTransmitCallback()':
src\main.cpp:475:7: error: 'requestQueue' was not declared in this scope
   if (requestQueue.isEmpty())
       ^
src\main.cpp:483:3: error: 'requestQueue' was not declared in this scope
   requestQueue.pop(&transmitBuffer);
   ^
src\main.cpp: In function 'void timerLazyCallback()':
src\main.cpp:1249:11: error: 'requestQueue' was not declared in this scope
       if (requestQueue.getRemainingCount() < 6)
           ^
*** [.pio\build\esp8266_d1minipro\src\main.cpp.o] Error 1
*** [.pio\build\esp8266_d1minipro\src\DIYBMSServer.cpp.o] Error 1
======================================================================================================== [FAILED] Took 5.15 seconds ========================================================================================================
Environment        Status    Duration
-----------------  --------  ------------
esp8266_d1minipro  FAILED    00:00:05.152
================================================================================================== 1 failed, 0 succeeded in 00:00:05.152 ================================================================================================== 

A Relay Wishlist

See attached image. I figured a pic is worth a thousand words, in this instance.
DIYBMSV4_relay_wishlist

Configure voltage range of graph and show nominal/high/low voltage for chemistries

I work with cells that use different kinds of chemistry, and they have some voltage ranges that don't precisely fit into the "Lithium Ion" template of voltage ranges. e.g.)

  • Lead Acid : 1.8 to 2.27 ( 2V nominal )
  • LiFeMnPo (Valence) : 2.5 to 3.65-4.2V ( 3.3V nominal )
  • LiPo : 3 to 4.2V hard cutoff ( 3.7V nominal )
  • LiCoO2 : 3.0 to 4.2V hard cutoff ( 3.6V nominal )

As an enhancement, and since people don't tend to use mixed-chemistries ... I would like to propose an enhancement where the graph's voltage range fits the chemistry of the batteries being used and that the high/low/nominal voltages be shown across the graph as perhaps faint colored/dashed lines.

When I am monitoring LiFeMnPo cells and (top and bottom) balancing them -- the graph really never extends more than about halfway up. It's very hard to see small differences in charge between the cells when the voltage range is so small graphically.

It's even more difficult with lead acid cells for example, since the voltage range on them is only 0.47V... everything is compressed into a tiny range.

voltage

configure

Callibration of voltage only works on cell 0

Expected: When setting callibration value on cell XX then cell XX should have that callibration voltage setting

Current: If i change on cell 10 still cell 0 is changed and i can see that cell go to NA and then back in the dashboards.

This is for the 256module branch. I will take a look at hte code later on what could be wrong unless fixed before that and submitt a pull request.

Relay gets activated for a short time when ESP board restarts

I use the 4 channel relay board as recommended.
On relay channel 2 I have two rules active:

  • Individual cell under voltage: 2900, on
  • Pack under voltage: 42000, on
    Relay default is: off

Some times my esp controller restarts on its own. I guess some sort of overflow (many packets get los and I also have some CRC errors) or in generell some noise problem. But anyway, after the controller restarts the relay 2 gets fired up for some short time. Thus, my battery inverter gets the open circuit signal and thinks that my pack is critical low. As consequence it starts charging (from the grid). The same happens if I restart the esp on purpose (by software and by unplugin/plugin).

Maybe the esp controller doesn't calculate the total pack voltage in the first secondes correctly as it doesn't have the feedback of all modules. If this is true we need some sort of delay for the relays.

I tried changing to relay channel 3 with the same setting and the same issue happens. So I think it is not a relay board based problem.

Controller code version number

I think it'd be helpful and reduce some confusion, at least on my part, to have a controller code version number somewhere on the web interface page.

Current Sensing

Is there any sourcecode available for the current sensing? You you have any plans for that? Can I help?

New functionality for rules

Hi @stuartpittaway ,
Here are my suggestions about extending the rules functionality (move here from the community on your request).

Long story short:

  1. Add "Individual cell module over temperature (internal) °C"
  2. Add second "Individual cell over temperature (external) °C" for High and High High signals
  3. "Pack under voltage (mV)" - divide into 2 set points: under voltage + recover set point
  4. "Pack over voltage (mV)" - divide into 2 set points: over voltage + recover set point

Detailed description with examples:

  1. Add an internal over temperature rule to start cooling fan for the bms. Example: cells modules are installed separately from cells, all together, lets say in a box. With such installation it is easy to organize a cooling for them to make top balancing more efficient for large packs. Also in such case the interface/communication wires are as short as possible to minimize interference. A rule to start cooling would be nice to have in this case.

  2. Individual cell over temperature (external) °C - it would be great to have this rule 2 times to configure HIGH and HIGH HIGH limits. HIGH limit would be used to switch on cooling fans in the battery compartment and HIGH HIGH - as a main trip signal to disconnect the battery from all devices.

  3. Pack under voltage. The most reasonable use for this rule is disconnecting and connecting back to the battery inverters. I saw somebody already suggested to put a time delay for rules, but I would like to extend this subject. Normally for such application 2 set points are used: switch off set point and recover set point. Time delay would also be great (to cover start loads) but not enough, from my point of view. Example: 14s battery + grid tie inverter with limiter - the inverter itself will normally have a battery discharge protection, however it make no sense to “dry run” an inverter if the battery is discharged, because it will only consume power from grid (yes, not much, but still); so, it would be nice to switch off the inverter lets say at 44V and connect it back only after battery is recharged to lets say 49V. Using this rule “as it is” with only one set point make for me little sense, because it would be jumping back and forth all the time.

  4. Pack over voltage (mV) - similar thing as case 3 but for burning the excess energy (to heat the water for example). We can switch on the relay to turn on the water heater at Lets say 57,5V and switch it off at 56V. A time delay would also be nice here.

It would be nice to have these features in new releases.
Thanks

WARNING! Cell modules overheating, PID crashed

Dear all,

I have been running with the DIYBMS for 3 weeks now. Running flawless, till I did a configuration change that crashed every single one of my 14 cell modules which began to go smoking hot.

Running the current release version of the code.

I wanted to balance my power wall down to 3.8v/cell to do some charge testing with my solar tomorrow. The stack was at 3.9v/cell. Here is what happened.

  1. I updated the global settings to 65 Celsius, 3800 mV,
  2. drank a cup of coffee,
  3. went down to my power wall, and noticed that the balance indicator LEDs were all solid on. Not “PID flickering”
  4. pulled up the web interface. Each module was at 120 Celsius and rising.
  5. in a panic, increased the bypass voltage to 4100 mV and did a global update.
  6. all cell modules cut out now that the bypass voltage was set higher than what the cell voltage. The boards began to cool. LED went off for every single module.

This was reproducible. Each time I changed back the bypass voltage to any value below the cell voltage, the PID did not kick in. The LEDs just went solid on and the dump resistors was driven constantly on.

Everything else appeared normal. I could read out the configuration of each module. No bogus values, no bad data packages.

It was first when I physically unplugged and thus rebooted each cell module that I could get rid of the dangerous and odd behavior. After having cycled power to all 14 modules I could set the global parameters to 65 Celsius and 3800 mV and all cell modules have since operates as intended.

I do not dare to keep the system on without active supervision now. Has anything like this been seen/reported before?

PS. I am using the 4mb WEMOS on the ESPController. Do not know if this can be related to my issues.

branch 256modules doesnt start up the softap properly but crashes

When using 256modules branch the softap doesnt work properly. It crashes the ESP after 2 seconds. I tried both the master branch right now that works fine and boots up and start debugging messages properly meanwhile 256 modules look like this:
image
As can bee seen it crashes and doesnt show the AP.

Also why is the debugging ofsetted on the 256modules version compare to the master that looks nice?

Meassured voltage should not be done during balancing

Currently we read the voltage without looking into if the balancing is running.
When balancing there is a significant voltage drop over the wires. Either we need to calculate this during voltage reading or we should just stop the balancing during this time

The drop itself do trigger the pwm to engage rather early. (I have to dig into the code a bit more to understand how it all works)

I could probably take a look but the code for the cell modules arent what im used to (Im not a coder) :)

Low temperature rule

Brilliant BMS system and I am definitely going to build and use the v4 for an upcoming DIY electric boat conversion to a 16s 300Ah LIFEPO4 powered system.

I am only missing a rule to switch off the (solar) charger when a cell or pack temperature is below 0 celcius (<5 celcius is safer) as a lithium battery will be permanently damaged when charged in low temperature state.

Timer2 PWM hangs

Timer2 is used to drive the balancing circuit via PWM.

After the first cycle of balancing, the PWM appears to not enable fully and causes the balance to not fully work.

Balance on demand

It would be nice to have option to make "force balance", for which you would enter mV value of biggest difference, and than modules would balance themselves regardless that cell is not in overvoltage state.
This would help in case that you have one cell with lower voltage, and not getting them all to "charge state".
Thank you.

MQTT Features

Hi Stuart,

Can you extend the MQTT messages for the whole pack/bank?

  • pack voltage
  • relay status
  • voltage range

Another wish, if possible, can you make a field for the cell modules to give the pack individual names?

Mqtt keeps broadcasting stale data when comms have issues.

What happens:
The current code keep sending same data even when comms is down or stale.

Expected:
It should revert to 0 values if not valid data in them or just not send the data at all.

Perhaps do something like this: (main.cpp)
if ((!mysettings.mqtt_enabled && !mqttClient.connected()) || receiveProc.HasCommsTimedOut())

Missing sdkconfig.h, freertos/semphr.h, esp_task_wdt.h, ...

Hi!
I try to get this debug code up running, but after cloning the git, the compiler ask for some missing libs: sdkconfig.h, freertos/semphr.h, esp_task_wdt.h. I tried to install the libs manually, without success.

In file included from .pio\libdeps\nodemcuv2\AsyncTCP_ID1826\src\AsyncTCP.cpp:24:0: .pio\libdeps\nodemcuv2\AsyncTCP_ID1826\src\AsyncTCP.h:26:23: fatal error: sdkconfig.h: No such file or directory

How can I install the right libs?
Thanks!

Add hysteresis to relay rules

Hi,
I have been using your bms for a while and I noticed that when undervoltage or overvoltage events are triggered bms sends signal to turn off load/charging but as soon as device turns off voltage on the cells bounces back a little and bms sends signal to turn on the device.

It would be great if You could add some sort of hysteresis, so when discharging the cells voltage reaches for example 3V/cell bms sends signal to turn off discharging device, but turning it back on would be possible when cells reach for example 3.2V/cell. Of course overvoltage situation working on the same principle.

It would eliminate constant turning on and off
of peripheral devices.

ESPController copilation issue

Hi,
I'm trying to compile the ESPController software but am getting errors regarding git from the file buildscript_versioning.py.
When compiling from the downloaded Zip:
"fatal: Not a git repository (or any of the parent directories) .git"
When compiling from a cloned directory:
"fatal: your current branch 'master' does not have any commits yet"
Why does it want me to set up a git repository?

Mongoose OS

Feel free to delete this if it's off-topic, however i am wondering if the ESP used in the controller board can have Mongoose OS loaded with the default diybmsv4 code working in tandem.

My reason, i have the diybms setup and working, and i turned a raspberrypi into an MQTT Broker. I also have a Flask-based Apache webpage that i have turned into a webapp. Currently it uses a 433MHz communication system. I want to reconfigure the webpage/webapp to communicate with the diybms main console. The reason? I have a home automation setup that allows me to control and monitor my home and workspace remotely. I already have the UI and homeautomation setup, i'd simply like to integrate the diybms into the system.

Cell modules moved away from bank 0 don't register over voltage

Any cell modules moved away from bank 0 do not initiate balance mode. Red LED does not light and resistors do not heat up. This happened on banks 1, 2, and 3. I lowered global bypass voltage threshold below my lowest cell, save settings and cells only on bank 0 did what they should.

Can bus support for controller?

A lot of inverters (Goodwe, Growatt, SMA, Sungrow, etc) have the capability to communicate with a battery over CAN. I even suspect they refuse to function without communication being present. Maybe it would be a nice addition to support communication over CAN replicating the LG RESU message protocol (best supported in the industry it seems).

Bank zero disappears periodically and loses max and min values when reappears.

I have 3 banks (14s) attached to my controller. When watching the monitor page from the web browser, periodically (when charging mostly) bank 0 will disappear from the display but bank 1 and 2 will remain. On the next refresh it will reappear but it will have lost it's min and max voltage values. I've attached a couple of screen shots showing the data missing from the monitor.json file and when a bank is missing (not that banks are not renumbered, bank 1 and 2 remain as 1 and 2 not changed to 0 and 1).
missing
missing2

Enable BOD

Enable BOD detection and also write EEPROM values multiple times to prevent loss of EEPROM contents in BOD conditions

vref

hi stuartpittaway
i dont have lm4040, can i just leave it blank? and just change this line to 1024.0?
//2mV per ADC resolution
myConfig.mVPerADC = 2.0; //2048.0/1024.0;

Clarify allowed use cases

Hi,

sad to see you moved away from open licenses and are now using a more restrictive one - especially since "non-commercial" isn't really a well defined concept and a lot of uses might be considered "commercial". As such things like paying companies to fabricate boards instead of etching them at home, using boards to run a solar system connected to the grid (some countries require owners to start a "company" to get the necessary permits) or even talking about the system on websites containing ads might put users into a position where lawyers might write nasty letters. It would be great if you could add a little clarification on where your interpretation of "NC" starts and what uses are explicitly allowed.

Rule for temperature is below value

I am only missing a rule to switch off the (solar) charger when a cell or pack temperature is below 0 celcius (<5 celsius is safer) as a lithium battery will be permanently damaged when charged in low temperature state.

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.