GithubHelp home page GithubHelp logo

Calibration help about hx711 HOT 10 CLOSED

bogde avatar bogde commented on July 17, 2024
Calibration help

from hx711.

Comments (10)

bogde avatar bogde commented on July 17, 2024

hello,

you just need to do the calibration once for each load cell, so you don't have to use the calibration function in your "production" code. you can just use parts of the included example to calibrate your load cell and get that constant value you need to use in your code.

also, you just need to use the tare function once, when you start weighting, for instance before placing the beehive on the scale (or just after you placed it if you want to get the weight of the honey only).

let me know if you have any questions.

btw, what do you plan to use for gsm communication?

bogdan

from hx711.

NZbeek avatar NZbeek commented on July 17, 2024

Can you give me an example of the code I would use to get the calibration value?
So the tare function wont kick in each time the arduino wakes and runs the code? - effectively zeroing with the weight of the hive on it?
I will use a gsm Sim900 shield. This is just a prototype, I will go to a more barebones setup if it works well.
thanks for the response!

from hx711.

bogde avatar bogde commented on July 17, 2024

the calibration procedure is described in the readme file:

How to Calibrate Your Scale

Call set_scale() with no parameter.
Call set_tare() with no parameter.
Place a known weight on the scale and call get_units(10).
Divide the result in step 3 to your known weight. You should get about the parameter you need to pass to set_scale.
Adjust the parameter in step 4 until you get an accurate reading.

so you would do a simple program that does everything in setup(): call set_scale, call set_tare, output something like "you have 10 seconds to place a known weight on the scale" to the serial console, delay 10 seconds (while you place your weight), call get_units, divide the result to the known weight and output it to the serial console, something like that.

depending on your application you may or may now want to run the tare function every time the device is powered on. in your particular case, i wouldn't run it, but you know your requirements better.

from hx711.

NZbeek avatar NZbeek commented on July 17, 2024

something like:

#include "HX711.h"

// HX711.DOUT - pin #A1
// HX711.PD_SCK - pin #A0

HX711 scale(A1, A0); // parameter "gain" is ommited; the default value 128 is used by the library

void setup() {

Serial.println("You Have 20s to Place a Known weight on the Sensor:"); // Time delay to place weight

delay(20000);

scale.set_scale(); // this value is obtained by dividing the calibration value with the known weight;
scale.tare(); // reset the scale to 0

Serial.println("Calibration Value:"); // divide this bby the weight of the load used
}

void loop() {
Serial.print("Divide this by value by the weight used in desired output units e.g. Grams/Kilograms:\t");
Serial.print(scale.get_units(10));

scale.power_down(); // put the ADC in sleep mode
delay(1000);
scale.power_up();
}

from hx711.

NZbeek avatar NZbeek commented on July 17, 2024

Is it better to have the get_units take the average from more readings? - in the example I assume it is the average of 10 readings, but will the weight be more accurate if we used 100?

I am using a load cell rated at 300kg, but I am only using a 10kg sample weight to calibrate, will I get more accurate readings using a larger weight?

I also notice, when I have weight on, the values fluctuate dramatically, is this likely to just be because I haven't calibrated it successfully?

Thanks!

from hx711.

bogde avatar bogde commented on July 17, 2024

you have to call set_scale() and tare() before placing your weight on the scale, so before starting the 20 seconds delay.

i dont know if reading the sensor 100 times is more accurate, but most likely you will see less fluctuation in the resulting value.

i can't answer your other questions. i don't have extensive experience with load cells and don't know anything about your specific setup.

good luck with your project!

from hx711.

louiepaguilar avatar louiepaguilar commented on July 17, 2024

can someone please post an example of how to get the kilogram. im using 4pcs Human Body scale load cell sensor resistance strain 50kg half-bridge sensors ..

from hx711.

kbickham avatar kbickham commented on July 17, 2024

Thanks again for the code, but I am confused. There is no member in the library set
_tare(). I don't expect you to remember every piece of code you've written, but you are referring to the call (for an object instantiated as scale) scale.tare(); correct?

from hx711.

bogde avatar bogde commented on July 17, 2024

@kbickham yes, that's correct. i also updated my comment above.

from hx711.

bemar76 avatar bemar76 commented on July 17, 2024

This sketch could be helpfull:

#include "HX711.h"

const int PIN_SCK = 32;
const int PIN_DOUT = 33;

HX711 scale;

float calibration;

void setup() {
  Serial.begin(9600);
  scale.begin(PIN_SCK, PIN_DOUT);

  Serial.println("Please place a known weight on the scale and enter its weight:");

  scale.set_scale(); // this value is obtained by dividing the calibration value with the known weight;
  scale.tare(); // reset the scale to 0

  float m = 0;
  boolean f = 0;

  while (f == 0) {

    if (Serial.available() > 0) {
      m = Serial.parseFloat();
      if (m != 0) {
        Serial.print("Known mass is: ");
        Serial.println(m);
        f = 1;
      }
      else {
        Serial.println("Invalid value");
      }
    }
  }

  float unit = scale.get_units(20);

  Serial.print("Calibration Value: ");

  calibration = unit / m;

  Serial.println(calibration);
}

void loop() {
  Serial.print("Read: ");
  Serial.println(scale.get_units(20) / calibration);

  delay(100);
}

from hx711.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.