# DIYBMS v4

**URL:** <https://community.openenergymonitor.org/t/diybms-v4/11292>\
**Category:** diyBMS\
**Tags:** bms, diybms, battery\
**Created:** [30 June 2019 09:06 UTC](https://community.openenergymonitor.org/t/diybms-v4/11292 "2019-06-30T09:06:01Z")\
**Posts on this page:** 20\
**Page:** 5

<div class="post-metadata">

**Author:** ![planepilot](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/p/51bf81/32.png) [@planepilot](https://community.openenergymonitor.org/u/planepilot)\
**Post date:** [9 August 2019 00:28 UTC](https://community.openenergymonitor.org/t/diybms-v4/11292/88 "2019-08-09T00:28:22Z")

</div>

Still no luck. I have ordered a USBTiny to do the programming so I’m hoping that will make things easier!

---

<div class="post-metadata">

**Author:** ![Paul\_C](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/paul_c/32/10784_2.png) [@Paul\_C](https://community.openenergymonitor.org/u/Paul_C)\
**Post date:** [9 August 2019 08:12 UTC](https://community.openenergymonitor.org/t/diybms-v4/11292/89 "2019-08-09T08:12:00Z")

</div>

Hi Rick, i was trying last night to program my first module with an arduino, and after a few hours of tearing my hair out i got it working.

Inside the platformio.ini file shoul look like this:

; PlatformIO Project Configuration File  
;  
; Build options: build flags, source filter  
; Upload options: custom upload port, speed and extra flags  
; Library options: dependencies, extra library storages  
; Advanced options: extra scripting  
;  
; Please visit documentation for the other options and

[env:attiny841]  
platform = atmelavr  
board = attiny841  
framework = arduino

board\_build.f\_cpu = 8000000L  
board\_build.core = tinymodern

lib\_deps =  
[GitHub - bakercp/PacketSerial: An Arduino Library that facilitates packet-based serial communication using COBS or SLIP encoding.](https://github.com/bakercp/PacketSerial.git)  
[GitHub - mike-matera/FastPID: A fast, integer based PID controller suitable for Arduino.](https://github.com/mike-matera/FastPID.git)

upload\_protocol = stk500v1

; each flag in a new line  
;-B16 option needed for my USBASP programmer to slow it down!  
upload\_flags =  
-P$UPLOAD\_PORT  
-b$UPLOAD\_SPEED  
-Uefuse:w:0b11111110:m  
-Uhfuse:w:0b11010110:m  
-Ulfuse:w:0b11100010:m

; efuse = 1111 1110 = Enables SPM instruction  
; hfuse = 1101 0110 = EESAVE & 1.8V BOD detection level  
; lfuse = 1110 0010 = CKDIV8 & Calibrated Internal 8MHz Oscillator  
upload\_port = COM4  
upload\_speed = 19200

Hope this helps

Paul

---

<div class="post-metadata">

**Author:** ![marius\_r](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/marius_r/32/10619_2.png) [@marius\_r](https://community.openenergymonitor.org/u/marius_r)\
**Post date:** [9 August 2019 08:15 UTC](https://community.openenergymonitor.org/t/diybms-v4/11292/90 "2019-08-09T08:15:33Z")

</div>

You need an USBASP, I use one and I didn’t have any problems at all.

---

<div class="post-metadata">

**Author:** ![stuart](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/stuart/32/16661_2.png) [@stuart](https://community.openenergymonitor.org/u/stuart)\
**Post date:** [9 August 2019 09:18 UTC](https://community.openenergymonitor.org/t/diybms-v4/11292/91 "2019-08-09T09:18:54Z")

</div>

> [@planepilot](#):
>
> Still no luck. I have ordered a USBTiny to do the programming so I’m hoping that will make things easier!

Have you tried a basic “blink” sketch using the Arduino IDE - just to test the programmer out?

---

<div class="post-metadata">

**Author:** ![planepilot](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/p/51bf81/32.png) [@planepilot](https://community.openenergymonitor.org/u/planepilot)\
**Post date:** [9 August 2019 11:22 UTC](https://community.openenergymonitor.org/t/diybms-v4/11292/92 "2019-08-09T11:22:57Z")

</div>

Thanks Paul!!! That code worked perfect!!!

---

<div class="post-metadata">

**Author:** ![Paul\_C](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/paul_c/32/10784_2.png) [@Paul\_C](https://community.openenergymonitor.org/u/Paul_C)\
**Post date:** [9 August 2019 11:51 UTC](https://community.openenergymonitor.org/t/diybms-v4/11292/93 "2019-08-09T11:51:25Z")

</div>

Glad to help! Wasnt sure if i fluked it or not, i generally just muddle my way through code.

---

<div class="post-metadata">

**Author:** ![Ufuoma\_Abirhire](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/ufuoma_abirhire/32/10522_2.png) [@Ufuoma\_Abirhire](https://community.openenergymonitor.org/u/Ufuoma_Abirhire)\
**Post date:** [9 August 2019 20:52 UTC](https://community.openenergymonitor.org/t/diybms-v4/11292/94 "2019-08-09T20:52:20Z")

</div>

I was able to use an arduino nano as an ISCP programmer to program the attiny841.

---

<div class="post-metadata">

**Author:** ![planepilot](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/p/51bf81/32.png) [@planepilot](https://community.openenergymonitor.org/u/planepilot)\
**Post date:** [9 August 2019 20:58 UTC](https://community.openenergymonitor.org/t/diybms-v4/11292/95 "2019-08-09T20:58:22Z")

</div>

Sorry for all the questions. I finally got one board working 😁 I have one that seemed to program okay. Lights blinked while programming. But red light came on when the battery was connected. It was never recognized on the controller. It also started getting warm so I unplugged it and checked all the components for shorts and proper connection. I then tried to program the board again but it fails with the following error:

avrdude: Device signature = 0xffffff (probably .reduced\_core\_tiny)  
avrdude: Yikes! Invalid device signature.  
Double check connections and try again, or use -F to override  
this check.

I tried the override and it finished but still gave an upload error. Have I fried the chip or is there anything I can do to get it to write again?

---

<div class="post-metadata">

**Author:** ![Gelisob](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/gelisob/32/10688_2.png) [@Gelisob](https://community.openenergymonitor.org/u/Gelisob)\
**Post date:** [9 August 2019 21:14 UTC](https://community.openenergymonitor.org/t/diybms-v4/11292/96 "2019-08-09T21:14:41Z")

</div>

darn it. You better make sure you re-check the LCSC order after you import the bill of materials file. I ended up with several things in quantity of 10 instead of 100, bleh 😛  
(like the big 2512 balance resistors! … and JST connectors and…)

---

<div class="post-metadata">

**Author:** ![Eddie\_Latuta](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/eddie_latuta/32/10714_2.png) [@Eddie\_Latuta](https://community.openenergymonitor.org/u/Eddie_Latuta)\
**Post date:** [10 August 2019 15:58 UTC](https://community.openenergymonitor.org/t/diybms-v4/11292/98 "2019-08-10T15:58:19Z")

</div>

I managed to figure out what was the problem in my case. At first I did not know that Platformio would download the appropriate library automatically once you build the project but also I had an error while downloading libraries so it did not work anyway. So I downloaded all necessary library one by one from Libraries section in Platformio. I guess that did not download the right version of the NtpClient library. Even I deleted Time.h file it did not resolve the problem. What I did in the end was to uninstall all the libraries and loaded a new project but commented out NtpClient library. After that all libraries were downloaded fine. At this point I commented NtpClient and it downloaded OK too. After that I deleted Time.h and all code compiled and uploaded OK.

---

<div class="post-metadata">

**Author:** ![Eddie\_Latuta](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/eddie_latuta/32/10714_2.png) [@Eddie\_Latuta](https://community.openenergymonitor.org/u/Eddie_Latuta)\
**Post date:** [10 August 2019 16:15 UTC](https://community.openenergymonitor.org/t/diybms-v4/11292/99 "2019-08-10T16:15:03Z")

</div>

It is probably easier to include libraries like it is done in the Sonoff-Tasmota project with the required revision specified in the lib folder:

> **[Tasmota/lib at development · arendst/Tasmota](https://github.com/arendst/Tasmota/tree/development/lib)**
>
> development/lib

---

<div class="post-metadata">

**Author:** ![Bill.Thomson](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/bill.thomson/32/1834_2.png) [@Bill.Thomson](https://community.openenergymonitor.org/u/Bill.Thomson)\
**Post date:** [10 August 2019 16:59 UTC](https://community.openenergymonitor.org/t/diybms-v4/11292/100 "2019-08-10T16:59:54Z")

</div>

> [@Eddie\_Latuta](#):
>
> commented out NtpClient library. After that all libraries were downloaded fine.

> [@Eddie\_Latuta](#):
>
> At this point I commented NtpClient and it downloaded OK too.

**un** commented?

---

<div class="post-metadata">

**Author:** ![Eddie\_Latuta](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/eddie_latuta/32/10714_2.png) [@Eddie\_Latuta](https://community.openenergymonitor.org/u/Eddie_Latuta)\
**Post date:** [10 August 2019 17:07 UTC](https://community.openenergymonitor.org/t/diybms-v4/11292/101 "2019-08-10T17:07:30Z")

</div>

Yes sorry that was a typo uncommented of course

---

<div class="post-metadata">

**Author:** ![Bill.Thomson](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/bill.thomson/32/1834_2.png) [@Bill.Thomson](https://community.openenergymonitor.org/u/Bill.Thomson)\
**Post date:** [10 August 2019 17:16 UTC](https://community.openenergymonitor.org/t/diybms-v4/11292/102 "2019-08-10T17:16:16Z")

</div>

No worries. Thought that was the case. Been there, done that, _many_ times myself. 😉 😁

Just wanted to avoid any confusion for other users who may be having the same problem.

---

<div class="post-metadata">

**Author:** ![Eddie\_Latuta](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/eddie_latuta/32/10714_2.png) [@Eddie\_Latuta](https://community.openenergymonitor.org/u/Eddie_Latuta)\
**Post date:** [10 August 2019 18:03 UTC](https://community.openenergymonitor.org/t/diybms-v4/11292/103 "2019-08-10T18:03:57Z")

</div>

Yey it is working

 ![diy%20bms%201](https://community.openenergymonitor.org/uploads/default/original/2X/1/15a0a87e16a9c5b26dcb5d9d2330bc88e42b72db.png) ![diy%20bms%202](https://community.openenergymonitor.org/uploads/default/original/2X/8/8824fec4c1edf808dddbeb01fcbf8398f39e0153.png)

---

<div class="post-metadata">

**Author:** ![planepilot](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/p/51bf81/32.png) [@planepilot](https://community.openenergymonitor.org/u/planepilot)\
**Post date:** [11 August 2019 01:18 UTC](https://community.openenergymonitor.org/t/diybms-v4/11292/104 "2019-08-11T01:18:42Z")

</div>

Still struggling on these boards. So I have made 4 now. 2 are working and 2 are not. Still facing the error if I try to re-program the chips on the bad ones. But the 2 that I have working only do so if connected single. When I try to add another into the chain, it gets a communication error. Using the same cables for each board?

---

<div class="post-metadata">

**Author:** ![Paul\_C](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/paul_c/32/10784_2.png) [@Paul\_C](https://community.openenergymonitor.org/u/Paul_C)\
**Post date:** [11 August 2019 07:19 UTC](https://community.openenergymonitor.org/t/diybms-v4/11292/106 "2019-08-11T07:19:57Z")

</div>

I have one made along with the controller board and they work flawlessly together, surprisingly so, as they were both hand soldered in my lorry whilst parked up for the night. The next ones ill be using solder paste and the stencil.

As for problems the only ones i had was a broken wire on a jst pin and i ordered the PCF8574T and not the AT version, but i altered the code to suit and it works.

As for anyone having communication problems, make sure the optoisolator is the right way round and none of the pins are shorted out (They’re awfully close together)

 ![20190811_080934](https://community.openenergymonitor.org/uploads/default/original/2X/f/fb955b27600ad59f429b4fc3b835914b760a3cc0.jpeg)

---

<div class="post-metadata">

**Author:** ![higopi](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/h/f475e1/32.png) [@higopi](https://community.openenergymonitor.org/u/higopi)\
**Post date:** [12 August 2019 18:47 UTC](https://community.openenergymonitor.org/t/diybms-v4/11292/107 "2019-08-12T18:47:28Z")

</div>

> [@Paul\_C](#):
>
> i ordered the PCF8574T and not the AT version, but i altered the code to suit and it works.

Hi Paul. Thanks . Could you kindly share the code changes as I have made the same mistake with the order

---

<div class="post-metadata">

**Author:** ![stuart](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/stuart/32/16661_2.png) [@stuart](https://community.openenergymonitor.org/u/stuart)\
**Post date:** [12 August 2019 19:30 UTC](https://community.openenergymonitor.org/t/diybms-v4/11292/108 "2019-08-12T19:30:43Z")

</div>

This is simply a number change. The i2c address is different for these chips. Think there are comments in the controller code about this already.

---

<div class="post-metadata">

**Author:** ![higopi](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/h/f475e1/32.png) [@higopi](https://community.openenergymonitor.org/u/higopi)\
**Post date:** [12 August 2019 19:41 UTC](https://community.openenergymonitor.org/t/diybms-v4/11292/109 "2019-08-12T19:41:15Z")

</div>

Cheers thanks Stuart !!

[Previous page](https://community.openenergymonitor.org/t/diybms-v4/11292.md?page=4)

[Next page](https://community.openenergymonitor.org/t/diybms-v4/11292.md?page=6)
