Simple DIY ESP8266 BMS

Announcement - Help us fight the BOTS! Please report all spam including stuff in your inbox!

Michel

New member
Joined
Apr 30, 2018
Messages
14
Hi Everyone,

Like many of us whom are looking to buy or make a simple BMS which would monitor and (passively) balance cells in our powerwall I've been playing with the idea to make my own based on ESP8266 modules. I've seen the DIY BMS that Stuart Pittaway has been working on but I find it way too complex and almost impossible for the average joe to make.

I'm looking forward to make a DIY BMS that's:
  • As simple as possible
  • As little different components as possible
  • Software programmable/WiFi manageable.
Attached is a quick sketch drawn by hand (sorry I've never used software for this purpose so opted to draw by hand):


image_ubdzjm.jpg


Each 1s module would have one board with the following components:
1 * ESP8266 D1 Mini (SOC)
1 * MCP1700-3302E/TO (3.3v regulator, regulate input/battery voltage to 3.3v for ESP)
2 * FK28X5R0J105K (1u 6.3v Capacitor, regulate input and output for/from MCP regulator)
5 * SFR16S0003300JA500 (330 Ohm resistor, for voltage divider and LED's)
2 * 1 Ohmn 20W Ceramic Resistor (For balancing/discharging)
2 * BUK98150-55A/CUF (N-Channel Mosfet, to switch resistors on/off)
2 * LED (as an indicator if resistors/balancing is active)

The primary function of the ESP8266 will be monitoring the voltage (to grafana) and activate the resistors when the battery surpasses a certain voltage (first resistor at 4.1V, second at 4.15V for example?). Since it's a SOC the software can be modified and improved over time.

I have little to no experience creating my own circuit, so this will be my first try, kindly please have a look at my plans, and if you have comments/suggestions please do share them.
 

Korishan

Moderator
Joined
Jan 7, 2017
Messages
6,635
Looks pretty good. I can't say if that'll work or not in the grand scheme.

A few points though.
Are you going to have a master? If so, how are you going to communicate with it?
What is the algorithm that will drive the balancing? How will it know when to kick on/off?
What use the ESP8266 and not just a ATTINY? Will you be putting the ESP to sleep between updates, or will it always be one monitoring the pack? If sleeping, how often would you wake it up to take samples?

I'm sure there are more questions, but I'll have to think of them, or let others post them ;)
 

Michel

New member
Joined
Apr 30, 2018
Messages
14
Hi Korishan,

Thank you for your reply!

Korishan said:
Are you going to have a master? If so, how are you going to communicate with it?
I was thinking about letting them all connect to our home network, and either assign a master, or chose to go for an external "server" as a monitor/command and control center. I think the last option would be the easiest as it should give more flexibility as to what coding language/protocol to use. MQQT?

Korishan said:
What is the algorithm that will drive the balancing? How will it know when to kick on/off?
So first I just want them to do top balancing and reporting the current voltages to a Raspberry Pi running grafana, which is currently monitoring the MPP PIP. As I mentioned since it's all software based from there on it should be easy to expand and improve. Suggestions as to what "algorithm" to use for balancing? So I can start doing my research :)

Korishan said:
What use the ESP8266 and not just a ATTINY? Will you be putting the ESP to sleep between updates, or will it always be one monitoring the pack? If sleeping, how often would you wake it up to take samples?
Well I assumed that even considering the non-sleeping energy consumption which is around 200mA@3.3V is completely unnoticeable when using powerwall sized deployments, like my 14s80p setup. It might be worth looking in to the sleeping functionality, but I'd rather not over-complicate everything.

I just did a quick google search on the ATTINY, it's a small programmable chip without WiFi and won't run arduino, correct? I'm afraid that'd be too complicated for me.
 

Geek

Member
Joined
Aug 15, 2017
Messages
920
I personally don't trust WiFi with such critical tasks. If for whatever reason there is some interference and your network is interrupted there is a possibility a critical error might be reported.

I would opt for a system that is wired and stand alone for the sake of reliability.

The Attiny85 is quite capable as an alternative to the Atmega328 (So it is quite capable of running Arduino code). However the difference in price is negligible .
 

Korishan

Moderator
Joined
Jan 7, 2017
Messages
6,635
The biggest issue with WiFi is that you can flood your network very rapidly. Also, it has delays that may impact certain responses, like safety measures. I would actually recommend at least going with I2C comms instead. Just 2 wires running from board to board. But, then you'd need to add in an opto-coupler.

I didn't have an algo in mind. I was just curious as to what your plan was to do the balancing. You have part of the 'idea' of it down, but you also need to include the whole path of the curve, not just where you want to terminate at the end. What I mean here is at what point do you start balancing? Do you wait till 1 pack gets to full voltage before triggering the burner? Do you cut in and slow it's charge by starting early (like start burning around 80% while the others are at 75% and wait, see what happens, readjust, etc, etc)?

Attiny can be programmed using the Arduino Library. However, you do need an interpreter of some sort. You can use an arduino board to do this, or you can get a USB -> SPI interface (i think that's what their called) that would allow you to do this. No it doesn't have wifi, but it does have I2C and SPI comms. Depending on which flavor you go with, you can have 3 sensors, or 10 sensors (i think it's 10, been awhile since I looked at them), unless you use I2C, then you can have several.

I'm not trying to discourage by any means. Just making you more aware of what the difficulty is overall before you get a lot of time/effort/money involved and find out it's a lot more difficult than originally expected.
I'm still learning on the electronics front building my own bms. Mine will be based off the Texas Instruments BQ769x0 line of IC's (there are 3, 920, 930, 940) and probably use either an esp32 or an stm32 to do the primary work. Then the smaller slaves will use the ATTINY's.

Before you go to deep, make a road map of what you'd like to do, how you think it's going to work. Learn about the different mcu's (atmega, attiny, stm, esp, ...), the pros/cons of various ways to do the project.

And actually, I think BTLE would be better to a central unit, and then that unit would do all the wifi broadcasting to your lan. But BT can be a pain to configure on some devices. Even Julian and Andreas had issues with it and they are way better at that stuff than me ;)
 

Michel

New member
Joined
Apr 30, 2018
Messages
14
Thank you for all your input. Just a quick reply/remark:
For I2C communications all boards will need to share the same ground, and that in my design isn't the case.
 

Geek

Member
Joined
Aug 15, 2017
Messages
920
Michel said:
Thank you for all your input. Just a quick reply/remark:
For I2C communications all boards will need to share the same ground, and that in my design isn't the case.


There are boards available to isolate I2C.
 

Mikethezipper

Member
Joined
Jul 7, 2018
Messages
121
Michel said:
Thank you for all your input. Just a quick reply/remark:
For I2C communications all boards will need to share the same ground, and that in my design isn't the case.

Hi Michel,
I'm very very interested in your project since this is where I will also be headed soon. Basically it seems like there is a huge gap between what we need and the other commercial systems commonly brought up here on this board.

I've been working on a bluetooth system to control my inverter and my refrigerator via a bluetooth app on my phone (or one could use a tablet).
My next phase was going to be a BMS. For me, this is important because I need all of my house to be talking to eachother. Something I haven't seen mentioned much is what happens to power generated AFTER all the cells are charged. With the BMS I'd like to build, excess power will be diverted to running loads which are non-essential but nice to have such as an electric water heater, charging random stuff I don't use often, etc. I don't see options for this on most charge controllers in a normal price range. Additionally, if I leave my inverter on overnight (by accident) it would automatically shutoff the inverter after 1am for example since.. well I shouldnt be awake that late anyways :)

What Korishan brought up is really what I would agree with. Basically I was going to do pack by pack voltage detection (which with any microcontroller also brings up other issues) and then control pack by pack charging. However, it's basically pointless to do this since as Korishan said, Texas instrument already made an IC that does all of this for us, and they took care of all of the leg work for charging characteristics etc.

I am thinking a more robust system would be to use the TI IC to measure the pack voltages (it would look at each pack as a cell since the voltage is the same for all of those cells in parallel) as well as to control charging for the packs (from an equalization point of view) I haven't looked into the communication protocol the chip uses, but I'm sure it outputs all of the invormation we already need.
From there, the microcontroller will use that information to make decisions such as low or over voltage cutoff (You still need over voltage cutoff in case something awful happens and power keeps getting dumped into battery) and will transmit data to a central command station (computer, tablet, phone etc). However it should be independently robust and work regardless of what's going on with wifi or bluetooth etc. Essentially, the computer/table/etc will be used to display data that's been logged over time and to be able to remotely adjust parameters such as cutoff voltages etc.

The coding part is honestly going to get really ugly. If you were making a system to only do BMS with cutoffs etc, that in and of itself doesn't initially seem to be that big a deal. What I've been dealing with is connection drops and packet losses (with bluetooth, but that applies to everything really) whereby you have to continue doing all the important BMS activities while trying to re-establish a connection with something that is super timing dependent. This is why I think it's best to essentially have a separate chip manage that, the TI chip. The second chip (microcontroller) will essentially be there to do any auxiliary control and to communicate as a middle man between the TI chip and the computer/tablet.

This way, it doesn't really matter if you use bluetooth or wifi. I'll be following this thread; I'm really interested to see your progress!
 

Sean

Member
Joined
Oct 8, 2016
Messages
936
Michel said:
Hi Everyone,

Like many of us whom are looking to buy or make a simple BMS which would monitor and (passively) balance cells in our powerwall I've been playing with the idea to make my own based on ESP8266 modules. I've seen the DIY BMS that Stuart Pittaway has been working on but I find it way too complex .....

Have you seen ....

https://github.com/chickey


image_wzqyhj.jpg
 

Korishan

Moderator
Joined
Jan 7, 2017
Messages
6,635
Michel said:
For I2C communications all boards will need to share the same ground, and that in my design isn't the case.

That's why I said you'd need to use opto-couplers, or opto-isolators as they are also called. Basically they transmit signals across a gap using infra-red light. The gap is only a hairs width or less, all packed into an IC. On either side of the chip there can be differences in voltage. They are used a lot in switching powersupplies, or when half the board is low voltage DC and the other half is high voltage AC.

As Sean brought up, Colin Hickey's boards are pretty nice too. I don't remember who elaborated and built on the other. But Colin and Stuart have worked together on the projects.
btw, here on the forum, Colin is also known as rev0
 

Mikethezipper

Member
Joined
Jul 7, 2018
Messages
121
I was taking a look at the TI reference designs and well, basically they have the exact board we need, already designed, all the schematics, testing data, documentation ... everything just sitting there:
http://www.ti.com/tool/TIDA-00817 <--overall reference design page

http://www.ti.com/lit/ug/tidubz7/tidubz7.pdf <-- full documentation

Basically, they are using a couple main parts - a microcontroller that controlls.. well everything , their main monitoring chip which just looks at the voltage of each cell, and then a switching matrix that basically hooks up their charging circuitry to each cell depending on which cell is lowest.

This was basically the design I was thinking of... but more complicated than I think it needs to be for what most of us would be doing with it. For example, their setup is made to go up to 4A charging current per cell (packs) which I think will be waay out of line with what we should need for balancing.

So basically what I'm wondering is if we can use one of their cheaper cell monitoring chips to get accurate cell voltages and report those to a microcontroller with a decent number of pins (not an ESP8266 or we'd need to use a multiplexer or something) and those pins would essentially control TP4056 boards which are hooked up to each individual cell. So we could at night (3am?) have it start charging the lowest cells using the pack power (thru a buck converter that regulates to a 5v rail).
I know it's not ideal, but I'm honestly too stupid to know the right way of doing this, and overall I think with board, the TI chip, and a couple pre-made TP4056 boards, the all in cost would not be too high. And more importantly for me, I'd have the ability to monitor my powerwall without needing to trust some chinese board that I'm expecting to randomly explode (even if the TP4056 fails, the main microcontroller will shutoff power to that board) or having to shell out a ton of money for a batrium system for each of my small powerwalls (3kwh isn't worth the comparatively huge price tag for me)
 

Charly144

Member
Joined
Nov 22, 2017
Messages
287
I was playing with similar thoughts on a bms based on an esp but gave up due to voltage reading from cells.

One idea came up recently: you can buy a 14s bms where you can set parameters for almost eur 10,- and then read voltage data from cells via rs232. Then you can decide what functionality you want to use from cheap bms and build up your logic with esp externally e.g. 2A balancing current via resistor on a relay or mosfet... rest of cheap bms functionality you switch off.

It is simply degrading a full bms to just the voltage reading topic...

Just an idea
 

Mikethezipper

Member
Joined
Jul 7, 2018
Messages
121
Charly144 said:
I was playing with similar thoughts on a bms based on an esp but gave up due to voltage reading from cells.

One idea came up recently: you can buy a 14s bms where you can set parameters for almost eur 10,- and then read voltage data from cells via rs232. Then you can decide what functionality you want to use from cheap bms and build up your logic with esp externally e.g. 2A balancing current via resistor on a relay or mosfet... rest of cheap bms functionality you switch off.

It is simply degrading a full bms to just the voltage reading topic...

Just an idea

That's pretty interesting, especially if there was a way to send or communicate to it that it should begin balancing... or does it do that automatically all the time?

My only thing is that I pretty much hate rs232, and I'd rather make my own board than deal with that crap, because now I need another chip just to communicate by 232 and I still don't have much of any added functionality.
It'd be cool if there were some with SPI or i2c considering it'd be really weird for the BMS to natively support rs232 since it uses such a strange voltage vs .. basically anything else
Do you have a link or a name that I can google to look this up?

Also, all of this is based on the assumption that charging will be done via a separate dedicated charge controller - but basically this is kind of sub-optimal. Basically I'd have two latching relays for the main power busses into the pack. this way if any one cell voltage goes over a setpoint, it blocks off the pack from the charger, and if any single cell drops below the low setpoint it disconnects the pack to keep it safe. either condition will trigger pack balancing.

For my use I'd also want a shunt sensor at ~200A or so to report power use back to the main display, but it wouldn't necessarily be used for anything bms related. Also, for me I'd have a power bleed-off relay that would energize once the pack is fully charged so that I'm doing something with excess power.

As far as I can tell, the batriums have this same limitation. Basically all other parts are add-ons or features.


Ok I learned to google and I found a bunch of "I figured out a bit of the communication protocol" but nothing so far where they have full control
But something I found which does really pique my interest is the following BMS from ali express: HERE

They claim to be using the TI chips for both cell monitoring and charge control. The only thing is that I have no idea what the communication protocol on this is setup to be - basically we'd need to know that.
I tried looking up the company and found absolutely nothing. Considering they claim to have voltage cutoffs etc, I'm not sure if they are using a main controller chip of if the TI chip has that functionality built in. I'm going to message the seller and see what they can tell us...
If they are using legit TI chips thru and thru, we might be able to use the headers on the board to essentially reprogram the chips and send/receive data. Basically everything we need on one board for 50 bucks
 

Charly144

Member
Joined
Nov 22, 2017
Messages
287
I would be very happy using such a china bms where i can set parameters. It can do everything a standard bms should be capable of, only limitation is that it has just 50mA balancing current. You can get them in versions of 100A or more...

Rs232 is supported natively by the esp from my knowledge. You programm it via rs232.
You can implement logic which is not covered by bms in your program on the esp or raspberry...
 

Nikhil Mahajan

New member
Joined
Oct 2, 2017
Messages
13
hello everyone,

I'm also buildingdiy bms. I'musing 1117 to convert 12 v to 3.3 v. as my microcontroller is working on 3.3v.so this regulator is itself consuming a lot of power. around 11 mA whereas my microcontroller is consuming only 300 uA. is thereany other way to convert 12v to 3.3v.i though of using buck converter but it is too bulky or my circuit.

thank you in advance.
 

Korishan

Moderator
Joined
Jan 7, 2017
Messages
6,635
Nikhil Mahajan said:
hello everyone,

I'm also buildingdiy bms. I'musing 1117 to convert 12 v to 3.3 v. as my microcontroller is working on 3.3v.so this regulator is itself consuming a lot of power. around 11 mA whereas my microcontroller is consuming only 300 uA. is thereany other way to convert 12v to 3.3v.i though of using buck converter but it is too bulky or my circuit.

thank you in advance.

Are you trying to read the whole string of cells in as complete voltage? Or is your source 12V?
Probably the best and least power consuming would be to use opto-isolators and use an IC that can handle that voltage directly. Basically use'd use an ADC, then send the digital signal through the opto-isolator.
You need the opto so you can separate the physical grounds/negatives.
 

Mikethezipper

Member
Joined
Jul 7, 2018
Messages
121
Has anybody made any headway on this?

I've been looking around for a ChineseBMS that can be communicated with - basically, it would only be used for cell level monitoring.

I have found many solutions - but they are all way overpriced($100+ for something that will just monitor cell voltages) for what they are. Essentially they all have cell balancing and current monitoring, along with mosfets to shutoff/turn on current... but of course, none of them are useful for our uses since their current limits are way too low - and their cell balancing is always of too low a current to be useful for anything we'd be doing.

So what I'm thinking now is that there really isn't anything out there (short of batrium) that does what we want.

So I'm thinking now that we use a single slavemicro controller for monitoring cell voltages - then a master that is connected to the latching relays for allowing charge in/out and for controlling balancing.

Anyone interested in working with me on this? I finished my bluetooth fridge and inverter controller project (works like a charm) and I'll be moving onto this next. I"ll be starting my own thread soon - but I'm a bit reticent since there are so many threads that have been started on this topic and then kind of just fizzle out
 

Mikethezipper

Member
Joined
Jul 7, 2018
Messages
121
So I just spent the past 4 hours researching this again.

I think I have a tenable architecture for how this would work, and in the end it is similar to what batrium is doing. However for me the kicker to get this whole thing started is essentially something for battery monitoring.
I have looked at all of the offerings for single IC monitors (plus extras) offered by many of the companies out there and my favorite is the Maxim MAX14921 - as anything developed using this would mean it can be used for any number of cells from 3-16. The offerings from TI go from 6-16 cells or 3-6 cells, and they are much more expensive than the Maxim option.
I've requested an evaluation board from Maxim - their chip is $15 in low quantities. Maxim has some application notes, but not as much information as TI offers for their products.

I found that someone has used the 12cell version of the Maxim Chip:
https://endless-sphere.com/forums/viewtopic.php?t=66415
However there is little for me to love on this - I can use little of any of this information, but it is reassuring to know someone out there has done it.
I have found a couple projects using the TI chips, but for my use I can't use any of the 6+ cell ones since my first implementation will be for a 4s.
However, I did find a stackable project that looks promising (although it has lots of extra circuitry just for balancing that we wouldn't use):
https://endless-sphere.com/forums/viewtopic.php?f=14&t=49543&start=75
Which unfortunately went dark a couple years ago - all he shared is the schematic with none of the EAD files or code.

Essentially - looks like I'm at square one. What I like of the single IC chip solutions is that they would result in high accuracy voltage measurements. However, I'm wondering what, if any, purpose something like this would even serve? Considering we cannot use these chips for balancing - it seems like it's $15-20 down the drain for something not really useful.

I'm going to start looking at mutli-channel ADCs and a precision voltage reference going straight to the main controller - in the end a master micro-controller will be doing all the thinking and deciding what to do.
Looks like most of these battery monitoring ICs require external precision ADCs and precision voltage references ANYWAYS, so it seems like there is little to no point in having them. Maybe Korishan will chime in here with his wisdom, he always seems to know the answer.
 

Korishan

Moderator
Joined
Jan 7, 2017
Messages
6,635
For the TI chips, which ones were you looking at? I've been working with the BQ769x0 series IC's. They are about $3 - $8, depending on range. They are even designed so you could stack them. So if you go with the 920 (3-7s), you could use two of them to do 6 - 14. Or use them for modular expansion.
 

Mikethezipper

Member
Joined
Jul 7, 2018
Messages
121
I didn't realize the BQ76PL536A orBQ76925 chips didn't require external ADC and voltage reference. Considering the amount of information available for these chip, I'll probably start going down that road soon. This makes that solution much easier to implement and much cheaper as well. Thanks!
 
Top