#include "HX711.h"
// HX711 circuit wiring
const int DT1 = 13;
const int SCK1 = 12;
const int DT2 = 14;
const int SCK2 = 27;
const int DT3 = 26;
const int SCK3 = 25;
const int DT4 = 33;
const int SCK4 = 32;
const int DT5 = 23;
const int SCK5 = 22;
const int DT6 = 21;
const int SCK6 = 19;
// Instantiate 6 weight sensors
HX711 s1;
HX711 s2;
HX711 s3;
HX711 s4;
HX711 s5;
HX711 s6;
void setup() {
Serial.begin(115200);
Serial.println("Foot forces");
Serial.println("Initializing the scale");
// Indicate the GPIOs for each sensor
s1.begin(DT1, SCK1);
s2.begin(DT2, SCK2);
s3.begin(DT3, SCK3);
s4.begin(DT4, SCK4);
s5.begin(DT5, SCK5);
s6.begin(DT6, SCK6);
s1.set_scale(420.0f); // Scaling constant for sensor 1
s1.tare(); // Reset the scale to 0
s2.set_scale(420.0f); // Scaling constant for sensor 2
s2.tare(); // Reset the scale to 0
s3.set_scale(420.0f); // Scaling constant for sensor 3
s3.tare(); // Reset the scale to 0
s4.set_scale(420.0f); // Scaling constant for sensor 4
s4.tare(); // Reset the scale to 0
s5.set_scale(420.0f); // Scaling constant for sensor 5
s5.tare(); // Reset the scale to 0
s6.set_scale(420.0f); // Scaling constant for sensor 6
s6.tare(); // Reset the scale to 0
Serial.println("Readings:");
}
void loop() {
// Print the average of 10 readings for each sensor
Serial.print("S1: ");
float sen1 = s1.get_units(10);
Serial.print(sen1, 1);
Serial.print(" kg | S2: ");
float sen2 = s2.get_units(10);
Serial.print(sen2, 1);
Serial.print(" kg | S3: ");
float sen3 = s3.get_units(10);
Serial.print(sen3, 1);
Serial.print(" kg | S4: ");
float sen4 = s4.get_units(10);
Serial.print(sen4, 1);
Serial.print(" kg | S5: ");
float sen5 = s5.get_units(10);
Serial.print(sen5, 1);
Serial.print(" kg | S6: ");
float sen6 = s6.get_units(10);
Serial.print(sen6, 1);
Serial.print(" kg | Total: ");
// Print the sum of all the sensors
Serial.print(sen1+sen2+sen3+sen4+sen5+sen6, 1);
Serial.println(" kg");
// Sleep mode in between readings for low power consumption
// s1.power_down();
// s2.power_down();
// s3.power_down();
// s4.power_down();
// s5.power_down();
// s6.power_down();
delay(3000);
// s1.power_up();
// s2.power_up();
// s3.power_up();
// s4.power_up();
// s5.power_up();
// s6.power_up();
}