How to use the hX711 load cell and MAX6675 thermocouple in one code?

Hi, I use an Arduino Due, and I want to measure the HX711 load cell and MAX6675 thermocouple together.

HX711 communicates through DOUT and CLK, and thermocouple uses SPI communication.

If I use the right library individually, it works fine, but the moment I make the two into one code, the temperature sensor stops at 26 degrees or doesn’t work.
`
This is my code.

#include “HX711.h”
#define DOUT 4
#define CLK 5
#include “max6675.h”
int thermoDO = 74; //MISO - SDO; DO, DOUT, SO
int thermoCS = 52; //nCS, CS, CSB, CSN, nSS, STE
int thermoCLK = 76;

MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
HX711 scale;

float calibration_factor = -329; // this is my load cell Cal factor.
float Weight;

void setup() {
Serial.begin(115200);
scale.begin(DOUT, CLK);
scale.set_scale();
scale.tare(); //Reset the scale to 0
long zero_factor = scale.read_average(); //Get a baseline reading
}

void loop() {
Weight=scale.get_units();
Serial.print("Weight = “);
Serial.print(Weight);
Serial.print(”, ");
Serial.print("C = ");
Serial.println(thermocouple.readCelsius());
}

The other code (separated for the sensors) worked with the same pin numbers?

Did you really wire to the ICSP header? The used library doesn't use the SPI hardware so you can use any pins to connect the MAX6675.

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