Skip to content

BeaverUI/ESP32-BluetoothBMS2MQTT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESP32-BluetoothBMS2MQTT

Use Releases (right side of this page) to download the latest version.

Connects to Xiaoxiang BMS (www.lithiumbatterypcb.com) via Bluetooth and sends its status to an MQTT server over WiFi.

This work is based on https://github.com/kolins-cz/Smart-BMS-Bluetooth-ESP32, with several enhancements/fixes:

  • various bugfixes and protocol improvements (fixes for memory leaks, reboots and reconnect problems)
  • more advanced timeout and connection-related features, saving energy of the BMS
  • added MQTT functionality
  • removed the display routines (uses MQTT instead)

Required stuff

Note: some ESP boards experience brownouts (resets) with this code due to the high consumption of WiFi + Bluetooth which causes power supply stability issues. This can be fixed by removing the diode that is in series with the USB connector, and adding a 220uF (or similar) electrolytic capacitor between +5V and GND, and another one between +3V3 and GND (these pins are typically available on the headers, so they are easy to add). When adding one, mind the polarity of the capacitor.

Programming the ESP

  • Install the Arduino IDE
  • Configure the IDE (see code for more info):
    • In preferences, add the board manager URL
    • Install the required libraries
  • Open main.ino
  • Configure the programmer:
    • Connect the ESP32 board via USB, select the correct COM port
    • See programmer-config.png for the other settings

Configuring

To configure the module, change the following in main.ino:

  • configure your MQTT server and set the node name
  • configure your WiFi (SSID + password)
  • program the code, check the MQTT messages for the correct BMS device name and device address
  • configure the BLE name and address to the detected BMS name and addres

Example output in Node-RED