dorkhub

bm2-battery-monitor

Python connector and ESPHome template for Bluetooth based Battery Monitors - reverse engineering.

KrystianD
Python8416 forksMITupdated 1 year ago
git clone https://github.com/KrystianD/bm2-battery-monitor.gitKrystianD/bm2-battery-monitor

BM2 Battery Monitor

Result of my reverse engineering work on Bluetooth-based car battery monitor.

Battery Monitor 2 on Google Play

Content

bm2_python - Python client library

Supports the following API calls:

  • Reading current voltage - BM2Client.get_voltage()
  • Reading voltages history - BM2Client.get_history()

bm2_esphome - ESPHome template exposing current voltage

apps - Example applications

  • bm2_viewer.py - data viewer
  • bm2_history.py - history reader
  • bm2_mqtt.py - mqtt sender

Python library usage

import asyncio

from bm2.client import BM2Client

async def main():
    bm2 = BM2Client("B0:B1:xx:xx:xx:xx")
    bm2.start()
    
    # Read historical measurements
    history_readings = await bm2.get_history()
    
    for history_reading in history_readings:
        date_str = history_reading.date.strftime("%Y-%m-%d %H:%M:%S")
        print(f"{date_str} = {history_reading.voltage} V")

    # Read current voltage measurements
    while True:
        voltage = await bm2.get_voltage()
        print(voltage)

asyncio.run(main())

Example apps

Install dependencies from apps/requirements.txt - best in a virtualenv, then:

python apps/bm2_viewer.py --bm2-addr B0:B1:xx:xx:xx:xx

python apps/bm2_history.py --bm2-addr B0:B1:xx:xx:xx:xx

python apps/bm2_mqtt.py 
    --mqtt-host localhost \
    --mqtt-port 1883 \
    --mqtt-topic bm2 \
    --bm2-addr B0:B1:xx:xx:xx:xx

Reverse engineering

If you are curious on how I did the reverse engineering process, read here.

Keywords

BM2, Battery Monitor 2, com.dc.battery.monitor2, ICS Technology, Intelligent Control System

more like this

meine

meine 🌒 - A CLI file manager and system utility built with Textual. It combines intuitive command parsing with rich t…

Python50

taskbutler

Create and add progress bars, Office365 Files and Dropbox Paper papers by labels and link them to your Todoist tasks.

Python50

search

search projects, people, and tags