Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement