Hi,
I am kind of new to arduino but am using it to read data from four load cells. The signal coming in is digital and I am able to read and export (via serial) 2 of the sensors’ data simultaneously. However, when I try to add a 3rd sensor, the program stops outputting any data.
I did a little test to see what causes the data to stop and found that after the setup of the second sensor, the code just stopped running.
I attempted to increase the Baud rate from 9600 to 19200 but this had no effect.
The digital data in comes from a hx711 and collected using the library for that ADC.
Would love to understand why 3 sensors causes the arduino to just stop.
#include "HX711.h"
#define LOADCELL_DOUT_PIN 3
#define LOADCELL_SCK_PIN 2
#define LOADCELL_DOUT_PIN2 5
#define LOADCELL_SCK_PIN2 4
#define LOADCELL_DOUT_PIN3 7
#define LOADCELL_SCK_PIN3 6
#define LOADCELL_DOUT_PIN4 9
#define LOADCELL_SCK_PIN4 8
HX711 scale;
HX711 scale2;
HX711 scale3;
HX711 scale4;
float calibration_factor = -7050; //-7050 worked for my 440lb max scale setup
void setup() {
Serial.begin(9600);
Serial.println("HX711 calibration sketch");
Serial.println("Remove all weight from scale");
Serial.println("After readings begin, place known weight on scale");
Serial.println("Press + or a to increase calibration factor");
Serial.println("Press - or z to decrease calibration factor");
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
scale.set_scale();
scale.tare(); //Reset the scale to 0
long zero_factor = scale.read_average(); //Get a baseline reading
Serial.print("Load Cell 1 Initialized");
Serial.println();
scale2.begin(LOADCELL_DOUT_PIN2, LOADCELL_SCK_PIN2);
scale2.set_scale();
scale2.tare();
long zero_factor2 = scale2.read_average();
Serial.print("Load Cell 2 Initialized");
Serial.println();
scale3.begin(LOADCELL_DOUT_PIN3, LOADCELL_SCK_PIN3);
Serial.print("1");
scale3.set_scale();
Serial.print("2");
scale3.tare();
Serial.print("3");
long zero_factor3 = scale3.read_average();
Serial.print("Load Cell 3 Initialized");
Serial.println();
scale4.begin(LOADCELL_DOUT_PIN4, LOADCELL_SCK_PIN4);
scale4.set_scale();
scale4.tare();
long zero_factor4 = scale4.read_average();
Serial.print("Load Cell 4 Initialized");
Serial.println();
}
void loop() {
scale.set_scale(calibration_factor); //Adjust to this calibration factor
scale2.set_scale(calibration_factor);
scale3.set_scale(calibration_factor); //Adjust to this calibration factor
scale4.set_scale(calibration_factor);
Serial.print(scale.get_units(), 1);
Serial.print(" ");
Serial.print(scale2.get_units(), 1);
Serial.print(" ");
Serial.print(scale3.get_units(), 1);
Serial.print(" ");
Serial.print(scale4.get_units(), 1);
Serial.println();
}
Serial Monitor:
HX711 calibration sketch
Remove all weight from scale
After readings begin, place known weight on scale
Press + or a to increase calibration factor
Press - or z to decrease calibration factor
Load Cell 1 Initialized
Load Cell 2 Initialized
12