MAX31856 mit ESP§2

Hallo liebe Forummitglieder,

hoffe euch allen geht es gut!
Hab ein komisches Problem und vlt kann mir dabei jemand helfen.

Also hab die MAX31856 mit meine ESP32 HSPI verbunden (2 Stück).
Lustige ist, am Anfang funktioniert alles ok, dann aber kommt nur mehr nan als Wert.

EDIT: wenn ich den ESP§2 resette und dann ist die Ausgabe von Anfang an nan

Hier der Code:

// Basic example using one-shot measurement.
// The call to readThermocoupleTemperature() is blocking for O(100ms)

#include <Adafruit_MAX31856.h>

const uint8_t  SPI_CHIP_SELECT_1 {
  15
};     ///< Chip-Select PIN for Sensor1
const uint8_t  SPI_CHIP_SELECT_2 {
  4
};     ///< Chip-Select PIN for Sensor2
const uint8_t  SPI_MISO {
  12
};         ///< Master-In, Slave-Out PIN for SPI
const uint8_t  SPI_MOSI {
  13
};         ///< Master-Out, Slave-In PIN for SPI
const uint8_t  SPI_SYSTEM_CLOCK {
  14
};  ///< System Clock PIN for SPI
Adafruit_MAX31856 MAX31856_1 = Adafruit_MAX31856(SPI_CHIP_SELECT_1, SPI_MOSI, SPI_MISO, SPI_SYSTEM_CLOCK);
Adafruit_MAX31856 MAX31856_2 = Adafruit_MAX31856(SPI_CHIP_SELECT_2, SPI_MOSI, SPI_MISO, SPI_SYSTEM_CLOCK);

// Use software SPI: CS, DI, DO, CLK
// Adafruit_MAX31856 maxthermo = Adafruit_MAX31856(4, 13, 12, 14);
// use hardware SPI, just pass in the CS pin
// Adafruit_MAX31856 maxthermo = Adafruit_MAX31856(10);

void setup() {
  Serial.begin(115200);
  while (!Serial) delay(10);
  Serial.println("MAX31856 thermocouple test");

  MAX31856_1.begin();
  MAX31856_2.begin();

  MAX31856_1.setThermocoupleType(MAX31856_TCTYPE_K);
  MAX31856_2.setThermocoupleType(MAX31856_TCTYPE_K);

  Serial.print("Thermocouple type MAX31856_1: ");
  switch (MAX31856_1.getThermocoupleType() ) {
    case MAX31856_TCTYPE_B: Serial.println("B Type"); break;
    case MAX31856_TCTYPE_E: Serial.println("E Type"); break;
    case MAX31856_TCTYPE_J: Serial.println("J Type"); break;
    case MAX31856_TCTYPE_K: Serial.println("K Type"); break;
    case MAX31856_TCTYPE_N: Serial.println("N Type"); break;
    case MAX31856_TCTYPE_R: Serial.println("R Type"); break;
    case MAX31856_TCTYPE_S: Serial.println("S Type"); break;
    case MAX31856_TCTYPE_T: Serial.println("T Type"); break;
    case MAX31856_VMODE_G8: Serial.println("Voltage x8 Gain mode"); break;
    case MAX31856_VMODE_G32: Serial.println("Voltage x8 Gain mode"); break;
    default: Serial.println("Unknown"); break;
  }
  Serial.print("Thermocouple type MAX31856_2: ");
  switch (MAX31856_2.getThermocoupleType() ) {
    case MAX31856_TCTYPE_B: Serial.println("B Type"); break;
    case MAX31856_TCTYPE_E: Serial.println("E Type"); break;
    case MAX31856_TCTYPE_J: Serial.println("J Type"); break;
    case MAX31856_TCTYPE_K: Serial.println("K Type"); break;
    case MAX31856_TCTYPE_N: Serial.println("N Type"); break;
    case MAX31856_TCTYPE_R: Serial.println("R Type"); break;
    case MAX31856_TCTYPE_S: Serial.println("S Type"); break;
    case MAX31856_TCTYPE_T: Serial.println("T Type"); break;
    case MAX31856_VMODE_G8: Serial.println("Voltage x8 Gain mode"); break;
    case MAX31856_VMODE_G32: Serial.println("Voltage x8 Gain mode"); break;
    default: Serial.println("Unknown"); break;
  }

}

void loop() {
  Serial.print("Cold Junction Temp: ");
  Serial.println(MAX31856_1.readCJTemperature());

  Serial.print("Thermocouple Temp: ");
  Serial.println(MAX31856_1.readThermocoupleTemperature());
  // Check and print any faults
  uint8_t fault_1 = MAX31856_1.readFault();
  if (fault_1) {
    if (fault_1 & MAX31856_FAULT_CJRANGE) Serial.println("Cold Junction Range Fault");
    if (fault_1 & MAX31856_FAULT_TCRANGE) Serial.println("Thermocouple Range Fault");
    if (fault_1 & MAX31856_FAULT_CJHIGH)  Serial.println("Cold Junction High Fault");
    if (fault_1 & MAX31856_FAULT_CJLOW)   Serial.println("Cold Junction Low Fault");
    if (fault_1 & MAX31856_FAULT_TCHIGH)  Serial.println("Thermocouple High Fault");
    if (fault_1 & MAX31856_FAULT_TCLOW)   Serial.println("Thermocouple Low Fault");
    if (fault_1 & MAX31856_FAULT_OVUV)    Serial.println("Over/Under Voltage Fault");
    if (fault_1 & MAX31856_FAULT_OPEN)    Serial.println("Thermocouple Open Fault");
  }

  Serial.print("Cold Junction Temp: ");
  Serial.println(MAX31856_2.readCJTemperature());

  Serial.print("Thermocouple Temp: ");
  Serial.println(MAX31856_2.readThermocoupleTemperature());
  // Check and print any faults
  uint8_t fault_2 = MAX31856_2.readFault();
  if (fault_2) {
    if (fault_2 & MAX31856_FAULT_CJRANGE) Serial.println("Cold Junction Range Fault");
    if (fault_2 & MAX31856_FAULT_TCRANGE) Serial.println("Thermocouple Range Fault");
    if (fault_2 & MAX31856_FAULT_CJHIGH)  Serial.println("Cold Junction High Fault");
    if (fault_2 & MAX31856_FAULT_CJLOW)   Serial.println("Cold Junction Low Fault");
    if (fault_2 & MAX31856_FAULT_TCHIGH)  Serial.println("Thermocouple High Fault");
    if (fault_2 & MAX31856_FAULT_TCLOW)   Serial.println("Thermocouple Low Fault");
    if (fault_2 & MAX31856_FAULT_OVUV)    Serial.println("Over/Under Voltage Fault");
    if (fault_2 & MAX31856_FAULT_OPEN)    Serial.println("Thermocouple Open Fault");
  }
  delay(1000);
}

Hier die Ausgabe:

MAX31856 thermocouple test
Thermocouple type MAX31856_1: K Type
Thermocouple type MAX31856_2: K Type
Cold Junction Temp: 28.23
Thermocouple Temp: 27.41
Cold Junction Temp: 28.27
Thermocouple Temp: 27.27
Cold Junction Temp: 28.27
Thermocouple Temp: nan
Cold Junction Temp: 28.30
Thermocouple Temp: nan
Cold Junction Temp: 28.11
Thermocouple Temp: nan
Cold Junction Temp: 28.16
Thermocouple Temp: nan
Cold Junction Temp: 28.08
Thermocouple Temp: nan
Cold Junction Temp: 28.11

Jemand eine Idee was ich da falsch gemacht habe?

Danke

Lg

Lass dir mal fault_1 und fault_2 ausgeben als Zahl

Hallo,
sorry für die späte Antwort.
Nachdem ich 1 tag mit suchen und googeln verbracht habe, bin ich drauf gekommen, dass es was mit der Zeit zu tun hat. Da gibt es verschiedene "modes" in der lib.
Aber ich muss mir noch genau ansehen was das Problem ist.

Falls jemand schon mal sowas hatte, bitte ich um tipps.

Danke

Lg

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