Firmware

The facebit firmware enables the device to monitor a wearer’s heart rate using BCG, their respiration rate via temperature or pressure fluctuations, and automatically detects whether the mask is off or on. It broadcasts this data over BLE to the facebit companion application.

View the Code on Github

int main() 
{
    _logger = Logger::get_instance();

#if defined(FACEBIT_SWO)
    _logger->initialize(&swo, TRACE_LEVEL);
#elif defined(FACEBIT_UART)
    _logger->initialize(&serial, TRACE_LEVEL);
#endif

    NRF_POWER->DCDCEN = 1;

    _logger->log(TRACE_DEBUG, "START");

    imu_int.rise(imu_int_handler);
 
    BusControl::get_instance()->init();

    thread1.start(blink);

    facebit.run();

    return 0;
}

Overview

In it’s current configuration, the firmware is always taking a measurement when the mask is on (this facilitated our experiments). It alternates between respiration rate and heart rate.

Every two minutes, the device broadcasts any valid measurements to the companion application and then does a hard reset. This is thanks to an ongoing bug in the bluetooth stack which doesn’t allow the device to go to sleep after it makes a bluetooth connection. This dramatically raises power consumption, so we’re forced to do this workaround until the issue is sorted out. After it’s fixed, we expect to maintain a BLE connection to the application whenever it’s within range and send updates in real time.