1

I'm working with t-type thermocouple and needs to read the temperature data using python on Raspberry Pi 3. I used Adafruit MAX31856 to connect the thermocouple to the Pi and and tried to read it using this module.

I want to read the temperature for an extended period of time so I tried to print it out in a while loop However, anytime I run my code, I only get few 'correct' readings then the temperature resets to 0 until I re-run the code again - see the attached image.

enter image description here

I don't know what is causing this, and I don't think this is a connection problem since it prints the correct temperature when I re-run the code without touching the set-up.

Does anyone know why the reading is resetting to 0?

Here is my code:

from Adafruit_MAX31856 import MAX31856
import time

# Raspberry Pi software SPI configuration.
CLK = 4
CS  = 22
DO  = 17
DI  = 27
sensor = MAX31856(clk=CLK, cs=CS, do=DO, di=DI)

while True:
    temp = sensor.readTempC()
    print('Thermocouple Temperature: {0:0.3F}*C'.format(temp))
    time.sleep(1.0)
  • 2
    I think you need to check for issues with Adafruit, if it's an issue with the software they will know. – joan May 15 '17 at 7:44
0

I got it working by moving sensor = MAX31856(clk=CLK, cs=CS, do=DO, di=DI) under the while loop. I learnt that resets sensor.

from Adafruit_MAX31856 import MAX31856
import time

# Raspberry Pi software SPI configuration.
CLK = 4
CS  = 22
DO  = 17
DI  = 27

while True:
    sensor = MAX31856(clk=CLK, cs=CS, do=DO, di=DI)
    temp = sensor.readTempC()
    print('Thermocouple Temperature: {0:0.3F}*C'.format(temp))
    time.sleep(1.0)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.