bring repo up-to-date
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#include <HX711_ADC.h>
|
||||
|
||||
//HX711 constructor (dout pin, sck pin)
|
||||
HX711_ADC LoadCell_1(A3, A2); //HX711 1
|
||||
HX711_ADC LoadCell_2(A1, A0); //HX711 2
|
||||
|
||||
long t;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600); delay(10);
|
||||
Serial.println();
|
||||
Serial.println("Starting...");
|
||||
LoadCell_1.begin();
|
||||
LoadCell_2.begin();
|
||||
long stabilisingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilising time
|
||||
byte loadcell_1_rdy = 0;
|
||||
byte loadcell_2_rdy = 0;
|
||||
while ((loadcell_1_rdy + loadcell_2_rdy) < 2) { //run startup, stabilization and tare, both modules simultaniously
|
||||
if (!loadcell_1_rdy) loadcell_1_rdy = LoadCell_1.startMultiple(stabilisingtime);
|
||||
if (!loadcell_2_rdy) loadcell_2_rdy = LoadCell_2.startMultiple(stabilisingtime);
|
||||
}
|
||||
LoadCell_1.setCalFactor(100); // user set calibration value (float)
|
||||
LoadCell_2.setCalFactor(100); // user set calibration value (float)
|
||||
Serial.println("Startup + tare is complete");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
//update() should be called at least as often as HX711 sample rate; >10Hz@10SPS, >80Hz@80SPS
|
||||
//longer delay in scetch will reduce effective sample rate (be carefull with use of delay() in the loop)
|
||||
LoadCell_1.update();
|
||||
LoadCell_2.update();
|
||||
|
||||
//get smoothed value from data set + current calibration factor
|
||||
if (millis() > t + 250) {
|
||||
long a = LoadCell_1.getSingleConversionRaw();
|
||||
long b = LoadCell_2.getSingleConversionRaw();
|
||||
Serial.print("Load_cell 1 output val: ");
|
||||
Serial.print(a);
|
||||
Serial.print(" Load_cell 2 output val: ");
|
||||
Serial.println(b);
|
||||
t = millis();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user