0
\$\begingroup\$

I have a 100 gram load cell with the hx711 amplifier board. I have it wired up to an arduino nano with an NRF24L01 module to send the raw value to another arduino nano. The problem is that when I aply a force to the loadcell, the value gets larger until a certain point where it becomes negative and starts to get bigger from that negative number again. So for example:

  • No load : 500
  • Force aplied: 1000
  • More force: 1500
  • More force: 2000
  • More force: -2000
  • More force: -1500
  • More force: -1000

It is really weird. Everything worked before. I have updated the code a few times and made it simpler. I even had it set up so that the arduino only reads the value and sends it to serial monitor. That gave exactly the same behaviour. To give you a feeling for how much force is needed to reach this sort of limit. About 2 playing cards it can measure in the positive range en from 3 to 4 it becomes negative again. Then stacking to 5 or 6 it becomes positive and when 7 or 8 playing cards are on top of the loadcell the value becomes negative again.

I hope my description of the problem is sort of understandable. If more information is needed, let me know!

What could be the problem here?

EDIT: Thanks for the comments. I have found the problem: I had changed a variable in my code from long to int. That caused the problem. Here is the fixed code for anyone who is interested:

    #include "HX711.h"

    // HX711 circuit wiring
    const int LOADCELL_DOUT_PIN = 2;
    const int LOADCELL_SCK_PIN = 3;

    HX711 scale;


    #include <SPI.h>
    #include <nRF24L01.h>
    #include <RF24.h>
    RF24 radio(7, 8); // CE, CSN

    const byte address[6] = "00001";
    void setup() {
      Serial.begin(57600);
      scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
      radio.begin();
      radio.openWritingPipe(address);
      radio.setPALevel(RF24_PA_MIN);
      radio.stopListening();
    }
    long reading;
    int taredone = 0;
    long tarenumber;
    void loop() {
      if (taredone == 0){
        Serial.print("15 seconds to tare");
        delay(15000);
        tarenumber = scale.read_average(20);
        Serial.print("Tarevalue: ");
        Serial.println(tarenumber);
        Serial.print("zero value: ");
        Serial.println(scale.read()-tarenumber);
        reading = 1234567890
        radio.write(&reading, sizeof(reading));
        taredone = 1;
      }
    
      if (scale.is_ready()) {
        while (true) {
          reading = scale.read_average(10)-tarenumber;
          Serial.println(reading);
          radio.write(&reading, sizeof(reading));
          delay(10);
        }
      } 
      else {
        Serial.println("HX711 not responding or no loadcell connected");
      }
    
      delay(500);

    }
\$\endgroup\$
3
  • 4
    \$\begingroup\$ It sounds like a number that is unsigned is being treated as signed somewhere along the way. Double check all of the arithmetic that's being used to convert the raw readings from the ADC into application values. \$\endgroup\$
    – Dave Tweed
    Commented Aug 24 at 23:58
  • \$\begingroup\$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. \$\endgroup\$
    – Community Bot
    Commented Aug 25 at 1:04
  • \$\begingroup\$ The read value seams to be scrolled by 1 byte. Show your code to get help. \$\endgroup\$
    – Jens
    Commented Aug 25 at 13:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.