Jay Mehta
Created August 28, 2023

AquaEase: Effortless Smart Hydration for Armless Amputees.

AquaEase: Empowering armless users with effortless smart hydration for refreshed energy!

7
AquaEase: Effortless Smart Hydration for Armless Amputees.

Code

Final_Pressure_Sensing_bottle _smart_code

C/C++
#include <Wire.h>
#include <Adafruit_BMP085.h>
Adafruit_BMP085 bmp;
int relay=2;
float pressureinPSI;
float lastSysPressure=0;
long pressure;
long avgSysPressure,sysPressure;
long pressureSum;
long baseLinePressure;
bool motorOn=false;
byte i;
float delta;
float prevdelta;
void setup() {
  int setpress=0;
  Serial.begin(9600);

  if (!bmp.begin()) {
	Serial.println("Could not find a valid BMP085 sensor, check wiring!");
	while(1) {}
  

  
  }
  pinMode(relay, OUTPUT);
  digitalWrite(relay,HIGH);
  baseLinePressure=bmp.readPressure();
  prevdelta=100000;
}
  
void loop() {
  pressureSum=0;
  for(i=0;i<5;i++)
  {
    pressure=bmp.readPressure();
    pressureSum=pressureSum+pressure;   
  }
  avgSysPressure=pressureSum/5;
  sysPressure=avgSysPressure-baseLinePressure;

  delta=sysPressure-lastSysPressure;
 
 
  Serial.println(delta);
  if(delta<-100 && !motorOn)
 {

  Serial.println("ON");
  digitalWrite(relay,LOW);
  delay(5000);
  digitalWrite(relay,HIGH);
  motorOn=true; 

 }


 if(motorOn && delta<-500)
 {
  Serial.println("ON Second Time");
  digitalWrite(relay,LOW);
  delay(5000);
  digitalWrite(relay,HIGH);
  
  
 }

 if(sysPressure>0 && sysPressure<100)
 {
  motorOn=false;
 }


lastSysPressure=sysPressure;
prevdelta=delta;
}

Credits

Jay Mehta

Jay Mehta

2 projects • 0 followers

Comments