# mnh-jansson/open-battery-information architecture

> Architecture diagram of the GitHub repository mnh-jansson/open-battery-information, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mnh-jansson/open-battery-information
- Repository: https://github.com/mnh-jansson/open-battery-information

## Overview

This repository now contains the Arduino firmware for Open Battery Information; the browser UI is maintained separately. The main workflow is for the OBI-1 web tool to send a serial request, have the firmware issue the corresponding Makita battery command over 1-Wire, and return response bytes for the tool to display as battery information. The sampled source shows the serial dispatcher and bus operations; README documents the reported battery fields, but their decoding is outside this repository’s sampled firmware. The firmware’s board-specific GPIO layer is included; other product wiring is not inferred.

Main entry points: [`ArduinoOBI/src/main.cpp`](https://github.com/mnh-jansson/open-battery-information/blob/main/ArduinoOBI/src/main.cpp) (Serial command firmware), [`ArduinoOBI/lib/OneWire/OneWire2.cpp`](https://github.com/mnh-jansson/open-battery-information/blob/main/ArduinoOBI/lib/OneWire/OneWire2.cpp) (OneWire protocol library), [`ArduinoOBI/lib/OneWire/util/OneWire_direct_gpio.h`](https://github.com/mnh-jansson/open-battery-information/blob/main/ArduinoOBI/lib/OneWire/util/OneWire_direct_gpio.h) (Board GPIO access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Serial interface"]
  node_firmware_main["Serial command firmware<br/>[main.cpp]"]
end

subgraph group_firmware["Battery firmware"]
end

subgraph group_bus["1-Wire bus"]
  node_onewire_lib["OneWire protocol library<br/>[OneWire2.cpp]"]
  node_gpio["Board GPIO access"]
end

node_operator(("Battery repairer"))
node_obi_tool(("OBI-1 web tool"))
node_battery["Makita battery"]

node_operator -->|"requests battery read"| node_obi_tool
node_obi_tool -->|"sends serial command"| node_firmware_main
node_firmware_main -->|"issues bus operations"| node_onewire_lib
node_onewire_lib -->|"toggles bus pin"| node_gpio
node_onewire_lib -->|"exchanges 1-Wire bytes"| node_battery
node_firmware_main -->|"returns serial response"| node_obi_tool

click node_firmware_main "https://github.com/mnh-jansson/open-battery-information/blob/main/ArduinoOBI/src/main.cpp"
click node_onewire_lib "https://github.com/mnh-jansson/open-battery-information/blob/main/ArduinoOBI/lib/OneWire/OneWire2.cpp"
click node_gpio "https://github.com/mnh-jansson/open-battery-information/blob/main/ArduinoOBI/lib/OneWire/util/OneWire_direct_gpio.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_firmware_main toneBlue
class node_onewire_lib,node_gpio toneMint
class node_operator,node_obi_tool,node_battery toneIndigo
```

## Components

### Serial interface

- [Serial command firmware](https://github.com/mnh-jansson/open-battery-information/blob/main/ArduinoOBI/src/main.cpp): `ArduinoOBI/src/main.cpp`

### 1-Wire bus

- [OneWire protocol library](https://github.com/mnh-jansson/open-battery-information/blob/main/ArduinoOBI/lib/OneWire/OneWire2.cpp): `ArduinoOBI/lib/OneWire/OneWire2.cpp`
- [Board GPIO access](https://github.com/mnh-jansson/open-battery-information/blob/main/ArduinoOBI/lib/OneWire/util/OneWire_direct_gpio.h): `ArduinoOBI/lib/OneWire/util/OneWire_direct_gpio.h`

### Other components

- **Battery repairer**
- **OBI-1 web tool**
- **Makita battery**

## Connections

- Battery repairer → OBI-1 web tool: requests battery read
- OBI-1 web tool → Serial command firmware: sends serial command
- Serial command firmware → OneWire protocol library: issues bus operations
- OneWire protocol library → Board GPIO access: toggles bus pin
- OneWire protocol library → Makita battery: exchanges 1-Wire bytes
- Serial command firmware → OBI-1 web tool: returns serial response
