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

Gather all the parts
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"
2. Connections between "wrist_reg" and "ESP32"
3. Connections between "finger_bat" and "ESP32"
4. Connections between "finger_reg" and "ESP32"
5. Connections between "imu" and "ESP32"
6. Connections between "flex" and "ESP32"
7. Connections between "pulldown" and "ESP32"
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.




