chaitra deepika komatineni
Published © GPL3+

Smart Bra

A bra that can predict the date of your next menstruation, keep track of your vitals, and connect to other devices to respond to your body.

IntermediateProtip20 hours700

Things used in this project

Hardware components

NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
MAX30102 High-Sensitivity Pulse Oximeter and Heart-Rate Sensor for Wearable Health
Maxim Integrated MAX30102 High-Sensitivity Pulse Oximeter and Heart-Rate Sensor for Wearable Health
This component is ideal because of its accuracy and compact size.
×1
Felex Sensor
It was homemade.
×1
Resistor 221 ohm
Resistor 221 ohm
×1

Software apps and online services

Arduino IDE
Arduino IDE
Angular + Ionic
Used for the Demo app.
Proteus
Used for the simulation of MAX30102 with NodeMCU 09.v.
Fritzing
Used for the Schematic.

Story

Read more

Custom parts and enclosures

The Smart Bra

Schematics

Final Schematic

The image is the schematic of the entire hardware to be used. Due to the prevailing situation (Covid-19), components were either simulated using Proteus or were made at home.

Code

The Smart Bra

Arduino
The Code uses blynk app to test the data upload for ease of interface. In the future developments it will be using HTTP servers to establish communication between the app and the hardware.
Note: SPo2 is the amount of oxygen present in the blood.
This code is not the ideal code due to lack of resources and components.
#include <Wire.h>
#include "MAX30105.h"
#include "spo2_algorithm.h"
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

MAX30105 particleSensor;

#define MAX_BRIGHTNESS 255

#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__)
uint16_t irBuffer[100]; 
uint16_t redBuffer[100]; 
#else
uint32_t irBuffer[100]; 
uint32_t redBuffer[100];  
#endif

int32_t bufferLength; 
int32_t spo2;
int8_t validSPO2; 
int32_t heartRate; 
int8_t validHeartRate; 

byte pulseLED = 11; 
byte readLED = 13;

const int flexpin = D0; 
int flexarray[15];
//wifi credetials
char auth[] = "xxx";             
char ssid[] = "";
char pass[] = "";

//function to calculate avegare of flex values
int calcavgflex(int flexarray[]){
  float avgmin;
  long avgsum=0;
  for(int k=0;k<15; k++){
     avgsum+=flexarray[k];
     //Serial.println("\n");
     //Serial.print(avgsum);
     //Serial.println(" ");
  }
  avgmin=avgsum/15;
  return avgmin;
}
void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);

  pinMode(pulseLED, OUTPUT);
  pinMode(readLED, OUTPUT);

  // Initialize sensor
  if (!particleSensor.begin(Wire, I2C_SPEED_FAST))
  {
    Serial.println(F("MAX30105 was not found. Please check wiring/power."));
    while (1);
  }

  Serial.println(F("Attach sensor to finger with rubber band. Press any key to start conversion"));
  while (Serial.available() == 0) ;
  Serial.read();

  byte ledBrightness = 60; 
  byte sampleAverage = 4;
  byte ledMode = 2; 
  byte sampleRate = 100;
  int pulseWidth = 411;
  int adcRange = 4096;
  
  particleSensor.enableDIETEMPRDY(); 
  particleSensor.setup(ledBrightness, sampleAverage, ledMode, sampleRate, pulseWidth, adcRange);//calculates HR and SP02
}

void loop()
{
  bufferLength = 100; 
  static int i=0;
  static float avgflex=0;
  int flexposition; 
  Blynk.run();
  flexposition = analogRead(flexpin); 
  //Serial.print("\n sensorsize: "); 
  //Serial.print(flexposition); 
  delay(1000);
  //cup size moniter
     if(i<15){
      flexarray[i]=flexposition;    
    }
    while(i==15){
      avgflex=calcavgflex(flexarray);
      Serial.println("\nAvarage flex: ");
      Serial.print(avgflex);
      i=-1;
      break;
    }
  i++;
  Blynk.virtualWrite(V7, avgflex);
  //Read values
  for (byte i = 0 ; i < bufferLength ; i++)
  {
    while (particleSensor.available() == false) 
      particleSensor.check(); //Check the sensor for new data

    redBuffer[i] = particleSensor.getRed();
    irBuffer[i] = particleSensor.getIR();
    particleSensor.nextSample(); //We're finished with this sample so move to next sample

    Serial.print(F("red="));
    Serial.print(redBuffer[i], DEC);
    Serial.print(F(", ir="));
    Serial.println(irBuffer[i], DEC);
  }

  //calculate heart rate and SpO2 after 
  maxim_heart_rate_and_oxygen_saturation(irBuffer, bufferLength, redBuffer, &spo2, &validSPO2, &heartRate, &validHeartRate);


  while (1)
  {
    for (byte i = 25; i < 100; i++)
    {
      redBuffer[i - 25] = redBuffer[i];
      irBuffer[i - 25] = irBuffer[i];
    }

    //calculating the heart rate.
    for (byte i = 75; i < 100; i++)
    {
      while (particleSensor.available() == false)
        particleSensor.check();

      redBuffer[i] = particleSensor.getRed();
      irBuffer[i] = particleSensor.getIR();
      particleSensor.nextSample();

      
      float temperatureF = particleSensor.readTemperatureF();

      Serial.print(" temperatureF=");
      Serial.print(temperatureF, 4);

      Serial.print(F(", HR="));
      Serial.print(validHeartRate, DEC);

      Serial.print(F(", SPO2="));
      Serial.println(validSPO2, DEC);
    }

    //After gathering new samples recalculate HR and SP02
    maxim_heart_rate_and_oxygen_saturation(irBuffer, bufferLength, redBuffer, &spo2, &validSPO2, &heartRate, &validHeartRate);
  }
}

The Working code with only the flex sensor

Arduino
The NodeMCU calculates the average flex sensor value and transfers them to the blynk app. The app shows the Menstrual cycle using the flex values and other indicators as well.
 //CUP SIZE MONITER
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
const int flexpin = D0; 
int flexarray[15];

char auth[] = "xxx";             
char ssid[] = "";
char pass[] = "";

void setup () 
{ 
 Serial.begin(9600); 
 Serial.print("Begin");
 Blynk.begin(auth, ssid, pass);

 //pinMode(flexpin, OUTPUT);
 
} 
void loop () 
{
 static int i=0;
 static float avgflex=0;
 int flexposition; 
 Blynk.run();
 flexposition = analogRead(flexpin); 
 Serial.print("\n sensorsize: "); 
 Serial.print(flexposition); 
 delay(1000);

    if(i<15){
      flexarray[i]=flexposition;    
    }
    while(i==15){
      avgflex=calcavgflex(flexarray);
      Serial.println("\nAvarage flex: ");
      Serial.print(avgflex);
      i=-1;
      break;
    }
  i++;
  Blynk.virtualWrite(V7, BPM);

}

int calcavgflex(int flexarray[]){
  float avgmin;
  long avgsum=0;
  for(int k=0;k<15; k++){
     avgsum+=flexarray[k];
     //Serial.println("\n");
     //Serial.print(avgsum);
     //Serial.println(" ");
  }
  avgmin=avgsum/15;
  return avgmin;
}

Credits

chaitra deepika komatineni

chaitra deepika komatineni

2 projects • 5 followers
Thanks to A. Uddeepa Reddy and Bhargava Rajaram.

Comments