Thermocouple type K returns the NaN value when the temperature increases

Hello, I am reading a type K thermocouple sensor on an arduino portenta machine.
Library used: Arduino_MachineControl new version.
It reads the normal value when the temperature has not increased.
The problem is that when the sensor starts to increase in temperature, it returns the NaN value.

Here is the temperature when it is normal
image

Here is the temperature when it is increase
image

BUT!!!!
A very miraculous thing, somehow when I tried to read this sensor twice at the same time
This way:
temp_probes.selectChannel(0);
pLvSensor->pmcSensor.heaterSensor.temperature = temp_probes.tc.readTemperature(PROBE_K); // need to read double time to fix the issue : "nan" fault returrn
pLvSensor->pmcSensor.heaterSensor.temperature = temp_probes.tc.readTemperature(PROBE_K); // TODO: check root cause

As a result, it returned the correct value on the second reading.
image

I think the problem may lie in the spi function receiving data. Can you help me find the cause for this?

For informed help, please read and follow the directions in the "How to get the best out of this forum" post, linked at the head of every forum topic.

1 Like

Please identify the hardware used to receive the Type K signal an output it to the Arduino board.

I will take a SWAG and say your SPI is either in the wrong mode or sending an incorrect number of clocks.

This probably wont help but NaN is usually the result of division by zero or the square root of a negative number.