# mau-lima/esp32-bike-powermeter architecture

> Architecture diagram of the GitHub repository mau-lima/esp32-bike-powermeter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mau-lima/esp32-bike-powermeter
- Repository: https://github.com/mau-lima/esp32-bike-powermeter

## Overview

This ESP32 proof of concept advertises as a bicycle power meter, reads an HX711 load cell, and sends BLE power-characteristic debug values plus simulated crank cadence data. The principal workflow runs through firmware setup and its loop, then the BLE service implementation, which notifies connected bike apps. The README also describes standards-compliant phone-app visibility; sampled source shows the BLE services and notifications. Hardware and BLE-library behavior are external dependencies, so their internal details are not represented.

Main entry points: [`src/main.cpp`](https://github.com/mau-lima/esp32-bike-powermeter/blob/master/src/main.cpp) (Setup and loop), [`src/BLEPowerCSC.cpp`](https://github.com/mau-lima/esp32-bike-powermeter/blob/master/src/BLEPowerCSC.cpp) (Cycling power service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_firmware["Firmware workflow"]
  node_main["Setup and loop<br/>[main.cpp]"]
  node_state["Connection flags<br/>[main.cpp]"]
end

subgraph group_ble["BLE services"]
  node_blepower["Cycling power service<br/>[BLEPowerCSC.cpp]"]
  node_csc["Crank cadence service<br/>[BLEPowerCSC.cpp]"]
end

node_app(("Bike app"))
node_hx711{{"HX711 load cell"}}
node_blelib["ESP32 BLE stack"]

node_main -->|"initializes"| node_blepower
node_main -->|"reads samples"| node_hx711
node_main -->|"sends debug value"| node_blepower
node_main -->|"sends cadence"| node_csc
node_blepower -->|"creates services"| node_blelib
node_blepower -->|"updates connection"| node_state
node_main -->|"checks connection"| node_state
node_main -->|"restarts advertising"| node_blepower
node_blepower -->|"notifies power"| node_app
node_csc -->|"notifies cadence"| node_app

click node_main "https://github.com/mau-lima/esp32-bike-powermeter/blob/master/src/main.cpp"
click node_state "https://github.com/mau-lima/esp32-bike-powermeter/blob/master/src/main.cpp"
click node_blepower "https://github.com/mau-lima/esp32-bike-powermeter/blob/master/src/BLEPowerCSC.cpp"
click node_csc "https://github.com/mau-lima/esp32-bike-powermeter/blob/master/src/BLEPowerCSC.cpp"

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_main,node_state toneBlue
class node_blepower,node_csc toneAmber
class node_app,node_hx711,node_blelib toneIndigo
```

## Components

### Firmware workflow

- [Setup and loop](https://github.com/mau-lima/esp32-bike-powermeter/blob/master/src/main.cpp): `src/main.cpp`
- [Connection flags](https://github.com/mau-lima/esp32-bike-powermeter/blob/master/src/main.cpp): `src/main.cpp`

### BLE services

- [Cycling power service](https://github.com/mau-lima/esp32-bike-powermeter/blob/master/src/BLEPowerCSC.cpp): `src/BLEPowerCSC.cpp`
- [Crank cadence service](https://github.com/mau-lima/esp32-bike-powermeter/blob/master/src/BLEPowerCSC.cpp): `src/BLEPowerCSC.cpp`

### Other components

- **Bike app**
- **HX711 load cell**
- **ESP32 BLE stack**

## Connections

- Setup and loop → Cycling power service: initializes (evidence: `src/main.cpp`)
- Setup and loop → HX711 load cell: reads samples (evidence: `src/main.cpp`)
- Setup and loop → Cycling power service: sends debug value (evidence: `src/main.cpp`)
- Setup and loop → Crank cadence service: sends cadence (evidence: `src/main.cpp`)
- Cycling power service → ESP32 BLE stack: creates services (evidence: `src/BLEPowerCSC.cpp`)
- Cycling power service → Connection flags: updates connection (evidence: `src/BLEPowerCSC.cpp`)
- Setup and loop → Connection flags: checks connection (evidence: `src/main.cpp`)
- Setup and loop → Cycling power service: restarts advertising (evidence: `src/main.cpp`)
- Cycling power service → Bike app: notifies power (evidence: `src/BLEPowerCSC.cpp`)
- Crank cadence service → Bike app: notifies cadence (evidence: `src/BLEPowerCSC.cpp`)
