Inventeam Project

This is amazing, i really appreciate the help. I used the code you provided and only the else is returning. Also, the code is running constantly without a magnet even being sensed.

#define W D2 //the waist sensor is on this pin
#define H D5 //the hip sensor is on this pin

	int w_state=HIGH;//sets the waist measurement state for a grove hall effect sensor
 	int h_state=HIGH;//sets the hip measurement state for a grove hall effect sensor
 	int w_count=70;//our testing rig has an initial waist size of 70cm
 	int h_count=82;//our testing rig has an initial hip size of 82cm
  bool w_isNearMagnet = W;
 	 bool h_isNearMagnet=H;
 	  
int w_sensorValue;
int h_sensorValue;


void setup() {
    
     pinMode(D2, INPUT);
 	 pinMode(D5, INPUT);

}

void loop() {
sensor1();
sensor2();
}

void sensor1() {
    if (w_isNearMagnet)//if the Grove sensor is near the magnet?
		measure();
		
   
}
void sensor2() {
    	if (h_isNearMagnet)//if the Grove sensor is near the magnet?
		measure();
		
}

bool measure() {
		h_sensorValue = digitalRead(H);
		w_sensorValue = digitalRead(W);
	if(h_sensorValue == LOW)//if the hip sensor value is LOW
	{
	h_count +=1 ;//count each low state and add it to the intial hip size.
	calc_ratio();
	}
	else
	{
		return false;//no,return false
	}
	
    if(w_sensorValue == LOW)//if the waist sensor value is LOW
	{
	//COUNT(w_count + COUNT);//count each low state and add it to the intial waist size.
	w_count+=1;
	calc_ratio();
	}
	else
	{
		return false;//no,return false
	}
}

float calc_ratio() {
  if (h_sensorValue != 0) {  // <-- make sure the divisor is NOT zero
    float ratio = w_sensorValue / h_sensorValue;
    char txt[16];
    snprintf(txt, sizeof(txt), "%.2f", ratio);
    Particle.publish("ratio", txt, PRIVATE);
    return (ratio); 
  }
  else {
    Particle.publish("ratio", "80", PRIVATE);
    return -1; 
  }    
}

That is the expected behaviour. The name of the function loop() should give that away - i.e. it will be permanently running in a never ending loop doing its stuff over and over.
Your code is not event driven but running continously.
When sensing your magnets the first thing would be to check whether there was a change of state - if there wasn't just keep checking without further action. Only when something changed deal with that change and go back checking.

Using interrupts would make this project more event driven.