JBD BMS Wi-Fi Module

melkier

Solar Addict
Joined
Jul 24, 2020
Messages
125
Many thanks for your kind replies!

Funny that you already thought about doing so. If you do then i might also build one of your boards for that purpose only since i trust your exceptional abilities in this field.
It might be an idiotic question (i am not so good with this stuff) but it wouldn't be possible to connect with your board via Bluetooth to the stock android app or?
What i am looking for is on one side intelligent automated control of my active balancer + still being able to do the same things (monitor and change settings) i can do now via the phone xiauxiang app without having to rely on a computer r pi or wifi.
Could your board somehow share the UART with the Bluetooth adapter? 😁 Guess not..

If you want to use bluetooth you would probably want to use the ESP32 - you might look previously in this thread as shadowsteve has already done this. Using the ESP32 it would be pretty easy to control it via an android app. There are a ton of vids on youtube showing how to control a relay (to turn the active balancer on/off) with the ESP32.
 

Visusolar

Explorer
Joined
Dec 6, 2020
Messages
283
If you want to use bluetooth you would probably want to use the ESP32 - you might look previously in this thread as shadowsteve has already done this. Using the ESP32 it would be pretty easy to control it via an android app. There are a ton of vids on youtube showing how to control a relay (to turn the active balancer on/off) with the ESP32.
Excellent, thank you so much for showing the path to cater my unique needs! Will search for what you suggested. Sounds very promising, esp32 2in1, intelligent relay control through monitoring actual cell voltage as well preserving normal offline functionality.
 

melkier

Solar Addict
Joined
Jul 24, 2020
Messages
125
Great news thanks! Previously i couldn't connect my WeMos with a hotspot, seems like they added that functionality in some recent releases.

Something to consider: I set my phone hotspot to 2.4Ghz. It will definitely not work if your hotspot is in 5Ghz mode.
 

drbytes

Solar Enthusiast
Joined
Oct 21, 2021
Messages
105
Awesome thread.
If this works it will help mitigate the problem I have with my bms; they shipped me a version with no RS485 support. Which I really wanted so I can ingest the data. Been stuck with the dumb bluetooth app so far.

I'm trying to hook it up with a nodemcu and a voltage reg outputting 3.3v. No dice so far. Even with the UART pins swapped, and reversed rx/tx for good measure.

I'll tinker with it some more later
 
Last edited:

shadowsteve

Solar Addict
Joined
Feb 11, 2021
Messages
250
Awesome thread.
If this works it will help mitigate the problem I have with my bms; they shipped me a version with no RS485 support. Which I really wanted so I can ingest the data. Been stuck with the dumb bluetooth app so far.

I'm trying to hook it up with a nodemcu and a voltage reg outputting 3.3v. No dice so far. Even with the UART pins swapped, and reversed rx/tx for good measure.

I'll tinker with it some more later
Are you using the esp8266 or esp32 based units? I have esp32's talking to my JBD bms's and sending data via MQTT over wifi and it works well. I couldn't get the comms to work reliably with ESP01 (esp8266) boards
 

drbytes

Solar Enthusiast
Joined
Oct 21, 2021
Messages
105
I'm using the esp8266 unit. I'll have a look for a esp32 unit. Thx for the tip

---

I have a raspberry pi next to the batteries to monitor all kinds of related thing and I decided to enable the onboard uart and open up ttyS0. Lo and behold I can talk to the "dumb" bms now.
Excellent, that resolves my problem.
 
Last edited:

daklein

Solar Enthusiast
Joined
May 8, 2020
Messages
96
Thanks @melkier, I've been using this for a while now, generally working very well. I have two 10s packs in a lawn tractor and used as a powerwall when parked. I have 4 14s packs running also with jbd BMSs and maybe a 5th soon, but so far just using the pack voltage from solar charge controller to start & stop discharging. I haven't set up the wifi dongles yet, I think I need to supply a more solid 12v than each BMS does, so I'll make a harness for that.

I have jbdtool started on the RPi from a shell script that starts on bootup from a systemd service. The shell script runs two separate jbdtool instances in the background, and my controls get the data from mqtt. On the RPi in node-red, I have watchdog timers on all the sources of data (jbd BMSs, SMA inverters CAN & rs485, Midnite charge controller, enphase envoy), and if any of the data goes missing for too long, it stops charging or discharging the lithium packs.

printf "\n%s\n" "Starting JBD BMS mqtt reader instances, for each BMS, multiple in background"
jbdtool -t ip:192.168.15.34,23 -i 180 -m 192.168.15.15:BMS_ETR:JBD_ET_rear:mqtt_user:mqtt_user_pw &
sleep 2
jbdtool -t ip:192.168.15.35,23 -i 181 -m 192.168.15.15:BMS_ETF:JBD_ET_front:mqtt_user:mqtt_user_pw &

On the tractor, whenever it leaves the garage, the jbdtool script stops when the wifi dongle goes away out of range. I need to restart them manually each time. (I do the above at cmd line)

What's a good way to make it either restart automatically, or not give up when the serial link is lost?

Maybe a shell script that pings each BMS ip address first, until it gets a ping back, then run the jbdtool as is (repeating). In node-red, if the BMS data has gone away, it could run that shell script again.

Reading through this whole thread now, hah, this may be useful to run it in a docker container. https://github.com/gabrielpc1190/jbdtool If you're still here @gabrielpc1190, how did you make it into a docker container?
 
Last edited:

daklein

Solar Enthusiast
Joined
May 8, 2020
Messages
96
Hah! I figured out how to use an exec node in node-red, to run a script if the BMS watchdog timer trips. The jbdtool processes are still started when the RPi starts as before, but now there's another script which node-red kicks off if there is no BMS data coming through. The script first pings each one, then checks if jbdtool is already running for that bms, and starts it if not. It will continue until jbdtool is running for each bms.

So far it worked when I tested by unplugging the wifi dongle from one of them, and kept trying until it was on the network again, restarted jbdtool and exited. Now I'll go mow with the tractor and see if it just automagically recovers again.

Code:
pi@sma-rpi:~ $ more jbd_poll_et.sh
#!/usr/bin/bash                                                                           
                                                                                          
# list of bms ipaddress, clientid and topic, indexed starting at 0                         
declare -a ipa=("192.168.15.34" "192.168.15.35")                                           
declare -a cli=("BMS_ETR"       "BMS_ETF")                                                 
declare -a top=("JBD_ET_rear"   "JBD_ET_front")

until [[ $j -gt 1 ]]   # num of BMS to check, 0 1 2...
do
        j=0   # reset each time
        for i in 0 1   # loop through all BMS
        do               # first ping
        printf '%s' "pinging bms at " "${ipa[$i]}"
        printf '\n'
        if [[ $(ping -c 3 "${ipa[$i]}" | grep "3 received") ]]
        then                # if good ping, then check for jbdtool running
                echo "$i"
                echo "${ipa[$i]}  ${cli[$i]}  ${top[$i]}"
                printf '%s' "checking for jbdtool polling bms at " "${ipa[$i]}"
                printf '\n'
                if [[ $(ps -ef | grep jbd | grep "${ipa[$i]}") ]]
                then         # jbdtool already running for this one
                        sleep 1
                        printf '%s' " jbdtool already polling " "${cli[$i]}"
                        printf '\n'
                        ps -ef | grep jbd | grep "${ipa[$i]}"
                        sleep 2
                        ((j++))   # number already running, exit if all are done
                else         #  or need to start it
                        sleep 1
                        printf '%s' " starting jbdtool for " "${cli[$i]}"
                        printf '\n'
                        jbdtool -t ip:"${ipa[$i]}",23 -i 180 -m 192.168.15.15:"${cli[$i]}":
"${top[$i]}":mqtt_user:mqtt_user_pw &
                        sleep 2
                        ps -ef | grep jbd | grep "${ipa[$i]}"
                fi
                echo "done, $j BMS successfully polling"
        else
                echo "done, only $j BMS pinging"
        fi
        done
done

exit                                                                                       
pi@sma-rpi:~ $
 

daklein

Solar Enthusiast
Joined
May 8, 2020
Messages
96
I have some JBD bms's that I wanted to use esp-link on. I purchased several esp-01s modules. Doesn't matter what version of esp-link I try to program on the devices, they all reset after starting the dhcp server.

I'm using a 10A 3.3V regulated supply so it's not a power issue.

Can anyone offer some suggestion that I've not tried?

Thanks in advance.
@billh1986 Solved this? I would check where the power supply is coming from: from the +12 on the UART connector? or battery pos? Some of the BMSs may not have quite enough power output on that '12v' line on the UART. 2 of my BMS work just fine, others are sketchy and don't work consistently. If the 3.3v converter and ESP are powered from another power source, then it might work fine.

I'm just getting back to setting up 4 other packs with communication, and I'm powering them from a little bigger DCDC '10A' converter from the ~58v battery bus down to 12v, then that 12v to each of the ESP-01 wifi dongles. The '12v' line from the BMS UART will not be used, and the UART ground will be common between all 4 BMSs.
 

pacman

New Member
Joined
Jan 24, 2022
Messages
28
Hi dear Melkier,
I finally moved to a 64 bit OS for the PI 4B i use.
Where can I download a static 64 bit latest version, please (with the MQTT ver.3)? I am a dumb linux user so unable to compile by myself. 🤷‍♂️

Thanks in advance
 
Last edited:

pacman

New Member
Joined
Jan 24, 2022
Messages
28
Hello all,
since I believe our dear Melkier is propably on holydays ;) I am trying to get some progress on my own.
I run a Raspberry 4B 8 GB with OpenPlotter3 a derived OS based on 64 bit Debian Bullseye.
I made the following steps, but I get an error message when it comes to the "make" command, if I compile with static=yes:

sudo apt-get install libssl-dev
git clone https://github.com/sshoecraft/jbdtool.git
cd jbdtool
git clone https://github.com/eclipse/paho.mqtt.c.git
cd paho.mqtt.c
make
sudo make install
cd ..
modified Makefile to:
DEBUG=no
BLUETOOTH=no
MQTT=yes
STATIC=yes
modified mqtt.c to:
#define MQTT_3 0
make
sudo make install

the error I get at the jbdtool "make" command is: /usr/bin/ld: cannot find -lpaho-mqtt3c
and I am wondering how to fix it with no success until now

Thanks in advance
 
Last edited:

daklein

Solar Enthusiast
Joined
May 8, 2020
Messages
96
I run a Raspberry 4B 8 GB with OpenPlotter3 a derived OS based on 64 bit Debian Bullseye.
I get an error message when it comes to the "make" command, if I compile with static=yes:

the error I get at the jbdtool "make" command is: /usr/bin/ld: cannot find -lpaho-mqtt3c
Maybe it's the 64b os, and paho mqtt not set up for 64bit? Just a guess. Maybe the paho makefile needs to be adjusted. Maybe see if there's a different version of it that would work, or ask at the paho github page? https://github.com/eclipse/paho.mqtt.c/releases
 

pacman

New Member
Joined
Jan 24, 2022
Messages
28
Maybe it's the 64b os, and paho mqtt not set up for 64bit? Just a guess. Maybe the paho makefile needs to be adjusted. Maybe see if there's a different version of it that would work, or ask at the paho github page? https://github.com/eclipse/paho.mqtt.c/releases
Thanks for taking the time to answer Daklein, the fact is that as I wrote, I am a complete dumb on linux and It is really hard for me to get my head on this things.
Anyway, if I compile not statically all is working fine; if I compile statically there is the error (so I guess that paho is fine with the 64 bit).
 

justgary

Solar Addict
Joined
Jan 1, 2022
Messages
365
It has been quite a while for me, but as I recall you can't link a static object against a reloadable library. You need to find or compile a static version of the missing library.
 
Joined
Nov 30, 2019
Messages
12,485
Thanks for taking the time to answer Daklein, the fact is that as I wrote, I am a complete dumb on linux and It is really hard for me to get my head on this things.
Anyway, if I compile not statically all is working fine; if I compile statically there is the error (so I guess that paho is fine with the 64 bit).
Why do you want to compile with encapsulated libraries?
 

pacman

New Member
Joined
Jan 24, 2022
Messages
28
Why do you want to compile with encapsulated libraries?
Because I have a test pi and a production one, and I would like to keep the production one as light and clean as possible.
Melkier has several times posted the tool statically linked.
As said I am a dumb one on Linux :confused:, would you mind helping on how to compile encapsulating, please? 🙏
 
Joined
Nov 30, 2019
Messages
12,485
Because I have a test pi and a production one, and I would like to keep the production one as light and clean as possible.
Melkier has several times posted the tool statically linked.
As said I am a dumb one on Linux :confused:, would you mind helping on how to compile encapsulating, please? 🙏
Do you need MQTT?
If not make a safety copy of your Makefile and change
MQTT=yes to MQTT=no
see if you get further
 
Last edited:
Top