MustafaMulla29/bluetooth-connected-pedometer
It defines a PCB footprint and schematic symbol for a row of solder pads used as wire connection points, featuring customizable spacing and label annotations.
- Version
- 0.3.0
- License
- unset
- Stars
- 0
Use with the tscircuit CLI
tsci is the tscircuit CLI. Install it with npm install -g tscircuit.
tsci clone MustafaMulla29/bluetooth-connected-pedometer # download the package files into ./bluetooth-connected-pedometer
tsci add MustafaMulla29/bluetooth-connected-pedometer # add it to your project as @tsci/MustafaMulla29.bluetooth-connected-pedometerIn a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.
firmware/README.md
# Firmware integration and bring-up
`board_config.h` is a verified pin/register contract, not a complete flashable application. Integrate it into a CC2340R5 SimpleLink Low Power F3 SDK project using TI's power-aware drivers and SysConfig. BLE stack integration, a phone UI, production firmware and measured hardware validation are outside the supplied PCB build.
## Boot sequence
1. Use the RF-star RF-BM-2340B1 hardware configuration for CC2340R5. The module includes its 48 MHz clock and RF matching. Its standard assembly omits the external 32.768 kHz crystal: select the internal LF RC oscillator in SysConfig, as specified in section 4 of the module data sheet. Enable the matching TI power-driver calibration behavior and check BLE timing across temperature. Use the module's DCDC configuration; the host board no longer carries the bare-chip DCDC network. SWDIO and SWCLK connect directly to J5 with no external bias resistors; preserve TI's debug-port configuration while the probe is attached.
2. Drive OLED_EN low and park OLED_SDA/OLED_SCL low with internal pull-ups disabled. R1 holds the display switch off during reset. The OLED supply is controlled by TPS22917, independently of the charger.
3. Enable the CC2340R5 internal pull-ups on DIO13/CHG_INT_N and DIO11/CHG_PG_N before sampling the charger's open-drain outputs; this revision has no external R3/R4 pull-ups. Then read BQ25186 at 7-bit address `0x6A`; `(MASK_ID at 0x0C) & 0x0F` must equal `0x01`. Use bounded I²C retries and preserve unrelated register bits. The old BQ25150 address and register map do not apply to Rev E.
4. Set ICHG_CTRL bit 7 to disable charging while configuring. Select VBAT_CTRL `0x46` (4.20 V), ICHG_CTRL `0x94` (25 mA with charge disabled), and CHARGECTRL0 `0x64` (2.5 mA precharge, 10% termination, 4.5 V input DPM, 100 °C die thermal regulation). Keep IC_CTRL.TS_EN enabled and preserve the safety timer. Read back the settings and fault flags, then write ICHG_CTRL `0x14` only after verification. The reset charge setting is 10 mA. The 100 °C setting is chip thermal regulation, not the allowed cell temperature; the cell NTC provides independent hot/cold protection.
5. Bound all firmware charge-current requests to 25 mA for the selected cell. This charger has no external IMAX code-limiting resistor. Never reuse the old BQ25150 RANGE/LDO/LP writes. Use a protected 100 mAh cell rated for at least 50 mA charging and validate its NTC thresholds. A held SW2 pulls TS/MR low and suspends charging until release; it also handles the configured ship/reset gesture.
6. Read BMA400 chip ID and configure Bosch's official SensorAPI for normal-mode step counting with the recommended ODR/filter settings. The low-power wake-only mode is not a replacement for the step-counter operating mode. Enable a latched activity/step interrupt as appropriate; prefer periodic counter reads and coarse event batching to waking the MCU for every step.
7. Configure BQ27427 for the exact cell's chemistry, 100 mAh design capacity, design energy, taper rate and terminate voltage according to its technical reference manual. Follow config-update/unseal/checksum procedures; do not guess a chemistry profile. Preserve the integrated sense-resistor configuration. Let the gauge sleep between reads; repeated polling can defeat the battery target. Recover inadvertent shutdown using open-drain GPOUT control.
8. Start BLE advertising around 1–2 s intervals, with short fast-advertising windows for pairing. Start with 0 dBm transmit power. Use a slow connection interval/slave latency when allowed by the central. Publish accumulated steps and battery percent; continuous streaming is unnecessary.
## Display transaction
Check pack voltage and charger status first. The regulator is an LDO; OLED_VCC can droop below 3.3 V at low battery voltage. Keep the OLED off when the measured rail cannot meet its specification; the accelerometer and MCU can continue counting. An initial conservative battery threshold is 3.5 V; characterize it under OLED load.
Raise OLED_EN and wait at least 10 ms before releasing the software I²C lines. C18 is a 1 nF slew-rate capacitor from TPS22917 CT to VIN; the supply rise must be measured with the actual module. Initialize SSD1306 for **128×32**, its internal charge pump, address `0x3C`, and modest contrast. It has a 512-byte framebuffer. Adafruit 4440 includes auto-reset circuitry.
After five seconds, send display-off, issue STOP, park both display pins low, then drive OLED_EN low. TPS22917 discharges OLED_VCC through its QOD connection. Do not pull the display bus up to V3V3 or allow a fixture to feed the switched rail. Check startup current and total capacitance against the 200 mA logic regulator rating.
## Data and BLE behavior
Read the 24-bit BMA400 step count atomically. Accumulate unsigned modulo-24-bit deltas, treating sensor reset separately from wraparound. Retain daily totals with wear-limited flash journaling and a validity/CRC marker; never write flash on every step. Have the phone set UTC/timezone policy for day rollover. Use standard Battery Service (`0x180F`, Battery Level `0x2A19`) and a documented custom read/notify characteristic for a 32-bit daily step count. Pair/bond if step history or user identity is retained.
## Bench checks
- First power from a current-limited 5 V bench source with **battery and OLED disconnected**; verify VCHG, VSYS, 3.3 V, and reset.
- Program through J5 with a VTref-sensing 3.3 V-compatible SWD probe. Test I²C addresses and the module clock start across supply and temperature.
- Validate charger voltage/current and hot/cold NTC behavior with an appropriate battery simulator before attaching a real protected cell. NTC must be thermally coupled to the cell.
- Confirm the fuel gauge reports discharge and charge with the correct signs and that no fixture bypasses BAT→SRX.
- Measure battery input current with SWD unplugged: sleep, step counting, advertising, connection events, display startup/on/off, charging and ship mode. Test several display patterns.
- Compare accumulated steps against counted walking/running trials, inactivity, vehicle travel, and pocket/wrist placement; tune filtering based on results.
- Check the module antenna performance in the actual enclosure, near the body and battery. Validate harmonics and oscillator error before manufacturing release.
Register and power-switch references: [BQ25186 data sheet](https://www.ti.com/lit/ds/symlink/bq25186.pdf), [TPS22917 data sheet](https://www.ti.com/lit/ds/symlink/tps22917.pdf).
The stock module may contain RF-star serial firmware. Flash a custom CC2340R5 application through J5; the preinstalled serial firmware does not implement this pedometer or its charging policy. Module pin numbers differ from the bare RKP package. Use the Rev E interface table and `board_config.h` together.