First, you must using 4 load cell 50 kg for balance
please watch this tutorial
first do the calibration
=================================================================
#include "HX711.h" //You must have this library in your arduino library folder ,search in github
#define DOUT 3
#define CLK 2
HX711 scale(DOUT, CLK);
//Change this calibration factor as per your load cell once it is found you many need to vary it in thousands
//float calibration_factor = -96650; //-106600 worked for my 40Kg max scale setup
float calibration_factor = 190;
//=============================================================================================
// SETUP
//=============================================================================================
void setup() {
Serial.begin(9600);
Serial.println("HX711 Calibration");
Serial.println("Remove all weight from scale");
Serial.println("After readings begin, place known weight on scale");
Serial.println("Press a,s,d,f to increase calibration factor by 10,100,1000,10000 respectively");
Serial.println("Press z,x,c,v to decrease calibration factor by 10,100,1000,10000 respectively");
Serial.println("Press t for tare");
scale.set_scale();
scale.tare(); //Reset the scale to 0
long zero_factor = scale.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_factor);
}
//=============================================================================================
// LOOP
//=============================================================================================
void loop() {
scale.set_scale(calibration_factor); //Adjust to this calibration factor
Serial.print("Reading: ");
Serial.print(0.453592 * scale.get_units(), 3);
Serial.print(" kg"); //Change this to kg and re-adjust the calibration factor if you follow SI units like a sane person
Serial.print(" calibration_factor: ");
Serial.print(calibration_factor);
Serial.println();
if(Serial.available())
{
char temp = Serial.read();
if(temp == '+' || temp == 'a')
calibration_factor += 10;
else if(temp == '-' || temp == 'z')
calibration_factor -= 10;
else if(temp == 's')
calibration_factor += 100;
else if(temp == 'x')
calibration_factor -= 100;
else if(temp == 'd')
calibration_factor += 1000;
else if(temp == 'c')
calibration_factor -= 1000;
else if(temp == 'f')
calibration_factor += 10000;
else if(temp == 'v')
calibration_factor -= 10000;
else if(temp == 't')
scale.tare(); //Reset the scale to zero
}
}
=============================================================
load cell in action :
#include "HX711.h" //You must have this library in your arduino library folder
#define DOUT 3
#define CLK 2
HX711 scale(DOUT, CLK);
//Change this calibration factor as per your load cell once it is found you many need to vary it in thousands
float calibration_factor = 230; //-106600 worked for my 40Kg max scale setup
double a;
//=============================================================================================
// SETUP
//=============================================================================================
void setup() {
Serial.begin(9600);
Serial.println("Press T to tare");
scale.set_scale(calibration_factor); //Calibration Factor obtained from first sketch
// scale.tare(); //Reset the scale to 0
}
//=============================================================================================
// LOOP
//=============================================================================================
void loop() {
Serial.print("Weight: ");
Serial.print((0.453592 * scale.get_units(3))/10, 1); //Up to 3 decimal points
Serial.println(" kg"); //Change this to kg and re-adjust the calibration factor if you follow lbs
float a = ((0.453592 * scale.get_units(3))/10);
Serial.println(a,1);
if(a,1 >= 0.8){
Serial.println("stop");
}
if(Serial.available())
{
char temp = Serial.read();
if(temp == 't' || temp == 'T'){
scale.tare(); //Reset the scale to zero }
}
if(temp == 'a'){
scale.set_scale(calibration_factor);
scale.tare();
}
}
}
No comments:
Post a Comment