Hello everyone,
I am trying to make a scale with a 5kg load cell and a HX711 amplifier. I have added pictures to this post of how I connected it. The problem is that my readings are not varying with different weights being put on the load cell. I am only getting readings around 1750 in the serial monitor.
Does anyone know what I am doing wrong? Thank you in advance!
Kind regards,
Daan
This is the code that I am using to test:
//Defining scale
#include "HX711.h"
#define LoadcellDOUT 4
#define LoadcellSCK 5
HX711 scale;
void setup() {
Serial.begin(57600);
scale.begin(LoadcellDOUT, LoadcellSCK);
}
void loop() {
//Serial.println(scale.read_average(5));
Serial.println(scale.read());
delay(200);
}
Connections from HX711:
DAT --> pin 4
CLK --> 5
VCC --> 5V
GND --> GND
Where is your load cell, how is mechanically connected? Is the measured weight never correct?
P.S.
Also follew the examples included in the library
Half the needed code is missing. Use the examples, it is not as intuitive as you think. Also check the SparkFun version of the software for a couple of more ideas. You will need to read the HX711 library code for a total understanding.
Your pictures although nice do not help me much. Post an annotated schematic showing all connections. Also post links to each hardware item.
Alright, I have not yet mechanically connected the loadcell to a proper setup because I first wanted to see if the load cell would give me any proper readings. I am putting one end of the load cell on the edge of my desk and I am pressing with my hand on the other end to see if the readings are changing, but they are not.
The link below is the HX711 module I am using. Does anyone know what the little pad on the backside is that says "RATE"?
https://nl.aliexpress.com/item/1005006293368575.html?spm=a2g0o.productlist.main.5.7faapxvMpxvMOy&algo_pvid=041bc3ad-5197-4455-b86f-a265593fa810&algo_exp_id=041bc3ad-5197-4455-b86f-a265593fa810-2&pdp_npi=4%40dis!EUR!1.75!1.12!!!13.56!8.68!%402103894417242397623206870e6b48!12000036639761167!sea!NL!810974822!X&curPageLogUid=Lm7NhsRldqMt&utparam-url=scene%3Asearch|query_from%3A
5kg load cell:
https://nl.aliexpress.com/item/1005006827930173.html?spm=a2g0o.productlist.main.1.3b86688aNKO5Sl&algo_pvid=bb37aa0c-7f1a-4b4e-a53e-82b7d6cef7cc&algo_exp_id=bb37aa0c-7f1a-4b4e-a53e-82b7d6cef7cc-0&pdp_npi=4%40dis!EUR!2.99!1.94!!!23.11!15.02!%4021039cba17242419115832633e2d10!12000038432362683!sea!NL!810974822!X&curPageLogUid=tp6gS3wXYiX8&utparam-url=scene%3Asearch|query_from%3A
I have now tested the load cell with the following two codes I found at this link:
#include "HX711.h"
#define LOADCELL_DOUT_PIN 3
#define LOADCELL_SCK_PIN 2
HX711 scale;
float calibration_factor = -7050; //-7050 worked for my 440lb max scale setup
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");
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
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(), 1);
Serial.print(" lbs"); //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;
}
}
#include "HX711.h"
#define calibration_factor -7050.0 //This value is obtained using the SparkFun_HX711_Calibration sketch
#define LOADCELL_DOUT_PIN 3
#define LOADCELL_SCK_PIN 2
HX711 scale;
void setup() {
Serial.begin(9600);
Serial.println("HX711 scale demo");
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
scale.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
scale.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
Serial.println("Readings:");
}
void loop() {
Serial.print("Reading: ");
Serial.print(scale.get_units(), 1); //scale.get_units() returns a float
Serial.print(" lbs"); //You can change this to kg but you'll need to refactor the calibration_factor
Serial.println();
}
No matter what I do, the result looks like this:
In the screenshot below you can see all of the connections:
You can get the full code and detailed circuit diagram here:
In this tutorial, It is shown step by step how to use an HX711 module with a load cell to make accurate weight measurements using an Arduino.
I guess I solved the problem. I took a closer look at the connections to the strain gauges on the load cell and 2 of the tiny wires were broken. I soldered them back together and now it seems like it is working.