Technovation
Published © GPL3+

Health Band - A Smart Assistant for the Elderly

This health band can assist old people in their daily lives, leaving the family stress free!

IntermediateFull instructions provided8 hours97,773
Health Band - A Smart Assistant for the Elderly

Things used in this project

Hardware components

DPS310
Infineon DPS310
×1
Arduino Nano R3
Arduino Nano R3
×1
ESP8266 ESP-01
Espressif ESP8266 ESP-01
×1
Jumper wires (generic)
Jumper wires (generic)
×1
3.7 V LiPo Battery
×1

Software apps and online services

Arduino IDE
Arduino IDE
Blynk
Blynk

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

HealthBand Wire Diagram

Code

Generating Data Test

Arduino
Once the various libraries are installed run this program to see if everything works. You should be getting a live stream of data or values on the serial monitor.
#include <ifx_dps310.h>

void setup()
{
  Serial.begin(9600);
  while (!Serial);

  //Call begin to initialize ifxDps310
  //The parameter 0x76 is the bus address. The default address is 0x77 and does not need to be given.
  //ifxDps310.begin(Wire, 0x76);
  //Use the commented line below instead to use the default I2C address.
  ifxDps310.begin(Wire);

  // IMPORTANT NOTE
  //If you face the issue that the DPS310 indicates a temperature around 60 C although it should be around 20 C (room temperature), you might have got an IC with a fuse bit problem
  //Call the following function directly after begin() to resolve this issue (needs only be called once after startup)
  //ifxDps310.correctTemp();

  //temperature measure rate (value from 0 to 7)
  //2^temp_mr temperature measurement results per second
  int temp_mr = 2;
  //temperature oversampling rate (value from 0 to 7)
  //2^temp_osr internal temperature measurements per result
  //A higher value increases precision
  int temp_osr = 2;
  //pressure measure rate (value from 0 to 7)
  //2^prs_mr pressure measurement results per second
  int prs_mr = 2;
  //pressure oversampling rate (value from 0 to 7)
  //2^prs_osr internal pressure measurements per result
  //A higher value increases precision
  int prs_osr = 2;
  //startMeasureBothCont enables background mode
  //temperature and pressure ar measured automatically
  //High precision and hgh measure rates at the same time are not available.
  //Consult Datasheet (or trial and error) for more information
  int ret = ifxDps310.startMeasureBothCont(temp_mr, temp_osr, prs_mr, prs_osr);
  //Use one of the commented lines below instead to measure only temperature or pressure
  //int ret = ifxDps310.startMeasureTempCont(temp_mr, temp_osr);
  //int ret = ifxDps310.startMeasurePressureCont(prs_mr, prs_osr);


  if (ret != 0)
  {
    Serial.print("Init FAILED! ret = ");
    Serial.println(ret);
  }
  else
  {
    Serial.println("Init complete!");
  }
}



void loop()
{
  unsigned char pressureCount = 20;
  long int pressure[pressureCount];
  unsigned char temperatureCount = 20;
  long int temperature[temperatureCount];

  //This function writes the results of continuous measurements to the arrays given as parameters
  //The parameters temperatureCount and pressureCount should hold the sizes of the arrays temperature and pressure when the function is called
  //After the end of the function, temperatureCount and pressureCount hold the numbers of values written to the arrays
  //Note: The Dps310 cannot save more than 32 results. When its result buffer is full, it won't save any new measurement results
  int ret = ifxDps310.getContResults(temperature, temperatureCount, pressure, pressureCount);

  if (ret != 0)
  {
    Serial.println();
    Serial.println();
    Serial.print("FAIL! ret = ");
    Serial.println(ret);
  }
  else
  {
    Serial.println();
    Serial.println();
    Serial.print(temperatureCount);
    Serial.println(" temperature values found: ");
    for (int i = 0; i < temperatureCount; i++)
    {
      Serial.print(temperature[i]);
      Serial.println(" degrees of Celsius");
    }

    Serial.println();
    Serial.print(pressureCount);
    Serial.println(" pressure values found: ");
    for (int i = 0; i < pressureCount; i++)
    {
      Serial.print(pressure[i]);
      Serial.println(" Pascal");
    }
  }

  //Wait some time, so that the Dps310 can refill its buffer
  delay(10000);
}

HealthBand with Blynk Application

Arduino
This is the final program, few variables and thresholds need to be manually inputted for the health-band to work well, follow the comments and make the adjustments. Set up the widgets on the Blynk app as per your needs and your assistant should come to life!
#include <ifx_dps310.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

#define BLYNK_PRINT Serial

char auth[] = "YourAuthToken";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";

const unsigned char pressureLength = 50;
unsigned char pressureCount = 0;
long int pressure[pressureLength];
unsigned char temperatureCount = 0;
const unsigned char temperatureLength = 50;
long int temperature[temperatureLength];

/*these thresholds will change according to where u currecntly are, 
these values worked perfetly in our coastal region where average temperatures were
34 degrees celsius
*/
int pressureFallingThresh = 1;
int pressureSleepingThresh = 4;
int tempFeverThresh = 39;
int pressureJogThresh = 5;

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  while (!Serial);
  ifxDps310.begin(Wire);
  
  int ret = ifxDps310.setInterruptPolarity(1);
  ret = ifxDps310.setInterruptSources(1, 0, 0);
  //clear interrupt flag by reading
  ifxDps310.getIntStatusFifoFull();

  int interruptPin = 3;
  pinMode(interruptPin, INPUT);
  attachInterrupt(digitalPinToInterrupt(interruptPin), onFifoFull, RISING);

  //start of a continuous measurement just like before
  int temp_mr = 3;
  int temp_osr = 2;
  int prs_mr = 1;
  int prs_osr = 3;
  ret = ifxDps310.startMeasureBothCont(temp_mr, temp_osr, prs_mr, prs_osr);
  if (ret != 0)
  {
    Serial.print("Init FAILED! ret = ");
    Serial.println(ret);
  }
  else
  {
    Serial.println("Init complete!");
  }
}


void loop()
{
  Blynk.run();
  
  Serial.println("loop running");
  delay(500);
  
  if (pressureCount == pressureLength && temperatureCount == temperatureLength)
  {
    //print results
    Serial.println();
    Serial.println();
    Serial.print(temperatureCount);
    Serial.println(" temperature values found: ");
    for (int i = 0; i < temperatureCount; i++)
    {
      Serial.print(temperature[i]);
      if (temperature[i] > tempFeverThresh){
        feverEmail();
      }
      Serial.println(" degrees of Celsius");
    }
    Serial.println();
    Serial.print(pressureCount);
    Serial.println(" pressure values found: ");
    for (int i = 0; i < pressureCount; i++)
    {
      Serial.print(pressure[i]);
      if (pressure[i] < pressureFallingThresh){
        fallEmail();
      }
      else if (pressure[i] < pressureSleepingThresh && pressure[i] < pressureFallingThresh){
        wakingUpEmail();
      }
      Serial.println(" Pascal");
    }
    Serial.println();
    Serial.println();
    //reset result counters
    pressureCount = 0;
    temperatureCount = 0;
  }
 
}

void feverEmail()
{
  Serial.println("Button is pressed."); // This can be seen in the Serial Monitor
  Blynk.email("your_email@mail.com", "Subject: your patient has fever", "your patient has a fever and his/ her body temp is", temperature);
}

void fallEmail()
{
  Serial.println("Button is pressed."); // This can be seen in the Serial Monitor
  Blynk.email("your_email@mail.com", "Subject: your patient just had a fall", "your patient just had a fall and requires assistance");
}

void wakingUpEmail()
{
  Serial.println("Button is pressed."); // This can be seen in the Serial Monitor
  Blynk.email("your_email@mail.com", "Subject: your patient has just left his/her bed", "your patient has a just left the bed for unknown reasons, he/she needs assistance");
}

//interrupt handler
void onFifoFull()
{
  //message for debugging
  Serial.println("Interrupt handler called");

  //clear interrupt flag by reading
  ifxDps310.getIntStatusFifoFull();

  //calculate the number of free indexes in the result arrays
  unsigned char prs_freespace = pressureLength - pressureCount;
  unsigned char temp_freespace = temperatureLength - temperatureCount;
  //read the results from Dps310, new results will be added at the end of the arrays
  ifxDps310.getContResults(&temperature[temperatureCount], temp_freespace, &pressure[pressureCount], prs_freespace);
  //after reading the result counters are increased by the amount of new results
  pressureCount += prs_freespace;
  temperatureCount += temp_freespace;
}

Credits

Technovation

Technovation

7 projects • 92 followers
We are two young inventors, Kousheek and Satya .We like making robots and tech related things. Our projects focus on simplicity utility.

Comments