Hi everyone,
I'm working a project for reading from four load cells connected to an arduino Nano by HX711 amplifier. So far, I can read from one digital pin, so how can add the arguments for connecting multiple HX711 and read the values in the program. Could somebody help me please,
appreciated.
Here ismy program works perfectly with one load cell:
#include "HX711.h"
#define calibration_factor -117250.0 //This value is obtained using the SparkFun_HX711_Calibration sketch
#define DOUT 3
#define CLK 2
HX711 scale(DOUT, CLK);
const int numReadings = 10;
float readings[numReadings]; // the readings from the analog input
int readIndex = 0; // the index of the current reading
float total = 0; // the running total
float average = 0; // the average
void setup() {
Serial.begin(9600);
Serial.println("HX711 scale demo");
scale.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
scale.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
Serial.println("Readings:");
}
void loop() {
total = total - readings[readIndex]; // read from the sensor:
readings[readIndex] = scale.get_units(); // add the reading to the total:
total = total + readings[readIndex]; // advance to the next position in the array:
readIndex = readIndex + 1; // if we're at the end of the array...
if (readIndex >= numReadings) { // ...wrap around to the beginning:
readIndex = 0;
}
// calculate the average:
average = total / numReadings;
Serial.print("Reading_scale#1: ");
Serial.print(abs(average*0.453592),2); //scale.get_units() returns a float
Serial.print(" Kg"); //You can change this to lb but you'll need to refactor the calibration_factor
Serial.println();
delay(1);
}