Hi, I have used an old set of digital hanging scales and connected the strain gauge to an arduino uno via a HX711 ADC. I have managed to calibrate the scale and can log weight readings to an SD card. The scale is hanging from the roof of a poultry shed with a platform connected with the goal of weighing the chickens as they jump on and off the platform. My problem is how to write code to tell log the weight of each bird as they jump onto the platform as there may be 1, 2, 3, ... birds already on the scale. Has anyone come across this kind of coding task before?
Thanks Delta_G thats allowed me to make another small step forward . Paul, yes thats the next issue...how to deal with that? maybe a smoothing or delay function?
Maybe a correlation between the rate of change in weight and the number of birds on the scale would help. (Does a digital scale even progressively change as weight is applied? Can't get the image of an old loaded spring scale out of my head)
I would run a while() loop which does nothing while the weight is changing more than a certain threshold. This will help you to get a reading once the measurement is stabilized.
Also, you probably know that a single chicken can weigh anywhere from X to Y gramms /pounds so in your code you can do something like this
#define MINIMUM_EXPECTED_WEIGHT 400 //400 gramms
#define MAXIMUM_EXPECTED_WEIGHT 1000 //1000 gramms.
....
int old_val=getWeight();
delay(100);
new_val=getWeight();
while( abs(old_val-new_val)>100 ){//grab weight samples, make sure that the value settles
old_val=new_val;
delay(100);
new_val=getWeight();
//maybe add a timeout statement here too
}
if( (new_val> MINIMUM_EXPECTED_WEIGHT) && (new_val<MAXIMUM_EXPECTED_WEIGHT) ){
Serial.println("we think that have one chicken on the scale");
logWeight(new_val);
}
else{
Serial.println("we may have more than one chicken on the scale")
doSomethingAboutIt();
}