# Cup Angle Liquid Measure-Temperature Cool Down Time Help

Hi, so I have a device which uses a accelerator to measure the x angle of my photon. The aim that I have set out is to attach it to a cup to measure the level of liquid being consumed. I have got the data for the different angles and the amount of liquid consumed.

I have also added a temperature sensor which allows me to get the temp of the cup. In doing this it has allowed me to determine weather any liquid is present in the cup.

The problem I am having is that the sensor for temp is outside of the cup, when I put hot water and empty the cup the code would still think their is liquid inside of the cup, this is because the cup on the outside is still hot and so temperature is going to go down gradually.

Does anyone know any sort of way to prevent this or to help in some way to improve it.

`````` if(si7020Temperature >= 17 && si7020Temperature <22){
Particle.publish("Noliquid", "No Liquid In Cup");

########RESTING CUP #####################
if (deg >= 49 && deg <= 51){
Particle.publish("Resting", "Cup Is Stable & Resting");
}else if (deg >=29 && deg <= 32){
Particle.publish("Slant", "Cup Is Slanted");
}else if (deg >= 33 &&  deg <= 36){
Particle.publish("Side", "Cup Is On Its Side");
}else if(deg >= 58 && deg <= 62) {
Particle.publish("Drying", "Cup Drying/Upside Down");
}
}

##########HOT LIQUID ###############
if(si7020Temperature > 23){

if(xTilt >= 270 && xTilt <= 285 && waterLevel == 0){
waterLevel = 100;
}else if (xTilt < 270 && xTilt > 265 && waterLevel > 97){
waterLevel = 97;
}else if (xTilt < 265 && xTilt > 260 && waterLevel > 95){
waterLevel = 95;
}
else if (xTilt < 260 && xTilt > 255 && waterLevel >90){
waterLevel = 90;
}else if (xTilt < 255 && xTilt >250 && waterLevel> 89 ){
waterLevel = 89;
}
else if (xTilt <250 && xTilt > 245 && waterLevel >74){
waterLevel= 74;
}else if (xTilt < 245 && xTilt > 240 && waterLevel >65){
waterLevel = 65;
}
else if (xTilt < 240 && xTilt > 235 && waterLevel >45){
waterLevel = 45;
}else if (xTilt < 235 && xTilt > 230 && waterLevel >37){
waterLevel = 37;
}
else if (xTilt <230 && xTilt > 220 && waterLevel >20){
waterLevel = 20;
}
else if (xTilt <220 && xTilt > 210 && waterLevel >10){
waterLevel = 10;
}else if (xTilt <210 && xTilt > 200 && waterLevel >5){
waterLevel = 5;
}else if (xTilt < 200 && waterLevel >0){
waterLevel = 0;
cupsOfLiquid ++;
}

Particle.publish("waterLevel", String(waterLevel));
Particle.publish("cupsOfLiquid", String(cupsOfLiquid));

int mlLiquid = 320;

int total = mlLiquid *cupsOfLiquid;

Particle.publish("totalConsumed", String(total));

}
``````

Once the liquid in the hot cup is finished I want it to go back to the resting cup with no liquid stage. However it will go back to the Hot cup and say their is liquid because the cup on the outside is still hot?

Any help is appreciated.