Skip to content
This repository was archived by the owner on Oct 14, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 96 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,99 @@
# BTWifiModule
Frsky Bluetooth Emulator

This code is for use on a ESP Wroom 32, it emulates a FRSky Bluetooth module but with way more future possibilities.
FrSky Bluetooth emulator for ESP32, to be used inside an OpenTX/EdgeTX radio.
It emulates a FrSky Bluetooth module and adds **Bluetooth telemetry**
(S.Port and CRSF), **auto-connect** and a **selectable BLE host**
(Bluedroid or NimBLE).

## Documentation for this project is at Git Book
### https://btwifimod.gitbook.io/
Based on the community project by **dlktdr**
(https://github.com/dlktdr/BTWifiModule).
Documentation: https://btwifimod.gitbook.io/

## Features

| Feature | Status |
|---|---|
| Bluetooth Trainer — Master Mode (connect to a BLE trainer / headtracker) | Supported |
| Bluetooth Trainer — Slave Mode | Supported |
| Bluetooth Telemetry over BLE | Supported |
| — S.Port (FrSky models) | Supported |
| — CRSF (ELRS models) | Supported |
| Auto-connect to the last known device | Supported |
| Device name from `AT+NAME` (persisted and advertised) | Supported |
| Selectable BLE host: Bluedroid or NimBLE | Supported |

## How telemetry works

In *Telemetry* mode EdgeTX forwards the radio's telemetry over the BT serial
link. The module passes those bytes to the connected BLE central unchanged:

- FrSky models: S.Port frames, `0x7E`-delimited and byte-stuffed.
- ELRS/CRSF models: raw CRSF frames.

The client app auto-detects the protocol, so both work over the same GATT
service (`0xFFF0`, characteristic `0xFFF6`, NOTIFY).

## Telemetry app

- S.Port: **INAV / Telemetry Viewer**.
- CRSF: the maintained fork by **RomanLut**
(https://github.com/RomanLut/android-taranis-smartport-telemetry/releases),
which publishes ready-made APKs with CRSF support.

## Hardware

- **ESP32-C3 SuperMini** (primary target); other boards are listed in
`platformio.ini`.
- UART to the radio: **GPIO20 (RX) / GPIO21 (TX)** on the C3 SuperMini.
- **Radiomaster TX16S MK3** with **EdgeTX** (a recent nightly is recommended,
see below).

> **TX16S MK3 note.** EdgeTX needs PR #7855
> (`BT_PWR_GPIO = PC13` in `targets/tx16smk3/hal.h`) to power the AUX2/BT
> connector. It is included in current nightlies.

## Building

PlatformIO (ESP-IDF). Two BLE hosts are selectable:

| Environment | BLE host | Flash (C3, 1 MB app) | Notes |
|---|---|---|---|
| `C3SuperMini` | Bluedroid (default) | ~84 % | |
| `C3SuperMini_nimble` | NimBLE | ~52 % | smaller footprint, recommended |

```bash
pio run -e C3SuperMini -t upload # Bluedroid
pio run -e C3SuperMini_nimble -t upload # NimBLE
```

The Bluedroid path is kept behind `#if !defined(USE_NIMBLE)`, so both hosts
share the same application code.

## AT command set

The module speaks the same AT protocol EdgeTX uses for the FrSky Bluetooth
module:

| Command | Meaning |
|---|---|
| `AT+BAUD4` | baud rate (this firmware stays at 115200) |
| `AT+NAME<name>` | set the Bluetooth name (persisted and advertised) |
| `AT+TXPW<n>` | TX power (acknowledged) |
| `AT+ROLE0` | Peripheral (telemetry / trainer slave) |
| `AT+ROLE1` | Central (trainer master) |
| `AT+DISC?` | start a scan (central) |
| `AT+CON<addr>` | connect to a device (central) |
| `AT+CLEAR` | forget the saved device |
| `AT+HTRESET` | reset the headtracker (BTWifiModule extension) |

Responses: `OK+...`, `Central:<addr>`, `Peripheral:<addr>`, `Connected:<addr>`,
`DisConnected`, `ERROR`.

## Branches

- `1.0-dev` — consolidated development branch (this one).

## Credits

Original project: **dlktdr/BTWifiModule**. Bluetooth telemetry, auto-connect,
the CRSF passthrough and the NimBLE port by this fork.
22 changes: 20 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
; https://docs.platformio.org/page/projectconf.html

[platformio]
default_envs = C3Mini
default_envs = C3SuperMini

[env]
platform = espressif32
platform = espressif32@6.7.0
framework = espidf
build_unflags = -Werror=all

Expand Down Expand Up @@ -131,3 +131,21 @@ build_flags =
-DCPU_ESP32=y
-DBLUETOOTH=y
-DBLUETOOTH5=y

; NimBLE experiment build (same board, NimBLE host instead of Bluedroid)
[env:C3SuperMini_nimble]
board_build.flash_mode: dio
board = esp32-c3-devkitm-1
board_build.esp-idf.sdkconfig_path = sdkconfig.C3SuperMini_nimble
upload_protocol = esptool
build_type = debug
monitor_speed = 115200
upload_port = COM9
monitor_port = COM9
build_flags =
-DRTOS_FREERTOS=y
-DPCB_C3SUPERMINI=y
-DCPU_ESP32=y
-DBLUETOOTH=y
-DBLUETOOTH5=y
-DUSE_NIMBLE=y
Loading