Week 7: Minimum Viable Product

Background

This week, after reviewing the possibilities, I switched from an EEG to heartrate monitor because of the ease of building. I use a heart rate monitor with a digital interface and bluetooth to create an "exercise-study" game.

Circuit

Project reference image 1 Project reference image 2
  
      #include 
      #include 
      #include 
      #include 
      #include 
      
      #define SERVICE_UUID        "12345678-1234-1234-1234-123456789abc"
      #define CHARACTERISTIC_UUID "abcdefab-1234-1234-1234-abcdefabcdef"
      
      const int PulseWire = D0;
      int Threshold = 550;
      
      PulseSensorPlayground pulseSensor;
      
      BLECharacteristic *pCharacteristic;
      bool deviceConnected = false;
      
      class MyServerCallbacks : public BLEServerCallbacks {
        void onConnect(BLEServer* pServer) {
          deviceConnected = true;
        }
        void onDisconnect(BLEServer* pServer) {
          deviceConnected = false;
        }
      };
      
      void setup() {
        Serial.begin(115200);
      
        // Pulse sensor
        pulseSensor.analogInput(PulseWire);
        pulseSensor.setThreshold(Threshold);
        pulseSensor.begin();
      
        // BLE setup
        BLEDevice::init("ESP32-Bagel");
        BLEServer *pServer = BLEDevice::createServer();
        pServer->setCallbacks(new MyServerCallbacks());
      
        BLEService *pService = pServer->createService(SERVICE_UUID);
      
        pCharacteristic = pService->createCharacteristic(
                            CHARACTERISTIC_UUID,
                            BLECharacteristic::PROPERTY_NOTIFY
                          );
      
        pService->start();
        pServer->getAdvertising()->start();
      
        Serial.println("BLE ready!");
      }
      
      void loop() {
        if (pulseSensor.sawStartOfBeat()) {
          int bpm = pulseSensor.getBeatsPerMinute();
          Serial.println(bpm);
      
          if (deviceConnected) {
            char buffer[8];
            sprintf(buffer, "%d", bpm);
            pCharacteristic->setValue(buffer);
            pCharacteristic->notify();
          }
        }
      }
  

The simple circuit has a heart rate pulse sensor (that I re-soldered for stability) that interfaces with my computer through bluetooth. Then a readout appears on the digital interface, using an initial arduino code that I modified from pulse playground.

Housing/Enclosure

Project reference image 1 Project reference image 2 Project reference image 2

I found box and lid files from the internet and modified it to have a hold I can thread the pulse sensor through to 3d print. First, though I wanted to test out the measurements on a basic laser cutter cut, so I printed this to test how well it fits in one's hand.

Download Box (w/ hole) File

Download Lid File

Digital Output

This is how the game works: 1) a question is shown (eventually planning to integrate an LLM to formulate questions), 2) two answers are shown, 3) to answer you must either do an exercise to raise heartrate or keep heartrate the same, 4) if you get it wrong it gets shuffled to the end of the queue.

Download HTML Game code

Oscilliscope

Project reference image 1 Project reference image 2

Before, the oscilliscope shows voltage/electricity taken from the air. Then, when I attatch the probes there is a constant, higher voltage, because this is a closed circuit.