Weighing Load Cell Sensor 3kgs not showing exact weight

Hi,

Weighing Load Cell Sensor 3kgs not showing exact weight it is displaying some ramdom values on arduino ide's serial monitor....

Hardwares we are using:
1)Weighing Load Cell Sensor 3kgs
2)HX711(Analog to digital convertor)
3)Arduino Uno
4)ESP8266 WIFI Module
5)Connecting wires

Program which we are executing is as per below,

#include <WiFiEsp.h>
#include <WiFiEspClient.h>
#include <WiFiEspServer.h>
#include <WiFiEspUdp.h>

#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>
#include <MySQL_Encrypt_Sha1.h>
#include <MySQL_Packet.h>

WiFiEspClient client; //Use this for ESP8266
MySQL_Connection conn((Client *)&client);

#include "HX711.h" //You must have this library in your arduino library folder

#define DOUT 6
#define CLK 5

HX711 scale(DOUT, CLK);

// Emulate Serial1 on pins 2/3 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(2, 3); // RX, TX
#endif

char ssid[] = "MAKARAND SYSTEMS"; // your network SSID (name)
char pass[] = "xyzabc"; // your network password

IPAddress server_addr(148,66,135,229); // IP of the MySQL server here go dadday
char user[] = "srinivas";
char password[] = "xyzabc$";

//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

//=============================================================================================
// SETUP
//=============================================================================================
void setup() {
Serial.begin(115200);

Serial.read();
while (!Serial); // wait for serial port to connect. Needed for Leonardo only
// initialize serial for ESP module
Serial.println("Starting....");
Serial1.begin(9600);
// initialize ESP module
WiFi.init(&Serial1);

//Serial1.println("Connecting to WiFi");

// Begin WiFi section
int status = WiFi.begin(ssid, pass);
if ( status != WL_CONNECTED) {
Serial.println("Couldn't get a wifi connection");
while(true);
}
// print out info about the connection:
else {
Serial.println("Connected to network");
IPAddress ip = WiFi.localIP();
Serial.print("My IP address is: ");
Serial.println(ip);
}
Serial.println("Press T to tare");
scale.set_scale(-96650); //Calibration Factor obtained from first sketch
scale.tare(); //Reset the scale to 0

Serial.print("Weight: ");
Serial.print(scale.get_units(),3); //Up to 3 decimal points
Serial.println(" kg"); //Change this to kg and re-adjust the calibration factor if you follow lbs

Serial.println("Connecting...");
if(conn.connect(server_addr,3306,user,password)) {
delay(1000);

// if(Serial.available()>0)
// {
Serial.print("executing inside available");
//char temp = Serial.read();
//if(temp == 't' || temp == 'T'){
char weight[8];
Serial.println("Line 1");
dtostrf(scale.get_units(),5,3,weight);
Serial.println("Line 2");
//char INSERT_SQL1[40];
//char INSERT_SQL[80];
String INSERT_SQL1 = "INSERT INTO test.test VALUES(";
String strbracket =")";
String INSERT_SQL=INSERT_SQL1+weight+strbracket;
Serial.println("Line 3");

MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
//extern void recvOneChar();
//extern void showNewData();
char copy[50];
Serial.println("Line 4");
INSERT_SQL.toCharArray(copy, 50);
cur_mem->execute(copy);
Serial.print("output:");
Serial.print(INSERT_SQL);
scale.tare();
}}

//}

//=============================================================================================
// LOOP
//=============================================================================================
void loop() {

}
//=============================================================================================

We are able to insert sensor data into our mysql database,but the data is inaccurate....
Please suggest us to get exact load sensor data.

Attached is the circuit connections among..load cell sensor,hx711 and arduino uno

Random values or just inaccurate ??I would use the example programs supplied with library and see if that works ok for you and gives sensible numbers.

There is a lot going on in that software ( I don’t like reading software) , so the examples will prove the basic circuit is working ok. The scale factor you have does seem odd .

Please edit your post to add code tags ("</>" button). See "How to use this forum".

Agreed - use the example code to just read that sensor. Make sure that part works.

Also know what accuracy you can expect, of course you will never get an exact weight, there's always some error in the reading.

Attached is the output of weight.

Checked physically and the accurate weight should be 50 grams...but getting just 10 to 12 gms.

Which sensor are you using?

You haven't posted the calibration sketch, perhaps the problem is there?

sensor which we are using is "WEIGHING LOAD CELL SENSOR 3KG FOR ELECTRONIC KITCHEN SCALE YZC-131 WITH WIRES "

We are facing problem to find exact calibration factor,

code for calibration factor is as below,

/*

  • https://circuits4you.com
  • 2016 November 25
  • Load Cell HX711 Module Interface with Arduino to measure weight in Kgs
    Arduino
    pin
    2 -> HX711 CLK
    3 -> DOUT
    5V -> VCC
    GND -> GND

Most any pin on the Arduino Uno will be compatible with DOUT/CLK.
The HX711 board can be powered from 2.7V to 5V so the Arduino 5V power should be fine.
*/

#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 = -6809741; //-106600 worked for my 40Kg max scale setup

//=============================================================================================
// 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(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
}
//delay(1000);
}
//=============================================================================================

Not able to find the calibration factor for load cell sensor.....please help

Pretty easy to find.
Take a known weight, see what your sensor thinks about it, calculate your sensor's calibration factor.
Do this for a few weights to check linearity.

And check for hysteresis... Go from 0g to 50g to 100g to 50g, etc, see if the 50g reading depends on the history, take the average of the readings as a better estimate than either - repeat for several weights and calculate the
regression or plot a graph if you want to check the linearity.

Do you have a preload of 3 to 5 % of full scale to pull the load cell up out of it's near 0 non linear range?

Might be load cell is not working properly....

please suggest whether weighing load cell of capacity 3 kgs is in working condition or not

Does it work? Then it's in working condition. Otherwise not.

Connections we did as per attached jpg file.

calibration factor Code is as per below.

Please suggest us if anything wrong in circuit connections or code.

#include "HX711.h"
#define DOUT 3
#define CLK 2
HX711 scale(DOUT, CLK);
float calibration_factor = -96650; //-7050 worked for my 440lb max scale setup
void setup() {
Serial.begin(38400);
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");
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);}
void loop() {
scale.set_scale(calibration_factor); //Adjust to this calibration factor
Serial.print("Reading: ");
Serial.print(scale.get_units()*0.453592, 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;}}