DIYBMS v4

I modified the platformio.ini file to allow selecting for the type of programmer your using, usbasp or arduino uno.

if you are using the arduino uno as isp you also need to set your comport. i tried to just upload the file but is not an allowed type to upload. anyways just cut and replace what is in the platformio.ini file. also I put the wiring information for the uno to bms module 6 pin header

default_envs = attiny841 ; uncomment if using usbasp for programming
;default_envs = attiny841_ARDUINOISP ; uncomment if using arduino uno as isp
comport = COM5 ; ** USED FOR ARDUINO ISP, Change this to the comport YOUR arduino uno is on

I have tested with my arduino uno, but not the usbasp device, so if someone could do that and let me know if it programmed as expected, then maybe Stuart can incorporate into published source.

; 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 examples
; Redirecting...
;
[platformio]
; options set default_envs to
; “attiny841” if using a usb programmer
; “attiny841_ARDUINOISP” if using an Arduino as isp
;
;***** ONLY CHANGE HERE ******
;
default_envs = attiny841 ; uncomment if using usbasp for programming
;
;default_envs = attiny841_ARDUINOISP ; uncomment if using arduino uno as isp
;
comport = COM5 ; ** USED FOR ARDUINO ISP, Change this to the comport YOUR arduino uno is on
;
;*****************************
;
; if using an arduino uno as isp the following is the wire connections
; bms module - PIN 1 (MISO) → Arduino Uno - PIN 12
; bms module - PIN 2 (5V) → Arduino Uno - 5V
; bms module - PIN 3 (SCK) → Arduino Uno - PIN 13
; bms module - PIN 4 (MOSI) → Arduino Uno - PIN 11
; bms module - PIN 5 (RESET) → Arduino Uno - PIN 10
; bms module - PIN 6 (GND) → Arduino Uno - GND
;
;
[common_env_data] ; common environment data
upload_flags =
-vv
-Uefuse:w:0b11110100:m
-Uhfuse:w:0b11010110:m
-Ulfuse:w:0b11100010:m
;
lib_deps =
GitHub - bakercp/PacketSerial: An Arduino Library that facilitates packet-based serial communication using COBS or SLIP encoding.
GitHub - mike-matera/FastPID: A fast, integer based PID controller suitable for Arduino.
;
;//==========================================================================
[env:attiny841] ; build parameters when using “USBASP” programmer
platform = atmelavr
board = attiny841
framework = arduino
;
board_build.f_cpu = 8000000L
board_build.core = tinymodern
;
lib_deps =
${common_env_data.lib_deps}
;
upload_protocol = usbasp
;
; efuse = 1111 0100 = Enables SPM instruction
; hfuse = 1101 0110 = EESAVE & 1.8V BOD detection level
; lfuse = 1110 0010 = CKDIV8 & Calibrated Internal 8MHz Oscillator
;
; E2
board_fuses.lfuse = 0b11100010
; D6
board_fuses.hfuse = 0b11010110
; F4
board_fuses.efuse = 0b11110100
;
; each flag in a new line
;-B16 option needed for my USBASP programmer to slow it down!
upload_flags =
${common_env_data.upload_flags}
-B16
-Pusb
;
;//==========================================================================
;
;//==========================================================================
[env:attiny841_ARDUINOISP] ; build parameter when using arduino as isp
platform = atmelavr
board = attiny841
framework = arduino
;
board_build.f_cpu = 8000000L
board_build.core = tinymodern
;
lib_deps =
${common_env_data.lib_deps}
;
upload_protocol = stk500v1
;
upload_port = ${platformio.comport}
upload_speed = 19200
;
; efuse = 1111 0100 = Enables SPM instruction
; hfuse = 1101 0110 = EESAVE & 1.8V BOD detection level
; lfuse = 1110 0010 = CKDIV8 & Calibrated Internal 8MHz Oscillator
;
; E2
board_fuses.lfuse = 0b11100010
; D6
board_fuses.hfuse = 0b11010110
; F4
board_fuses.efuse = 0b11110100
;
; each flag in a new line
upload_flags =
${common_env_data.upload_flags}
-P$UPLOAD_PORT
-b$UPLOAD_SPEED
;
;//==========================================================================

1 Like