Drifting Load cell in a stable environment

Hi

FYI A lot has changed from start of tread, read all if you struggle with load cell and LoRa, forum members has given me a lot of help, thanks!!!

UPDATE

Load cells 4x50 kg I have found this one, with datasheet, I dont have price but I will buy 40 pcs, GALOCE-load cell weighing solution provider
This type is used by a bee monitoring company.
From Datasheet:

24bit ADC NAU7802
Sparkfun even has a brake out board: SparkFun Qwiic Scale - NAU7802 - SEN-15242 - SparkFun Electronics
Also a library available

Chip: https://www.nuvoton.com/resource-files/NAU7802%20Data%20Sheet%20V1.7.pdf

Trouble to use LiPo batt in winter time.
I change from LiPo as main source to superCap, 5.5V 10F, works down to -40 Celsius. Can run my system for 190 times (2 sec run time between sleep)
I use LiPo if superCap strugle to charge, I do not charge LiPo if below 5C

Using 74HC393PW to select power source Super Cap og LiPo.This also give option to switch off LiPo charging (if cold outside).

I can choose what power source to use.

Also added option to switch off 3.3/5v to peripherals, can choose to only give 3.3 to ESP32

Also add a photo resistor to make longer sleep when dark (winter/night).---> Change: I use solar panel to measure dark/light, not photo resistor.

////////////////////////////////////////////////////////////////////////////////////////////////////////

V3 PCB (see post ca 150)

Final sender PCB, and receiver (OLD v2):

Home assistant view:

HX711 is placed on a100% copy of open source PCB layout. Both VCC and VDD is connected.

For LORA module with 868 mHz AI thinker don't have a bord with IPEX connector so that is added, then I can use an external antenna or solder a copper coil antenna to PCB, 2 options.

[
UPDATE:
3)
I needed to enable CRC coding to avoid to compute random received LoRa packages that messed up my graphs in Home Assistant. I used Rob TIllaart's CRC library and example codes and demo code (thanks @robtillaart )
Now only LoRa packages with correct CRC code are computed. Seems to work as it should.
As a consequence I no longer use lora.h library.

My scale (and other sensors on system) is running 24/7 with a changing load.

This is what my hive system is sending as payload over LoRa:

  vekt            = myPayload.vekt;
  pakkeNr         = myPayload.pakkeNr;
  BStempKube      = myPayload.BStempKube;
  BStempUte       = myPayload.BStempUte;
  DHTtempKube     = myPayload.DHTtempKube;
  DHTfuktKube     = myPayload.DHTfuktKube;
  alarmValue      = myPayload.alarmValue;
  kubeNr          = myPayload.kubeNr;
  volt            = myPayload.volt;
  senderVersjonNr = myPayload.senderVersjonNr;

To read load on scale after sleep/reboot the calFact and Scale offset/Zero value must be stored in memory, then when restart read mem and calculate load.

Added 2 buttons to shuffle true latest received packages per hive (Wife has 9 bee hives) and present on OLED. To manage this I store by hiveNo each reading, if new data from same hive the previous data is over written, I store then only one package pr hive.
This is per today on chips memory, that will eventually damage the mem, so next is to add a SD card, which allready is placed on my LiLigo board.

Also read this tread: CRC test, dont work
@J-M-L and @srnet gave valuable info. I did not manage to get this work, maybe for the future.

With all help in this tread my system is now working and stable.
I have gone from ESP8266 to ESP32 WROOM, I find it much more stable, and easier to save battery with sleep functions.

  • I use the 150 kg cell, but Alibaba 4x 50 kg loadcells is also pretty stable, and almost for free...
  • NB! Use a heavy weight for calibration, i used 25 Kg. This will give better readings when load cell is 150 Kg
  • HX711 from Sparkfun, powered it with 3.3V and 5V, also use PCB layout from Spakfun to ensure a stable AD operation.
  • 2 x temp sensors BS18B20 waterproof
  • 1 x DHT22 for temp and humidity (may stop working due to clogging with propolis)
  • 1x Ai Thinker RA01H, 868Mhz, has no IPEX connector so I add on to the PCB
  • 1x 1cell Li-Ion 350 mA
  • 1 x solar panel 200 mA - Max volt 6.2 when in full sun
  • 1 x alarm switch NO
  • 3 x reed relays for calibrate, tare, reset

I have also made a code for autocalibration and zero factor, and store values to mem.

The scale I have built, 3D animation, look here

The receiver part is much easier, no external components, I use a Liiligo ESP32 with OLED

For presentation/history I run Home assistant on my NAS with Grafana and influxDB

You will find more info further down in this tread
]

Board I use is a ESP8266MOD (wemos type), compile it for NodeMCU v1.0 (ESP12).

I'm using this 150 kg load cell.

I have a "No Name" hx711, i have connected it to 3.3v
I have also connected E- to ground (same as ESP8266 ground), also shield in cable from hx711 is connected to ESP ground.


(Soldering with Norwegian Sausage fingers:)

I use library from https://github.com/bogde/HX711. From Sparkfuns load cell example https://learn.sparkfun.com/tutorials/load-cell-amplifier-hx711-breakout-hookup-guide/all

For a 1 kg test I see drift from 998 to 1109 grams witch is near 11% (I may need a bigger load)

I have previously tested library from Olav Kallhovd: https://github.com/olkal/HX711_ADC that also drifted in my setup.

My test rig is standing in a room with stable temperature around 22 C.

Any ideas how to improve this?
Can the hx711 be the reason for the drift, I maybe need to buy one from Sparkfun?

Code I use to set calibration factor + serial output to read weight is (from sparkfun):

/*

  Example using the SparkFun HX711 breakout board with a scale
  By: Nathan Seidle
  SparkFun Electronics
  Date: November 19th, 2014
  License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).

  This is the calibration sketch. Use it to determine the calibration_factor that the main example uses. It also
  outputs the zero_factor useful for projects that have a permanent mass on the scale in between power cycles.

  Setup your scale and start the sketch WITHOUT a weight on the scale
  Once readings are displayed place the weight on the scale
  Press +/- or a/z to adjust the calibration_factor until the output readings match the known weight
  Use this calibration_factor on the example sketch

  This example assumes pounds (lbs). If you prefer kilograms, change the Serial.print(" lbs"); line to kg. The
  calibration factor will be significantly different but it will be linearly related to lbs (1 lbs = 0.453592 kg).

  Your calibration factor may be very positive or very negative. It all depends on the setup of your scale system
  and the direction the sensors deflect from zero state

  This example code uses bogde's excellent library: https://github.com/bogde/HX711
  bogde's library is released under a GNU GENERAL PUBLIC LICENSE

  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" //This library can be obtained here http://librarymanager/All#Avia_HX711

#define LOADCELL_DOUT_PIN D3
#define LOADCELL_SCK_PIN D4

HX711 scale;

float calibration_factor = 18.5; //preset value
void setup() {
  Serial.begin(57600);
  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(" g"); //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();
  //delay(1000);
  

  if (Serial.available())
  {
    char temp = Serial.read();
    if (temp == '+' || temp == 'a')
      calibration_factor += 0.1;
    else if (temp == '-' || temp == 'z')
      calibration_factor -= 0.1;
  }
}
2 Likes

Do you have a link to the data sheet and application notes?
How did you mount it?

1 Like

Hi DrDiettrich, thanks for answer.

LoadCell data further down.

Tread about Load cell connection here

Test resistors:
image

Data for load cell
Brand Name: XNQJALYCY
Origin: Mainland China
Output: Switching Transducer
Theory: Resistance Sensor
Model Number: load cel
Type: Biosensoris_customized: Yes
Material: Metal

Wiring
The way to connect to AD is:

Red power (+)

Green power (-)

White Output (+)

Black Output (-)

Technical Parameters:
Comprehensive error: 0.02% F.S
Sensitivity: 1.0 ± 0.1mv / v
Nonlinearity: 0.02% F.S.
Hysteresis: 0.02% F.S.
Importance: 0.02% F.S.
Creep: 0.02% F.S / 10 min
Zero output: ± 2% F.S
Input impedance: 405 ± 10Ω
Output impedance: 350 ± 3Ω
Insulation resistance: ≥ 5000MΩ (100VDC)
Excitation voltage: 5VDC ~ 12VDC
Temperature compensation range: 10 ℃ ~ +40 ℃
The use of temperature range: -20 ℃ ~ +60 ℃
Zero point temperature effect: 0.03% F.S / 10 ° C
Sensitivity Temperature Effect: 0.02% F.S / 10 ° C
Safety overload range: 120%
Limit overload range: 150%
Protection class: IP65

1 Like

I mean the direction of force. The many holes suggest to me a pull transducer, not push.

The data sheet says 5V to 12V

2 Likes

Yes, because most green ones need 5v, which is no good for 3.3 ESPs.

2 Likes

Hi again DrDiettrich

The data sheet says 5V to 12V

This was a surprise for me.... check before buy!!!

Do you know how I can feed it with correct volt?
What is the simplest way?

Don't completely understand your question:

The many holes suggest to me a pull transducer, not push.

The load cell is mounted for a vertical down force, I will place a bee hive on top. Data I send with LoRa.

The load cell has an arrow, this I assumed should point downwards.

I'd treat the 5v as a recommended minimum, not an absolute minimum.

The load cell can certainly be used with the 4.3 v excitation voltage of the HX711. It will output 4.3 mV at full scale instead of 5 mV, so there will be less meat for the HX711 to chew on, but it will still "work."

If you stay with the (Sparkfun!) HX711, you should not feed the load cell with any source other than the HX711 excitation output. For example, you may be tempted to power the load cell 12 v from some other source, but that would feed 6 v into the HX711 A- and A+ pins, which would probably kill it.

2 Likes

Only Sparkfun HX711 boards can be used with 3.3volt-logic ESP8266 boards directly.
The board pictured is 5volt-logic only.
3.3volt-logic HX711 boards have a 5volt supply for the load cell and a 3.3volt supply for the logic.

You could modify that board (see Sparkfun website), but you soldering skills...
Is that a lake of solder paste I see on the board.

We could have told you this from the start of your project in your two other cross-posts.
You would have known to include all the details if you had read the "how to post" sticky.
Leo..

2 Likes

I've been playing with a similar setup for some time now. I'm using a Pro Mini at 5V and a different (than yours) no name HX-711 board.

My code (below) uses no library (for the HX-711) it reads out counts.

First your %age calculations are misleading you. You have a 150 kg load cell so your error is:

(1000 - 1109)/ 150000 = < 1%

I have a feeling much of the variation is from the HX-711 but I'm still investigating.

/*
2022-09-01
    v001
    v002
    v002a
HX711 device prove out code.
Reads the HX711 Raw data. Developed using YZC-133 Load Cell

HX711 outputs 24 bits:   -8,388,608 to 8,388,607

Channel A can be programmed with a gain of 128 or 64,
corresponding to a full-scale differential input
voltage of ±20mV or ±40mV
Vexcitation on our board was 4.07Vdc

"filler" code converts the 24 bit two's compliment value
to a 32 bit two's compliment value, which the compiler understands.

https://www.exploringbinary.com/twos-complement-converter/

2022-09-06
	v002
	Added display and display calculations.


Notes on YZC-133 5kg
	Rated Output: 1.0 ±  0.15mV / V
	if Vexcitation = 4.07V
	5kg = 1mv * 4.07 = 4.07mv = 5kg.

	@gain = 128 then we are using only 1/5 of our range.
	8,388,607 *4.07 / 20 = ± 1,707,081


todo:
	add ability to leave waiting for data to go low after some period of time.
	fixed "while(_pin_data)" which caused spurious neg readings.

*/

#include <Wire.h>
#include "SSD1306Ascii.h"
#include "SSD1306AsciiWire.h"

#define I2C_ADDRESS 0x3C
#define _pin_data 2
#define _pin_slk 3

#define uint unsigned int

SSD1306AsciiWire oled;

//---------------------------------------------------------------------
void setup() {
    pinMode(_pin_data,INPUT);
    pinMode(_pin_slk, OUTPUT);

    Serial.begin(9600);
    delay(400);
    Serial.println("  setup v002a");

    Wire.begin();
	Wire.setClock(100000L);

	oled.begin(&Adafruit128x32, I2C_ADDRESS);

    oled.setFont(ZevvPeep8x16);  // Screen = 4 (0,2,4,6) lines X 16 characters (0 to 15)
    oled.clear();

    oled.SSD1306Ascii::setCursor(15*8,0);
    oled.print("g");

    oled.SSD1306Ascii::setCursor(9*8,2);
    oled.print("oz");
}

//---------------------------------------------------------------------

int32_t getValue(void);


//---------------------------------------------------------------------


void loop() {

    int32_t MeasCounts = getValue();

    oled.SSD1306Ascii::setCursor(1*8,0);
    oled.print(MeasCounts);
    oled.print("  counts  ");
    Serial.println(MeasCounts);
    delay(3000);

}


// --- Functions -------------------------------------------------------------

long getValue()
{
	byte data[3];
	while(digitalRead(_pin_data)) {}  // wait for data pin to go low.

	for (byte j = 3; j--;)
	{
		for (char i = 8; i--;)
		{
			digitalWrite(_pin_slk, HIGH);
			bitWrite(data[j], i, digitalRead(_pin_data));
			digitalWrite(_pin_slk, LOW);
		}
	}

	// add 25th clock pulse to put next reading at gain 128
	//  logic analyzer shows no delay is req'd to meet HX711 input req.
	digitalWrite(_pin_slk, HIGH);
	digitalWrite(_pin_slk, LOW);

    // Replicate the most significant bit to pad out a 32-bit signed integer
	uint filler;
	if (data[2] & 0x80) {
		filler = 0xFF;
	} else {
		filler = 0x00;
	}

	// Construct a 32-bit signed integer
	long value = ( static_cast<unsigned long>(filler)  << 24
					| static_cast<unsigned long>(data[2]) << 16
					| static_cast<unsigned long>(data[1]) << 8
					| static_cast<unsigned long>(data[0]) );

	return value;
}

1 Like

I thought for the most part everything was covered in your last two threads. You have a 150 kg load cell and you are loading it with a 1.0 kg test weight. That's about 0.66% of full scale for the cell. Not very much. Keep something else in mind. You have a very basic off the boat load cell designed for hobby use and hardly a precision laboratory grade temperature compensated load cell. For simple purposes we have tension, compression, alternating (does both) and bending which is what you have. Based on precision, load cells can be classified as ultra precision, precision, standard, and general-purpose. The off the boat flavors are at best general purpose.

Using a good quality DMM measure your load cell output. That is the Signal = and Signal -. Does the DC value drift? No load and your light load does it drift? Measure the excitation voltage, does it drift? You start there and work from there and using a good DMM with adequate resolution like 0.1 mV. A good high quality shear beam load cell 150 kg (330 Lb) can cost about $500 USD so don't have high expectations.

Finally the voltages you are seeing are normally the maximum allowable excitation voltages before self heating of the strain gauges starts. Good load cells have a sensitivity normally specified as for example: Rated Output: 3 mV/V ±0.0075 mV/V which means on a 150 kg load cell the full scale output voltage with 10.000 volts excitation would be 30.00 mV.

Ron

1 Like

11/150000 is not bad.

Hi all of you, thanks for helping me.

Seems to me that my weight may be OK when thinking about accuracy. Also when @DaveEvans pointed out I need 5V I will change XH711 board, so this weekend I will use a sparkfun HX711 board, and try to add a much bigger load for my test.

As mentioned, it is for a bee hive, and needed accuracy is not high, it is more like +- 1 kg. A full hive will have a weight up to 80 kg.

To @JohnRob: Today I started to change my code to a Pro Mini 5V, I hope I will make a prototype with this board this weekend.

What I'm struggling with is witch pins that is best to use on Pro Mini.
I have
1x HX711 Sparkfun
1x DHT20 Sprkfun
1x LoRa module AI-01
2x push buttons (tare + cube move alarm)

Pins I need to define is:
/*

  • Temp+humidity DHT20 2 pins (not sure, it is i2c bus and Pro Mini may be A4 (SDA), A5 (SCL))
  • DHTDOUT: ? A4
  • DHTCLK: ? A5
  • HX711 weight 2 pins
  • LOADDOUT: 2
  • LOADSCK: 3
  • LoRa 6 pins
  • SCK 13
  • MISO 16
  • MOSI 15
  • SS 14
  • RST 9
  • DIO0 A0
  • Push buttons 2 pins
  • Tare: A1
  • Move: A2
  • Totalt 12 pins
    */

If you can take a closer look to pins I appreciates your effort.

Here is my LoRa receiver oled ESP32, sender in this case is ESP8266, the one I will rebuild to Pro Mini
image

Data I send to web dashboard cayenne.com

Make sure you connect the analogue supply to 5volt and the digital supply to 3.3volt.
Leo..

1 Like

Hi

thanks @Wawa , I will double check.

I will power the Pro Mini from USB, so 5V I expect to be the RAW pin, as illustrated in picture under:

image

Wow, I never gave much thought to how much a bee hive weighs.

You should expect the colony and hive to vary between about 60 lbs to well over 300 lbs, depending on your location. You want the scale to be accurate to within few tenths of a percent (to within a half a pound or less). This should be checked out, especially for used scales, using various weights.

Reading The Scale is some interesting reading.). Never dreamed what went into all of this. Protocol for Scale Hive Measurements of the Honey Bee Nectar Flow

Ron

1 Like

Which ProMini.
The 3.3volt/8Mhz variant also requires that Sparkfun HX711 board with two supply pins.
Can use standard HX711 boards with the 5volt/16Mz ProMini.
Leo..

1 Like

I plan to use Pro Mini 5v 16mhz

I'm currently using a 5V Pro mini. Have had no functional issues.

1 Like

Hi all, again thanks for all help!

Today made new weight system, looks like a bathroom scale, only bigger

I used Sparkfun hx711 connected with 5V

Added 25 kg load

After 30 min the drift is down to 24,86, = 0.6% compared to 25 kg. Thats OK for my hives.

Readings, weight is presented in grams, will change in future.

Temp, humid, weight, packets received

That would be good! :slight_smile: Happy bees are productive bees.

Ron

1 Like