[full walk through video coming soon]

HACKING THE B20 FITNESS TRACKER'S nRF52832 ARM CORTEX MCU AND ACCESSING ADS1292 BIOIMPEDENCE DATA

Hacking the fitness tracker is very simple, all you have to do is solder wires to four (V+, GND, clock, data) big test pads on the PCB and connect it to an SWD programmer. The process of setting the device up for programming is explained in detail in one of my past projects and also the README for the project GitHub repository. I have provided a variant file for using Sandeep's Arduino Core which automatically sets up the SPI connection for the ADS1292 ECG chip. The impetus for doing this whole project was requests for help hacking nRF52 Fitness Trackers with ECG (like the B20) from visitors to my "Hacking Wearables For Mental Health and More" project.

B20 ECG Fitness Tracker Disassembly & Programmer Wiring Video

The ADS1292 is part of a family of bioimpedence sensors from Texas Instruments built for a variety of applications including ECG, EMG and EEG. This series of chips includes the ADS1299 which has been used by OpenBCI, a well regarded open source EEG device platform. Although ADS1292 is designed for ECG, there is no particular reason it can't be used for playing with EEG or EMG. The amount of noise generated by the ADS1292 means picture perfect EEG wave visualizations are not on the menu, but differentiation between brain states (EEG) or muscle contractions (EMG) can be accomplished by applying even very messy data to a neural network.


I ran a workshop on hacking NeuroSky/Mattel EEG headsets at the 2018 NYC BrainHack hackathon. Mindlex is probably the most popular and well known (and old) straight up hardware hacking project in existence. Mindflex is human-computer interface hardware hacking 101. Isn't it ironic then that the core functionality of the Mindflex, the concentration/relaxation output actually used in the game, remains a black box? And that no one has bothered trying to replicate it in both form and function a la open source?

THE MISSION: Replicate the functionality of the NeuroSky module and Mindflex headset in open source style for less than the original Mindflex price (about $60).

CODE 

The emphasis of this project is code, both on the firmware end of things with Arduino code for processing ADS1292 data and the live web interface with data visualization and machine learning. You can try out all the features of the live web interface right now using the test data. There are several existing ADS1292 Arduino based projects that pipe raw data over a serial/USB connection into a desktop application for analysis: Protocentral's ECG Processing desktop application (I provide code for using their software) and  Bois083's EEG Lucid Dreaming Project which pipes data into BrainBay. Performance of the EEG glasses is a little better than NeuroSky's classic "Mind Flex" EEG headsets that have been a hacker favorite for years.

CODE FOR THE DEVICE

At a recent Hackathon (CMI's BrainHack) I lead a workshop on hacking the Mindflex toy EEG headset (NeuroSky EEG front end and processing unity). Neurosky provides intriguing "concentration" and "relaxation" values from its EEG module - essentially black box on-device brain state detection. So, I wanted to see if I could do the same thing myself with an ARM Cortex processor and the ADS1292 ECG front end. And I did! It took a lot of work, trial and error + magic numbers in my code. The essential components are FIR (Finite Impulse Response) filters which I use to isolate specific frequency bands (like EEG waves) and a standalone MLP (Multi Layer Perceptron) neural network which is trained on an external web application but runs entirely on the microcontroller one it is trained. Their is a cost to doing processing on the microcontroller: the signals are not nearly as clean or pretty as what you might see on an external application. However, they are clean enough to detect changes in mental concentration or muscle flexing which is pretty cool! 

Firmware examples can be found in the "B20-ECG-nrf52832-activity-tracker" directory in the project GitHub Repository. There are three examples:

  1. FIR Filter Example (primary)
  2. FFT Example (Adafruit recently released at FFT library that is optimized for ARM Cortex math!)
  3. Ported code for Protocentral's ADS1292 ECG visualization tool

CODE FOR THE VISUALIZATION & MACHINE LEARNING WEB APP

LINK TO EEG DATA VISUALIZATION, PROCESSING AND NEURAL NETWORK WEB APP (live with recorded data)

This web application processes, visualizes, and trains neural networks using EEG data. The EEG Glasses stream data into the site over Web Bluetooth BUT I recorded EEG data so you can use the site right now. To mess around EEG Glasses data go to the live site here: https://curtpw.github.io/web-bluetooth-eeg-neural-network/. Everything is written in front-end JavaScript on a GitHub page so it should be super easy to mess with.


EEG GLASSES


DETAILS

B20 ECG Fitness Tracker Specs:

B20 nRF52832 MCU Pinout