Communicating mailbox project with hx711 amplifier


Hello, I work with this HX711 amplifier, for a communicating mailbox project, when there is a letter / parcel, it sends a notification to a phone :smiley: (With Arduino board), I would like to know how many bytes are transferred per second and how to do the tare once the support plate was installed.Thanks ! And finally I show you my code !


    // Hx711.DOUT - pin #A2
    // Hx711.SCK - pin #A3

    #include <hx711.h>

    Hx711 scale(A2, A3);

    //u: Variable detection package
    const float u = 1000; //If greater than 1000 g = package
    void diff ();

    void setup() {

    void loop() {
      Serial.print(scale.getGram(), 1);
      Serial.println(" g ");

        /*@description: Weight of the object
       *@content: Weight in gram 
      float z;

       * @description: 1: letter || 2: parcel || 0:nothing 
      unsigned int r; //unsigned 

      z = scale.getGram();

      r = diff(z); //r= 0 or 1 or 2

      //Output variable
      return r;


     * function diff: //Makes it possible to differentiate between: nothing - a package - a letter
    int diff (int i){
      if (i > 0){
        if (i < u){
          return 1; //letter 
          return 2; //parcel 
        return 0; //nothing

Thanks for your help !:smiley:


What do you mean by that

First, transfered between where and where?
And anyway, that only depends on your own code.

For the calibration, I use something like this

double doCalibration(double refWeight)
  double rawReading = 0.0;
  double calibrationFactor = 0.0;

  if (refWeight != 0.0) {
    // after taring use refWeight to calibrate the scale
    rawReading = scale.get_value(10);
    calibrationFactor = rawReading / refWeight;
  else {
    // without refWeight we do the tarring and return the raw tare reading
    // needs to be done before calibration with refWeight
    calibrationFactor = scale.get_offset();

  return calibrationFactor;

With this library


Hello ,thanks for your reply, bytes transfered between the “DAT” pin , Amplifier -> to arduino , i mean when you place a weight on the plate , for example 10 g = how many bytes ?
In the documentation it is specified 10SPS or 80SPS ,what is SPS?

Thanks :grinning:


I’s think that SPS stands for samples per second where each sample will be a 24bit 2-complement number, but that only applies for continous sampling mode with XI LOW.
But “my” lib does not use continous sampling mode but on demand. So you will only request on 24bit chunk with each read request and nothing more.


Ok i see , I have one last question to calibrate my sensor I have to operate the calibration code independently of the one I did?


I don’t follow.
I don’t see any calibration code in your post.
And sure “calibration” is a one-time action and would be done independently of the measuring action.

Having said that, I’d also suggest to have the values found during calibration stored in EEPROM to have them reapplied after a reset or powerloss.


Ok thanks so I can make a separate code