Go Down

Topic: Issue with thermocouple, MKR1010 with MKR Therm shield not producing temp values (Read 216 times) previous topic - next topic

djotaku

Did a search on the forums here and of the posts asking about thermocouples, no one else who was using the MKR Therm shield seemed to be complaining of the same issue.

To start, here are the components I'm using:

Arduino MKR Wifi 1010
MKR Therm Shield plugged in over the top of the MKR
Adafruit thermocouple - https://www.adafruit.com/product/3245

To eliminate any sources of it being my fault through faulty programming, I'm just running the code at the bottom of https://www.arduino.cc/en/Guide/MKRTHERMShield

As far as I can tell, the Therm shield is seated correctly and I'm using the right libraries because the reference temp it prints to the console makes perfect sense for the temperature of my room. (About 73-ish F when I convert from C which is close to what I've set the home thermostat to)

But my thermocouple temp reads as 1073741824.00 °C. Over at reddit someone commented this is 100 0000 0000 0000 0000 0000 0000 0000 binary - so maybe an error code?

The thermocouple comes from Adafruit with maybe 1/8-1/4" wire exposed which isn't enough to reach into the inputs for the THERM shield, so I removed the shrink wrap at the end and exposed more wire. Still get similar readings.

I tried many times and mostly get that number. For maybe 1 minute I was able to get it to read about 10°C less than the room temp, but then it went back to 1073741824.00 °C.

Because the fiberglass was frayed when I got the thermocouple, I asked for a replacement from Aadafruit and the replacement displays the same behavior. So (possibly) not a hardware issue?

I ordered a new thermocouple from Amazon that comes wired with a K-type ending and I'll be able to try that today, so I don't know if that'll fix the issue when I can just plug it straight into the K-input on the board.

Just to reiterate my settings in case there's something easy and silly I've missed - this is the second Arduino/shield combo I've ever used. And just like my previous experience I just took the THERM board and made sure that the writing on the black connectors matched w/ the MKR board and just inserted the board's "feet" into the same black connectors on the MKR board. I didn't connect anything else (besides the thermocouple, of course). So if there are any additional things I need to connect - I don't know about them.

Thanks for any help!
github: https://github.com/djotaku
hackaday.io: https://hackaday.io/djotaku

pert

This is my favorite MAX31855 library:
https://github.com/RobTillaart/Arduino/tree/master/libraries/MAX31855

The reason is that it makes it easy to detect error states. The way it works is you call the read() function to read the temperature from the thermocouple, but read() doesn't return the temperature reading like the Arduino_MKRTHERM library's readTemperature() function does. Instead, read returns the status, which is one of the following:
Code: [Select]
#define STATUS_OK               0x00
#define STATUS_OPEN_CIRCUIT     0x01
#define STATUS_SHORT_TO_GND     0x02
#define STATUS_SHORT_TO_VCC     0x04
#define STATUS_ERROR            0x07
#define STATUS_NOREAD           0x80


There are also some convenience functions for dealing with the status:
Code: [Select]
    uint8_t getStatus(void) const       { return _status; };
    // next 4 applies to last read
    inline  bool statusError() { return (_status & STATUS_ERROR) != 0; };
    inline  bool shortToGND()  { return (_status & STATUS_SHORT_TO_GND) != 0; };
    inline  bool shortToVCC()  { return (_status & STATUS_SHORT_TO_VCC) != 0; };
    inline  bool openCircuit() { return (_status & STATUS_OPEN_CIRCUIT) != 0; };


To get the temperature that was read during the call to read(), there is a separate function getTemperature().

So the library is slightly more complex to use than the Arduino_MKRTHERM library, but it allows you to achieve a higher level of reliability. If read() returns an error code then certainly you would not want your device to take any action based on the temperature reading, since it's unlikely to be correct.

Don't make the mistake of assuming that you are required to use the Arduino_MKRTHERM library just because you have an Arduino MKR Therm shield. It's just a standard MAX31855 chip on that shield. There's no special magic to it. Any MAX31855 library that is compatible with the SAMD architecture will work. There are multiple MAX31855 libraries available. The Adafruit library is also popular. I tested all the libraries I could find a few years ago when I made an Arduino-based temperature controller for my kiln with the MAX31855 and the RobTillaart library was the winner for me simply because I liked this design. The Adafruit library is probably the most popular.

Unfortunately, RobTillaart has lumped this library into a repository with a lot of other libraries and sketches and this makes it a little bit challenging to install. Here's how you do it in the Arduino IDE:
  • Download the repository: https://github.com/RobTillaart/Arduino/archive/master.zip
  • Unzip the downloaded file.
  • (In the Arduino IDE) Sketch > Include library > Add .ZIP Library
  • Select the Arduino-master/libraries/MAX31855 folder from the unzipped folder.
  • Click the "Open" button.
  • Wait until the Arduino IDE indicates that the library was successfully installed on the status bar.


You can now see that, despite the name of the menu item, "Add .ZIP Library" can be used to install libraries from folders as well as .zip files.

You'll find example sketches that demonstrate the usage of the library under the File > Examples > MAX31855 menu.

pert

I forgot to say that if you're using the Arduino Web Editor the library installation process is slightly different and I'm happy to provide those instruction on request.

djotaku

Before I move on to using that library you mentioned, I have an interesting observation that means maybe I'm missing something critical about the way that the arduino MKR works vs the Arduino Uno (which doesn't have bottom feet (feet being the wire leads on the bottom). If I touch the MKR's feet to my hand or arm, suddenly the readings are rational. They're off from the on-chip ref temp by about 10 deg C, but they seem to make some sense. Am I supposed to be doing something with the MKR and the feet?
github: https://github.com/djotaku
hackaday.io: https://hackaday.io/djotaku

pert

No. You shouldn't need to do anything with the pins (they're called "pins", not "feet") on the MKR WiFi 1010 to get the MAX31855 to read from the thermocouple correctly. However, you should be very careful to not place the MKR WiFi 1010 on any conductive objects that will short the pins (e.g., a metal table, coins, scraps of bare wire). Doing something like that could indeed interfere with the readings. The MKR WiFi 1010 comes with its pins stuck in black anti-static foam. This foam is electrically conductive so you need to remove it from the MKR WiFi 1010 before using the board.

The behavior you're seeing makes me think there could be a problem with the ground.

djotaku

Do I need to separately connect ground to something? I just have it sitting on my wooden desk. Is it ok that the THERM is going into the MKR vs the MKR going into the THERM?
github: https://github.com/djotaku
hackaday.io: https://hackaday.io/djotaku

pert

Do I need to separately connect ground to something?
No. You shouldn't need to connect the ground pin on your MKR WiFi 1010 to anything. However, you should be careful that your thermocouple is not grounded. For example, on my kiln, which has a grounded metal case, I need to be careful to insulate the thermocouple wires so that the bare wires don't make contact with the metal case where they penetrate it.

I just have it sitting on my wooden desk.
That's fine.

Is it ok that the THERM is going into the MKR vs the MKR going into the THERM?
Yes, it's OK. It makes no different how you stack them.

djotaku

so do you think my shield arrived messed up? Or is there something I should run with that other library you mentioned to debug? I've done a fair amount of software programming, but this is my first time doing hardware stuff since undergrad 20 years ago. So I'm not sure what to do for debugging.
github: https://github.com/djotaku
hackaday.io: https://hackaday.io/djotaku

pert

so do you think my shield arrived messed up?
I don't see any evidence of that.

is there something I should run with that other library you mentioned to debug?
Yes. Print the return value of the MAX31855 library's read() function to Serial Monitor. Then you'll know if the MAX31855 is indicating an error condition, and which condition.

djotaku

Looks like your guess was right. But I'm not sure what to do now. I ran the example code max31855_test_error sketch.

Here's the output:

stat:      7
error:      SHORT TO GROUND
SHORT TO VCC
OPEN CIRCUIT
internal:   -0.062
temperature:   -0.25
stat:      7
error:      SHORT TO GROUND
SHORT TO VCC
OPEN CIRCUIT
internal:   -0.062
temperature:   -0.25
stat:      7
error:      SHORT TO GROUND
SHORT TO VCC
OPEN CIRCUIT
internal:   -0.062
temperature:   -0.25
stat:      7
error:      SHORT TO GROUND
SHORT TO VCC
OPEN CIRCUIT
internal:   -0.062
temperature:   -0.25
stat:      0
internal:   0.000
temperature:   0.00
github: https://github.com/djotaku
hackaday.io: https://hackaday.io/djotaku

djotaku

If I change the USB cable, I get mostly:

stat:      0
internal:   0.000
temperature:   0.00
stat:      0
internal:   0.000
temperature:   0.00
stat:      0
internal:   0.000
temperature:   0.00
stat:      0
internal:   0.000
temperature:   0.00
stat:      0
internal:   0.000
temperature:   0.00
stat:      0
internal:   0.000
temperature:   0.00
stat:      0
internal:   0.000
temperature:   0.00
stat:      0
internal:   0.000
temperature:   0.00
stat:      0
internal:   0.000
temperature:   0.00
stat:      0
internal:   0.000
temperature:   0.00
stat:      0
internal:   0.000
temperature:   0.00
stat:      0
internal:   0.000
temperature:   0.00
stat:      0
internal:   0.000
temperature:   0.00

Better, I guess? But still not where I want to be
github: https://github.com/djotaku
hackaday.io: https://hackaday.io/djotaku

djotaku

OK - new and frustrating data point! I loaded Arduino IDE onto my laptop. Same problem. Then I disconnected my laptop from mains power - now it works perfectly!!! WTF?!?! What does this mean?

BTW - I'm in USA - 110V mains power.
github: https://github.com/djotaku
hackaday.io: https://hackaday.io/djotaku

Go Up