Guidance - Mega 2560 with 4 K-Type Sensors

Hello,

Can someone suggest the best solution for high quality and accurate, when using multiple, k-type shields?

I tried the MAX6675 with the sensors and the SPI library, is that the best solution? I had inaccurate numbers +- 2C.

Do you think it is because the shields are junk ( https://www.amazon.com/gp/product/B07QBPGVZZ/ ) or are the MAX6675 just not a good solution for using multiple of them?

I appreciate your time,
Matt

movieprodw:
I had inaccurate numbers +- 2C.

There could be many reasons for that, to eliminate one possible source, please post your entire sketch in code tags per the forum guidelines.

Oh, and how do you know the error, i.e. what are you comparing it with?

The MAX6675 datasheet here specifies temperature error of +/- 8 LSB (2C) and a cold-junction error of +/- 3C.

Did you try calibrating these thermocouples? A constant offset would be easy to remove

All I know is that thermocouples are a "pain" because they put-out very low voltages and when you amplify anything noise can be a problem. ...Theoretically, thermocouples are great because the temperature/voltage relationship depends on physics and unchanging laws of nature.

"Aaccuracy" can be calibrated. Noise & drift can be more difficult.

Personally, I'd use a solid state (semiconductor) temperature sensor if it works in the application.

Hello,

Sorry I was at work.

Please see the code below and here is an image of the build and the current results, the last 2 are way off, the actual temp is 66 degrees.

Link to image: Imgur: The magic of the Internet

RESULTS

66	68	32	32	
66	68	33	33	
66	68	33	33	
66	68	33	33	
66	68	34	34	
66	68	34	34	
66	68	34	35	
66	68	35	35	
66	68	35	35	
66	68	35	36	
66	68	36	36	
66	68	36	36	
66	68	36	37	
66	68	37	37	
66	68	37	37	
66	68	37	38	
66	68	38	38	
66	68	38	38	
66	68	38	39	
66	68	38	39	
66	68	39	39	
66	68	39	40	
66	68	39	40	
66	68	40	40	
66	68	40	40	
66	68	40	41	
66	68	40	41	
66	68	41	41	
66	68	41	42	
66	68	41	42	
66	68	41	42	
66	68	42	42

CODE

#include <SPI.h>

const byte max6675_num                  = 4;
const int max6675_cs_pins[max6675_num] = {35,33,31,29};

SPISettings max6675_spi(1000000, MSBFIRST, SPI_MODE1);

float max6675Read(int max6675_cs_pin)
{
  unsigned int data;
  SPI.beginTransaction(max6675_spi);
  digitalWrite(max6675_cs_pin, LOW);
  
  data = SPI.transfer16(0);
  
  digitalWrite(max6675_cs_pin, HIGH);
  SPI.endTransaction();
  
  if (data & 0x0004)
  {
    return NAN;
  }
  else
  {
    return (data >> 3) / 4;
  }
}


void setup()
{
  int i;
  
  for(i = 0; i < max6675_num; i++)
  {
    pinMode(max6675_cs_pins[i], OUTPUT);
    digitalWrite(max6675_cs_pins[i], HIGH);
  }
  
  SPI.begin();
  Serial.begin( 9600 );
  
}

void loop()
{
  const float mov_avg_alpha = .01;
  static float mov_avgs[max6675_num] = { -100, -100 };
  float value;
  int i;
  delay(4000);
  
  for (i = 0; i < max6675_num; i++)
  {
    value = max6675Read(max6675_cs_pins[i]);
    if(mov_avgs[i] == -100) mov_avgs[i] = value;
    mov_avgs[i] = mov_avg_alpha * value + (1 - mov_avg_alpha) * mov_avgs[i];
    
    Serial.print(round(mov_avgs[i] * 1.8 + 32));
    Serial.print("\t");
    
  }
  
  Serial.println();
}

movieprodw:
the actual temp is 66 degrees.

I asked you how you know that.

Hi,
Why are you using K type and for what use, temperature range?

An accuracy of +/- 2degC is what you expect with K type, they are designed for hundreds of DegC measurement.
If you are only measuring under 200DegC then use another tempsensor.

Tom.... :slight_smile:

Hi,
Ops pic.


You have got the red wire of the thermocouple connected to the negative input terminal?

Tom... :slight_smile:

Hi,
Can I suggest on the protobaord, you connect each of the modules to the power rails directly.
In the pic I can only see one or two connections so you are daisy chaining the power.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile:

Hello,

Thank you for your help.

I am using a Klein Tools CL210 to test the sensors before attaching them to the arduino.

We are measuring water pipe temps from 25-120 degrees.

What other sensors would you suggest? They need to be shielded.

I have the SO and SCK bussed to SO PIN 50 and SCK 52.

Matt

We are measuring water pipe temps from 25-120 degrees.

F or C?

I am sorry, 25-120 F.

I would absolutely love it if someone knew of a better sensor/shield.

The goal is that it will go in water pipes, there are 4 and if the temp gets to high +100 we know the heater is stuck on and if it gets below 32 we know the heater went out.

I have about 200 thermal couplers with the markings:
TC-21128s l=192* Type K

I do not need to use them but figured since I had them laying around I would.

Matt

There are these:
DS18B20-Waterproof-Digital-Humidity-Temperature-Sensor-Thermal-Probe

Thermocouples are not the sensor of choice for low temperatures , the voltage output is low and you rely on the performance of the cold junction compensation .

I’d second the DS18B20 , it’s digital
And gets around most of the accuracy issues associated with multiple shields and your poor layout using a prototype board

Awesome, thank you for the reference, I will buy a couple and test them asap.

I will grab these: https://www.amazon.com/Fevas-Temperature-Waterproof-Three-core-Shielded/dp/B07TL75283/ref=sr_1_1?dchild=1&keywords=shielded+DS18B20&qid=1584734179&sr=8-1