HX711 Code adjustment

Good morning,

I am doing a study on roll cages using strain gauges and I had to use an HX711 chip.

I have found code that is supposed to gather data from The strain gauge through the HX711 but for my application, I require to have 2 strain gauges taking readings at a time.

Can someone help me change that code I found to be used for 2 sensors labelled Sensor 1 and Sensor 2? Below is the code.

// Hx711.DOUT - pin #A2
// Hx711.SCK - pin #A3

#include <Hx711.h>

Hx711 scale(A2, A3);

void setup() 
{

Serial.begin(9600);
}

void loop() 
{

float value = scale.getGram();
Serial.print(value);
Serial.println(" mV");
delay(1000);
}

Thanks In advance.

I don't know if HX711 library allows more than one instance of itself to be launched - not all libraries are designed for this.
But if it does, you need to connect two HX711 modules each to their own pins:

// 1st HX711
// Hx711.DOUT - pin #A2
// Hx711.SCK - pin #A3

// 2nd HX711
// Hx711.DOUT - pin #4
// Hx711.SCK - pin #5


#include <Hx711.h>

// 1st scale object
Hx711 scale1(A2, A3);
// 2nd scale
Hx711 scale2(4, 5);

void setup() 
{
Serial.begin(9600);
}

void loop() 
{
//reading of 1st scale
float value = scale1.getGram();
Serial.print("Scale #1 = ");
Serial.print(value);
Serial.println(" mV");

//reading of 2nd scale
float value = scale2.getGram();
Serial.print("Scale #2 = ");
Serial.print(value);
Serial.println(" mV");
delay(1000);
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.