how to use load cell arduino 1kg
/*# How to Calibrate Your Scale
1. Call set_scale() with no parameter.
2. Call tare() with no parameter.
3. Place a known weight on the scale and call get_units(10).
4. Divide the result in step 3 by your known weight. You should get about the parameter you need to pass to set_scale.
5. Adjust the parameter in step 4 until you get an accurate reading.
*/
#include "HX711.h"
// HX711.DOUT - pin 11 or any pin
// HX711.PD_SCK - pin 12 or any pin
HX711 scale(11, 12); // parameter "gain" is ommited; the default value 128 is used by the library
float scalar = 1490;
float zero;
//=======================================================================================================
void setup() {
Serial.begin(9600);
Serial.println("HX711 Demo");
Serial.println("SETUP");
scale.set_scale(scalar); //I've left out the '.f'!!
scale.tare(); // reset the scale to 0
zero = scale.get_units(5);
while (zero != 0.0) {
if (zero > 0)++scalar;
if (zero < 0)--scalar;
scale.set_scale(scalar);
scale.tare(); // reset the scale to 0
zero = scale.get_units(5);
Serial.print("Zeroing. Scale reading:\t");
Serial.print(scale.get_units(), 1);
Serial.print(" Scalar: \t");
Serial.println(scalar);
Serial.println("");
}
Serial.print("Raw reading from ADC = \t");
Serial.println(scale.read()); // print a raw reading from the ADC
Serial.println("");
Serial.print("Average of (five) scale.readings = \t");
Serial.println(scale.read_average(5)); // print the average of readings from the ADC
Serial.println("");
Serial.print("Average of (five) readings minus tare weight = \t");
Serial.println(scale.get_value(5)); // print the average of readings from the ADC minus the tare weight
Serial.println("");
Serial.print("Average of (five) readings minus tare weight divided by SCALE parameter = \t");
Serial.println(scale.get_units(5), 1); // print the average of readings from the ADC minus tare weight, divided
// by the SCALE parameter set with set_scale
Serial.println("");
Serial.println("Readings:");
}
void loop() {
delay(200);
Serial.print("One reading:\t");
Serial.print(scale.get_units(), 1);
Serial.print("\t| Average reading:\t");
Serial.println(scale.get_units(50), 1);
//Serial.println(potDry);
// scale.power_down(); // put the ADC in sleep mode
delay(5000);
// scale.power_up();
}