Failure of measuring temperature using arduino nanoesp32 and max6675module

I have been using an arduino nano esp32 and max6675 module for temperature measurement. The board is 2.0.13 version.

It was working perfectly for temperature measuring three weeks back but now all of a sudden, it has stopped working in fact the code is just giving 0.0 deg (error response). we changed the arduino, cables, the sensor and the module but it still does not work.

The power is 3.25V verified by multimeter. We have already triple checked all the connections (also with the multimeter) and the pin arrangement. The shared GND between the board and the module is correct. Everything is firmly connected.

The code I am using is completely basic and is basically only creating a connection and starting the module. The arduino is reacting as it should. There is no difference when i take the sensor off, so it's like it can't even see whether one is connected.

The last time it worked was three weeks back and it accurately measured the temperature. I have no more ideas on what could be possibly wrong.

Please code, in code tags, and schematics. Pen, paper and a posted foto is fine.

#include "max6675.h" 

const int thermoSCK = 13;
const int thermoCS =  10;
const int thermoSO = 12;

MAX6675 thermocouple(thermoSCK, thermoCS, thermoSO);

void setup() {
  Serial.begin(115200); 
  while (!Serial) { ; } 
  delay(2000);
  Serial.println("MAX6675 Thermoelement test"); 
}

void loop() {
  float temp = thermocouple.readCelsius(); 
  if (isnan(temp)) {
    Serial.println("Fehler: Thermoelement nicht verbunden!");
} else if (temp > 2000) { 
    Serial.println("Fehler: Thermoelement offen oder Spannung instabil!");
} else {
    Serial.print("Temperatur: ");
    Serial.print(temp);
    Serial.println(" °C");
}
  delay(1000);
} 

@akhjos

Assuming it is my library, - GitHub - RobTillaart/MAX6675: Arduino library for MAX6675 chip for K type thermocouple · GitHub

could you add these two lines and post the output of the sketch?

#include "max6675.h" 

const int thermoSCK = 13;
const int thermoCS =  10;
const int thermoSO = 12;

MAX6675 thermocouple(thermoSCK, thermoCS, thermoSO);

void setup() {
  Serial.begin(115200); 
  while (!Serial) { ; } 
  delay(2000);
  Serial.println("MAX6675 Thermoelement test"); 
}

void loop() {
  float temp = thermocouple.readCelsius(); 
  if (isnan(temp)) {
    Serial.println("Fehler: Thermoelement nicht verbunden!");
  } else if (temp > 2000) { 
      Serial.println("Fehler: Thermoelement offen oder Spannung instabil!");
  } else {
      Serial.print("Temperatur: ");
      Serial.print(temp);
      Serial.println(" °C");
  }

  //  ADD STATUS 
  uint8_t status = thermocouple.getStatus();
  Serial.println(status, HEX);

  delay(1000);
}
Define value Description Action Notes
STATUS_OK 0 OK
STATUS_ERROR 4 Thermocouple short to VCC check wiring
STATUS_NOREAD 128 No read done yet check wiring only before first read()
STATUS_NO_COMMUNICATION 129 No communication check wiring

128 = 0x80
129 = 0x81

We used the library by Adafruit. But if we change it to yours and add these lines, we get:

MAX6675 Thermoelement test

Temperatur: 0.00 °C

0

Temperatur: 0.00 °C

0

Temperatur: 0.00 °C

0

OK, the zero status seems to indicate that all bits clocked in are zero.
That points possible to grounding of the data-pin.
So triple check the hardware connections.

If you have access to a logic analyzer, you might be able to confirm there is no data on the data-pin.


what was the output of the code in the first post (1) with the Adafruit library?

If you changed everything and used the same code, then it very hard to believe that it ever worked.

What were you measuring the temperature of when it did work?

Is that the once working or the failure creating schematics?

The Output was:

MAX6675 Thermoelement test

Temperatur: 0.00 °C

Temperatur: 0.00 °C

Temperatur: 0.00 °C...

It's not exactly the same code. The last version was much more complicated and was built on this. But everything else in the last working version has nothing to do with the measurement of the heat.

We were measuring the temperature of the room to test wether it works. Same as now.

Both. It is the version i tried first because i have never done anything with arduino before. I than kept adding to the code and in the end everything worked. Than it stopped (without changing it) and since I could not figure out why I used the first version again to see wether this would work. And it didn't.

Something is broken. Try and change cables to begin with.

I already did. Multiple times. And with the multimeter all the cables seem fine.

Hypothesis
When it worked, did it have another power supply ?
Usb, battery, wall power supply, whatever?

It is getting power through a usb cable which is connected to my laptop. I tried the same cable and the same laptop but also multiple other cables and one other laptop. Also: the arduino is getting power. I can see the light and the communication is working (at least i am getting output that changes if i change the code).

@bumblebee4 are you working with @akhjos ?

Yes, we are working together

In the IDE do you have the "By Arduino" pin numbering selected?

Yes, I do. (And i already tried GPIO)

Try this code, it should print out a "1" if the SO wire is connected or not.
If you get 0 in both cases then something is wrong with the ESP.
If you get 0 when connected and 1 when not, then there is something wrong with the MAX6675

const int thermoSCK = 13;
const int thermoCS = 10;
const int thermoSO = 12;

void setup()
{
  Serial.begin(115200);
  while (!Serial) { ; }
  delay(2000);
  Serial.println("MAX6675 test");

  pinMode(thermoSCK, OUTPUT);
  pinMode(thermoCS, OUTPUT);
  pinMode(thermoSO, INPUT_PULLUP);

  digitalWrite(thermoSCK, HIGH);
  digitalWrite(thermoCS, HIGH);
}

void loop()
{
  int SOdata = digitalRead(thermoSO);
  Serial.print(SOdata);
  Serial.println();
  delay(1000);
}