can someone tell me how i can get my bowl to be my zero point on my load cell? my bowl weighs 0.147 kg and i found the analog reading is 96. I made a variable and set it to 96 and then subtracted 96 from the analog reading to give me 0 and then the analog reading is set to zero. but my problem is once i add something to the bowl the analog reading is still reading zero and will not change. can someone tell me what i may be doing wrong?
here is what i am getting:
analogValue: 0.00
load: -6.40610
any help would be appreciated!
// Load cells are linear. So once you have established two data pairs, you can interpolate the rest.
// Step 1: Upload this sketch to your arduino board
// You need two loads of well know weight. In this example A = 10 kg. B = 30 kg
// Put on load A
// read the analog value showing (this is analogvalA)
// put on load B
// read the analog value B
// Enter you own analog values here
float loadA = 0.147; // kg
int analogvalA = 96; // analog reading taken with load A on the load cell
float loadB = 0.321; //30; // kg
int analogvalB = 146; // analog reading taken with load B on the load cell
// Upload the sketch again, and confirm, that the kilo-reading from the serial output now is correct, using your known loads
float analogValueAverage = 0;
// How often do we do readings?
long time = 0; //
int timeBetweenReadings = 200; // We want a reading every 200 ms;
int zero = 96;
void setup() {
Serial.begin(9600);
}
void loop() {
int analogValue = analogRead(0);
// running average - We smooth the readings a little bit
analogValueAverage = 0.99*analogValueAverage + 0.01*analogValue;
//analogValueAverage = analogvalA - zero;
// Is it time to print?
if(millis() > time + timeBetweenReadings){
float load = analogToLoad(analogValueAverage);
double ounce = load * 35.274;
Serial.print("analogValue: ");Serial.println(analogValueAverage);
Serial.print("Ounce: ");Serial.println(ounce);
Serial.print(" load: ");Serial.println(load,5);
time = millis();
}
}
float analogToLoad(float analogval){
// using a custom map-function, because the standard arduino map function only uses int
float load = mapfloat(analogval, analogvalA, analogvalB, loadA, loadB);
return load;
}
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}