Community project

BLE Wrist Gesture Logger

Photo of BLE Wrist Gesture Logger
Generated with AI

ddanielesmz

Published December 6, 2026

This project captures wrist and finger movements using Bluetooth Low Energy, logging gesture data from two ESP32-S3 boards equipped with an IMU and flex sensor. One board worn on the wrist streams accelerometer and gyroscope readings, while a finger-mounted board transmits flex sensor values. A stationary receiver connected to USB collects both data streams and records them with microsecond-level timestamps for later analysis.

The guide provides a complete wiring diagram showing how to connect the LSM6DSOX IMU and flex sensor to their respective ESP32 boards, a full parts list with power specifications, and the firmware needed to establish BLE advertising and scanning. Assembly steps cover powering each wearable independently with the LiPo battery and buck-boost regulator, then connecting the receiver to a computer for data logging.

Wiring diagram

Wiring diagram for BLE Wrist Gesture Logger
Loading diagram…

Gather all the parts

QtyComponent
1

ESP32-S3 DevKitC-1 N16R8 (wrist)

ESP32-S3 DevKitC-1 N16R8 (wrist)

1

LiPo 3.7V 1000mAh Battery

Protected single-cell LiPo

Single-cell LiPo pack, nominal 3.7 V, 1000 mAh. Default rechargeable choice for portable ESP32 / Pico projects. Pair with a TP4056 charger for safe USB recharging.

1

Pololu S13V25F3 3.3 V buck-boost

Pololu S13V25F3 3.3 V buck-boost

1

ESP32-S3 DevKitC-1 N16R8 (finger)

ESP32-S3 DevKitC-1 N16R8 (finger)

1

LiPo 3.7V 1000mAh Battery

Protected single-cell LiPo

Single-cell LiPo pack, nominal 3.7 V, 1000 mAh. Default rechargeable choice for portable ESP32 / Pico projects. Pair with a TP4056 charger for safe USB recharging.

1

Pololu S13V25F3 3.3 V buck-boost

Pololu S13V25F3 3.3 V buck-boost

1

Adafruit LSM6DSOX STEMMA QT (4438)

Adafruit LSM6DSOX STEMMA QT (4438)

1

SparkFun 2.2-inch flex sensor SEN-10264

SparkFun 2.2-inch flex sensor SEN-10264

1

Resistor

22 kΩ

Through-hole resistor (current-limiting in series with an LED)

Assemble it in 4 steps

1. Wire the wrist sensor

Connect an Adafruit STEMMA QT to header cable from the IMU to the wrist board. SDA goes to GPIO8, SCL to GPIO9, power to 3V3, and ground to GND.

2. Wire the finger divider

Connect one flex sensor lead to finger 3V3. Join the other lead and one 22 kΩ resistor lead at GPIO4. Connect the remaining resistor lead to finger GND. Secure the sensor base so it does not bend at the terminals.

3. Power the wearables separately

For each wearable, connect protected LiPo positive to its regulator VIN and negative to GND. Verify 3.3 V at VOUT with a meter before connecting VOUT to the board 3V3 and regulator GND to board GND. Leave EN open. Charge each cell separately with a compatible single-cell charger.

  • Disconnect the regulator output and ground before connecting USB to either wearable. Never connect a raw LiPo to 3V3. Check connector polarity before plugging in a battery.

4. Connect the receiver to USB

Use the USB-to-UART port on the third board. Wrist and finger broadcast independently to the receiver over BLE; there are no wires or shared grounds between boards.

Review all connections

1. Connections between "wrist_bat" and "ESP32"

Functionwrist_batESP32
power+V → Pololu S13V25F3 3.3 V buck-boost VINEXT
groundGND → Pololu S13V25F3 3.3 V buck-boost GNDEXT

2. Connections between "wrist_reg" and "ESP32"

Functionwrist_regESP32
groundGND → ESP32-S3 DevKitC-1 N16R8 (wrist) GNDEXT
powerVOUT → ESP32-S3 DevKitC-1 N16R8 (wrist) 3V3EXT

3. Connections between "finger_bat" and "ESP32"

Functionfinger_batESP32
power+V → Pololu S13V25F3 3.3 V buck-boost VINEXT
groundGND → Pololu S13V25F3 3.3 V buck-boost GNDEXT

4. Connections between "finger_reg" and "ESP32"

Functionfinger_regESP32
groundGND → ESP32-S3 DevKitC-1 N16R8 (finger) GNDEXT
powerVOUT → ESP32-S3 DevKitC-1 N16R8 (finger) 3V3EXT

5. Connections between "imu" and "ESP32"

FunctionimuESP32
powerVIN → ESP32-S3 DevKitC-1 N16R8 (wrist) 3V3EXT
groundGND → ESP32-S3 DevKitC-1 N16R8 (wrist) GNDEXT
i2cSDA → ESP32-S3 DevKitC-1 N16R8 (wrist) GPIO8EXT
i2cSCL → ESP32-S3 DevKitC-1 N16R8 (wrist) GPIO9EXT

6. Connections between "flex" and "ESP32"

FunctionflexESP32
analogP1 → ESP32-S3 DevKitC-1 N16R8 (finger) 3V3EXT
analogP2 → ESP32-S3 DevKitC-1 N16R8 (finger) GPIO4EXT

7. Connections between "pulldown" and "ESP32"

FunctionpulldownESP32
digitalP1 → ESP32-S3 DevKitC-1 N16R8 (finger) GPIO4EXT
digitalP2 → ESP32-S3 DevKitC-1 N16R8 (finger) GNDEXT

Deploy the firmware

#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_LSM6DSOX.h>
#include <BLEDevice.h>
#include <Preferences.h>
#include <esp_timer.h>
#include <string>

struct __attribute__((packed)) Frame {
  uint16_t company = 0xffff; // Internal prototype use only
  uint16_t magic = 0x504f;
  uint8_t role = 0;
  uint32_t seq = 0;
  uint32_t sample_us = 0;
  int16_t data[6] = {};
};
static_assert(sizeof(Frame)==25, "BLE payload size");
struct Record { int64_t rx; Frame f; };
QueueHandle_t records;
Preferences prefs;
Adafruit_LSM6DSOX imu;
Frame tx;
BLEAdvertising* adv;
BLEScan* scanner;
bool ready;

class Listener : public BLEAdvertisedDeviceCallbacks {
  void onResult(BLEAdvertisedDevice device) override {
    const int64_t rx = esp_timer_get_time();
    if (!device.haveManufacturerData()) return;
    auto bytes = device.getManufacturerData();
    Record r{};
    if (bytes.length()!=sizeof(r.f)) return;
    memcpy(&r.f, bytes.c_str(), sizeof(r.f));
    if (r.f.company!=0xffff || r.f.magic!=0x504f || r.f.role<1 || r.f.role>2) return;
    xQueueSend(records,&r,0);
  }
};
Listener listener;

void scanTask(void*) {
  for (;;) {
    scanner->start(1,false);
    scanner->clearResults();
  }
}

void publish() {
  BLEAdvertisementData packet;
  packet.setFlags(0x06);
  packet.setManufacturerData(String(reinterpret_cast<const char*>(&tx),sizeof(tx)));
  adv->stop();
  adv->setAdvertisementData(packet);
  adv->start();
}

void setup() {
  Serial.begin(115200);
  prefs.begin("polso",false);
  tx.role=prefs.getUChar("role",0);
  Serial.println("# Send w=wrist, f=finger, r=receiver. Role is saved and board restarts.");
  if (tx.role==1) {
    Wire.begin(8,9);
    ready=imu.begin_I2C(0x6a,&Wire);
    if (!ready) { Serial.println("# IMU missing at 0x6A; check QT wiring and reset."); return; }
  } else if (tx.role==2) {
    analogReadResolution(12);
  }
  BLEDevice::init("");
  if (tx.role==0) {
    records=xQueueCreate(64,sizeof(Record));
    scanner=BLEDevice::getScan();
    scanner->setAdvertisedDeviceCallbacks(&listener,true);
    scanner->setActiveScan(false);
    scanner->setInterval(80);
    scanner->setWindow(80);
    Serial.println("rx_us,node,seq,sample_us,ax_mm_s2,ay_mm_s2,az_mm_s2,gx_mrad_s,gy_mrad_s,gz_mrad_s,flex_raw");
    xTaskCreate(scanTask,"ble_scan",4096,nullptr,1,nullptr);
  } else {
    adv=BLEDevice::getAdvertising();
    adv->setScanResponse(false);
    adv->setMinInterval(160);
    adv->setMaxInterval(160);
  }
}

int16_t scaled(float value) {
  return static_cast<int16_t>(constrain(value*1000.0f,-32768.0f,32767.0f));
}
void loop() {
  while (Serial.available()) {
    int c=Serial.read();
    if (c=='w'||c=='f'||c=='r') {
      prefs.putUChar("role",c=='w'?1:c=='f'?2:0);
      ESP.restart();
    }
  }
  if (tx.role==0) {
    Record r;
    static uint32_t last[3] = {};
    static int64_t lastRx[3] = {};
    if (xQueueReceive(records,&r,pdMS_TO_TICKS(10))) {
      auto &f=r.f;
      if (lastRx[f.role] && f.seq==last[f.role] && r.rx-lastRx[f.role]<2000000) return;
      last[f.role]=f.seq;
      lastRx[f.role]=r.rx;
      Serial.printf("%lld,%s,%lu,%lu,",(long long)r.rx,f.role==1?"wrist":"finger",(unsigned long)f.seq,(unsigned long)f.sample_us);
      if (f.role==1) Serial.printf("%d,%d,%d,%d,%d,%d,\n",f.data[0],f.data[1],f.data[2],f.data[3],f.data[4],f.data[5]);
      else Serial.printf(",,,,,,%d\n",f.data[0]);
    }
  } else if (adv) {
    static uint32_t last=0;
    if (millis()-last>=250) {
      last=millis();
      tx.sample_us=micros();
      if (tx.role==1) {
        sensors_event_t a,g,t;
        imu.getEvent(&a,&g,&t);
        tx.data[0]=scaled(a.acceleration.x); tx.data[1]=scaled(a.acceleration.y); tx.data[2]=scaled(a.acceleration.z);
        tx.data[3]=scaled(g.gyro.x); tx.data[4]=scaled(g.gyro.y); tx.data[5]=scaled(g.gyro.z);
      } else tx.data[0]=analogRead(4);
      ++tx.seq;
      publish();
    }
  }
  delay(1);
}

Remix this project

Make it yours in one click

Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.

Open in Schematik