gabbyshimoni icon

basicLoadCellExample

gabbyshimoni | PRO | 04/17/19 04:50:35 PM UTC | 0 ⭐ | 399 👁️ | Never ⏰ | []
C++ |

810 B

|

None

|

0 👍

/

0 👎

#include <HX711_ADC.h>
 
HX711_ADC LoadCell(4, 5); //HX711 constructor (dout pin, sck pin):
 
void setup() {
  Serial.begin(9600); delay(10);
  LoadCell.begin();
  long stabilisingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilising time
  LoadCell.start(stabilisingtime);
  if (LoadCell.getTareTimeoutFlag()) {
    Serial.println("Tare timeout, check MCU>HX711 wiring and pin designations");
  }
  else {
    LoadCell.setCalFactor(1.0); // user set calibration value (float)
    Serial.println("Startup + tare is complete");
  }
  LoadCell.setCalFactor(-400); // change this number based on your calibration test
}
void loop() {
  LoadCell.update();
  float loadVal = LoadCell.getData();
  Serial.print("Load_cell output val: ");
  Serial.println(loadVal);
  delay(100);
}

Comments