DIY Lithium Battery Balancer and monitoring (BMS)

@stuart (and also @Colin_Hickey)

is it unthinkable that a future version of the boards will have active balancing rather than passive burning energy ?

Unthinkable I’m afraid. If the battery pack is well designed, the BMS hardly does any balancing so don’t worry about the wasted energy.

it was just a thought, i guess if using junk cells and good cells it would be a thing

and then again “china” will throw it at you for next to nothing,

anyway i would rate my thought as a mild smelling brain fart :smiley:

I am at my witsend with this project, in way to deep to stop and go to v4. Had it all working and then unfortunately a mishap happen the other week and i lost my controller (my fault). So i order another NodeMcu ESP8266 ESP-12E V3 same board. Uploaded the script, plugged it back it into where the old one came out, and (f&$ken of course not) it didnt work. Spent the next week making a new shield, tried different modules, used both test controller and wifi controller. Start the whole process on a module and nothing. Thinking it was the NodeMcu board ordered another one (its didnt work same issues) and a wemos mini (not here yet on a long boat from china still). Now the other night trying to load the script i am getting this

Sketch uses 347064 bytes (33%) of program storage space. Maximum is 1044464 bytes.
Global variables use 31568 bytes (38%) of dynamic memory, leaving 50352 bytes for local variables. Maximum is 81920 bytes.
esptool.py v2.6
Serial port COM10
Connecting…
Chip is ESP8266EX
Features: WiFi
MAC: cc:50:e3:cd:9e:c5
Uploading stub…
Running stub…
Stub running…
Erasing region (may be slow depending on size)…
Erase completed successfully in 0.2 seconds.
Hard resetting via RTS pin…
esptool.py v2.6
Serial port COM10
Connecting…
Chip is ESP8266EX
Features: WiFi
MAC: cc:50:e3:cd:9e:c5
Uploading stub…
Running stub…
Stub running…
Configuring flash size…
Auto-detected Flash size: 4MB
Compressed 351216 bytes to 248130…

Writing at 0x00000000… (6 %)
Writing at 0x00004000… (12 %)
Writing at 0x00008000… (18 %)
Writing at 0x0000c000… (25 %)
Writing at 0x00010000… (31 %)
Writing at 0x00014000… (37 %)
Writing at 0x00018000… (43 %)
Writing at 0x0001c000… (50 %)
Writing at 0x00020000… (56 %)
Writing at 0x00024000… (62 %)
Writing at 0x00028000… (68 %)
Writing at 0x0002c000… (75 %)
Writing at 0x00030000… (81 %)
Writing at 0x00034000… (87 %)
Writing at 0x00038000… (93 %)
Writing at 0x0003c000… (100 %)
Wrote 351216 bytes (248130 compressed) at 0x00000000 in 22.1 seconds (effective 126.9 kbit/s)…
Hash of data verified.

Leaving…
Hard resetting via RTS pin…

This is happening on any laptop i try to load the script on
If someone could help that would be great, as i am losing patients and finiances are drying up. Thanks Andy

Hi Andy, the upload process you list seems normal (this was changed a few months back by the Arduino/ESP folks).

What actually happens after you flash the ESP ? It should start the whole configuration process off again and ask you to configure the WIFI etc. Do you see the DIYBMS access point start up?

Anything on the serial console?

I’m also aware there were a batch of ESP modules floating around that didn’t work the same as a genuine NodeMCU board - they wouldn’t keep the EEPROM/flash settings and caused strange problems.

When i flash with the Test controller, i can see the esp wifi on my wifi list, i can bring up the list of serial monitor, but when scan it doesnt find anything. I have tried provisioned and unprovisioned module.
With the wifi controller, i finally seen the webpage [my optus router is giving me a hard timei never have to sign in like other have] but can not see any modules or provision them.
I wondering if i can test the NodeMcu board and its pins, what the chances the pins or naming have changed.
Stuart can you email me or would you need my email, i may need one on one help here and forum are to difficult to do that.
I am hoping it is just the nodemcu and when my wemos mini gets here it works.
Thanks
Andy

If it’s something that might help others in the future, we’d prefer you used the forum. But if not, you can use PMs (Private Messages) that are within the Discourse system but not visible to anyone other than the participants and top level Admins (I as a moderator can’t see them).
To get to the PM system, click on your icon top right, then the envelope icon.

I’m not able to provide one on one help (sorry) as you can imagine I get a lot of requests like this and I’d never get through them all !

Back to your setup… Lets get back to basics.

  • Program a single cell module with the ATTINY code (Arduino-BMS-Cell-Module.ino)
  • Connect the ESP8266 to a SINGLE cell module and ensure you have the pull up resistors connected.
  • Take a look at these instructions NodeMCU i2c Scanner on Arduino IDE - Robo India || Tutorials || Learn Arduino || Robotics
  • Program the ESP8266 with the i2c scanner software, open the serial monitor.
  • It should find an i2c device at address 21 (0x15 in hex) if it finds a device at 24 or higher then that module has already been provisioned and you didn’t do step 1 in this list.

If you can do the above and let the forum know how you got on. This should prove the ESP and ATTINY are talking to each other over i2c. Nothing will work on the DIYBMS without this basic feature working.

thanks stuart, understand.
i will do the above and let the forum know how i go.
Thanks
Andy

This is the result i recieved
⸮⸮xWA⸮⸮⸮$⸮⸮⸮⸮
I2C scanner. Scanning …
Done.
Found 0 device(s).

I used both the shield i made and then cables, All the same result as above. Even switch the scl and sda lines around, same results.
Andy

Ok, that’s progress.

As you can see nothing is found on the i2c bus.

Next we need to check the esp8266 pins to ensure that the i2c lines are correct.

Just a thought, the cell module was connected to a battery or power supply?

yeah it was, ran it like a proper setup with 1 battery.
I am using D1 SLC and D2 SDA.

The code I wrote has D2 for data and D1 for clock.
// DATA=GPIO4/D2, CLOCK=GPIO5/D1
Wire.begin(4, 5); //SDA/SCL

Just thinking out loud, the i2c scanner I asked you to run, can you replace the Wire.Begin statement in that code with the line from above (with the 4,5 in it) - potentially the i2c scanner is trying to use different pins.

This may also help troubleshoot ESP8266: I2C PORT and Address Scanner : 8 Steps - Instructables

Ultimately we need to prove that the i2c bus is working, without that working nothing is going to work.

  • Do you have any other chips or i2c devices (OLED screen, temperature sensor etc?) we could connect to the ESP instead of the BMS module?
  • Do you have more than 1 BMS module you can try (in case of bad soldering etc.) ?

I am not sure if i have put the Wire.begin(4, 5); //SDA/SCL in the correct place. Here is the code. i am using havent tested it as yet. I think i have a temp sensor, but i am unsure if its an i2c type, i will need to find it and check it. I have 16 modules that are completed and where all provisioned and working, i can grab any of them to test as well.
I will read the instructable and do some of the tests. I hope to get back to you later. Time zones are a pain. thanks Andy

#include <Wire.h>

void setup() {
  Serial.begin (9600); 
  while (!Serial) // Waiting for serial connection
    {
    }

  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;

  Wire.begin(4, 5); //SDA/SCL
  
  Wire.begin();
  for (byte i = 8; i < 120; i++)
  {
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      {
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      count++;
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup

void loop() {}

Remove the line

Wire.begin();

Did the change in the code same results as before.
will work on the other things now.
This is the temp sensor i have:
https://www.littlebird.com.au/products/module-sensor-temperature-arduino-comp
not sure it will help.
Bought one of these, but who knows when i get it due AUSPOST.
https://www.ebay.com.au/itm/LM75A-Temperature-Sensor-I2C-High-Speed-Interface-Development-Board-/263565430254?_trksid=p2385738.m43
Thanks
Andy

The LM75A should be okay - as thats an i2c device.

Its very strange that your setup was working but no longer does. Definately worth trying a different module or 2 against the ESP to see if they respond to the i2c.

Did you have any issues programming the ATTINY code - what type of programmer do you use? Did you burn the fuses properly (Arduino interface does this for you).

Yeah totally agree that its strange that its not working. I do think the NodeMcu are most probably crap, but i cant continue paying $10 for them until i get one that works.
I am really hoping the Wemos Mini gets here soon and it works straight away.
While i am waiting for the temp sensor i will test all 14 of the modules and see if any of them work. Can I test them using the scanner and see if they come up as a provisional module number, ie >24
How unlucky can i be that i get 2 NodeMcu that dont work.

I am using Adam Welch setup for the modules, using an Arduino. The ATTINY worked correctly, not sure what you mean by burn the fuses properly.
I will let you know how the 14 modules go. I am in Melbourne, so late here, will have to do it tomorrow.
Thanks
Andy

Yes thats fine as long as you connect them 1 at a time to the ESP

Yeah nothing found for all 16 modules, i will wait to the temp sensor get here and let you know how it goes. I will keep you inform what is happening. Thanks Andy