hi,
I'm making a scale with two and then four load cells (50kg each), two hx711 and arduino uno.
I use code from github and modify it to count mean from two measurements.
I changed pins to analogs and it seems to work better but still I think it's not perfect because measurements depends on point where I put weight.
Can I fix this problem in program?
I put my code in here
I'm new in this world so please answer me like to child
#include "HX711-multi.h"
#include "HX711.h"
#define DOUT1 2
#define CLK1 7
#define DOUT2 3
#define CLK2 4
HX711 scale1;
HX711 scale2;
float calibration_factor1 = -3000; //-7050 worked for my 440lb max scale setup
float calibration_factor2 = -3050; //-7050 worked for my 440lb max scale setup
float suma;
int p;
void setup() {
Serial.begin(9600);
Serial.println("HX711 calibration sketch");
Serial.println("Remove all weight from scale");
Serial.println("After readings begin, place known weight on scale");
Serial.println("Press + or a to increase calibration factor");
Serial.println("Press - or z to decrease calibration factor");
scale1.begin(DOUT1, CLK1);
scale1.set_scale();
scale1.tare(); //Reset the scale to 0
scale2.begin(DOUT2, CLK2);
scale2.set_scale();
scale2.tare(); //Reset the scale to 0
long zero_factor1 = scale1.read_average(); //Get a baseline reading
long zero_factor2 = scale2.read_average(); //Get a baseline reading
Serial.print("Zero factor: "); //This can be used to remove the need to tare the scale. Useful in permanent scale projects.
Serial.println(zero_factor1);
Serial.println(zero_factor2);
//pinMode(2, INPUT);
//attachInterrupt(2, srednia, FALLING );
}
void loop() {
interrupts();
scale1.set_scale(calibration_factor1); //Adjust to this calibration factor
scale2.set_scale(calibration_factor2); //Adjust to this calibration factor
Serial.print("Reading1: ");
Serial.print(scale1.get_units(), 2);
Serial.print(" kg");
Serial.print(" Reading2: ");
Serial.print(scale2.get_units(), 2);
Serial.print(" kg"); //Change this to and re-adjust the calibration factor if you follow SI units like a sane person
Serial.print(" calibration_factor1: ");
Serial.print(calibration_factor1);
Serial.print(" calibration_factor2: ");
Serial.print(calibration_factor2);
Serial.print( "reading: ");
Serial.println( suma/2);
Serial.println();
if (Serial.available())
{
char temp = Serial.read();
if (temp == '+')
calibration_factor1 += 100;
else if (temp == '-')
calibration_factor1 -= 100;
if (temp == 'a')
calibration_factor2 += 100;
else if (temp == 'z')
calibration_factor2 -= 100;
}
noInterrupts();
for(p=0; p<2; p++)
{
suma = scale1.get_units() + scale2.get_units();
}
}