Arduino Code | Adafruit MAX31865 RTD PT100 Or PT1000 Amplifier
Maybe your like
- Overview
- Pinouts
- Assembly
- RTD Wiring & Config
- Arduino Code
- Python & CircuitPython
- Python Docs
- F.A.Q.
- Downloads
- Single page
- Feedback? Corrections?
- Text View
-
Adafruit PT100 RTD Temperature Sensor Amplifier - MAX31865 $14.95 Add to Cart -
Adafruit PT1000 RTD Temperature Sensor Amplifier - MAX31865 $14.95 Add to Cart -
Platinum RTD Sensor - PT100 - 3 Wire 1 meter long $11.95 Add to Cart -
Platinum RTD Sensor - PT1000 - 3 Wire 1 meter long $14.95 Add to Cart
Arduino Code
You can easily wire this breakout to any microcontroller, we'll be using an Arduino. For another kind of microcontroller, as long as you have 4 available pins it is possible to 'bit-bang SPI' or you can use hardware SPI if you like. Just check out the library, then port the code.
SPI Wiring Since this is a SPI-capable sensor, we can use hardware or 'software' SPI. To make wiring identical on all Arduinos, we'll begin with 'software' SPI. The following pins should be used:
- Connect Vin to the power supply, 3V or 5V is fine. Use the same voltage that the microcontroller logic is based off of. For most Arduinos, that is 5V
- Connect GND to common power/data ground
- Connect the CLK pin to Digital #13 but any pin can be used later
- Connect the SDO pin to Digital #12 but any pin can be used later
- Connect the SDI pin to Digital #11 but any pin can be used later
- Connect the CS pin Digital #10 but any pin can be used later
Later on, once we get it working, we can adjust the library to use hardware SPI if you desire, or change the pins to other
Download Adafruit_MAX31865 libraryTo begin reading sensor data, you will need to the Adafruit MAX31865 library from the Arduino library manager.
Open up the Arduino library manager:
Search for the Adafruit MAX31865 library and install it
We also have a great tutorial on Arduino library installation at:http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use
Attach PT100 or PT1000 RTDYou'll need to attach an RTD, for this demo we'll be using a 3-wire 1 meter long one but you can adjust the demo if you have a 2 or 4 wire. Check the RTD wiring page for the jumpers and wiring requirements!
Load Demo Open up File->Examples->Adafruit_MAX31865->max31865 and upload to your Arduino wired up to the sensor. Adjust the max.begin(MAX31865_3WIRE) line if necessary.
Upload to your Arduino and open up the serial console at 115200 baud to see a print out of the sensors data. The MAX31865 doesn't actually return the resistance it measures. Instead it returns the ratio between the resistance measured and the Rref reference resistor.
- For the PT100 version of the breakout, this is a 430 ohm 0.1% resistor (marking is 4300 !!!)
- For the PT1000 version of the breakout, this is a 4300 ohm 0.1% resistor (marking is 4301 !!!)
You can use that ratio to calculate the resistance and then determine the temperature
More Accuracy Our library is efficient and small and uses an algorithm to calculate temperature. While this works very well, it isn't as accurate as it could be. Check out this ITS-90 conforming library from DrHaney that uses a lookup table for better accuracy!
Library ReferenceYou can start out by creating a MAX31865 object with either software SPI (where all four pins can be any I/O) using
Download File Copy Code // Use software SPI: CS, DI, DO, CLK Adafruit_MAX31865 max = Adafruit_MAX31865(10, 11, 12, 13); // Use software SPI: CS, DI, DO, CLK Adafruit_MAX31865 max = Adafruit_MAX31865(10, 11, 12, 13);Or you can use hardware SPI. With hardware SPI you must use the hardware SPI pins for your Arduino - and each arduino type has different pins! Check the SPI reference to see what pins to use.In this case, you can use any CS pin, but the other three pins are fixed
Download File Copy Code // use hardware SPI, just pass in the CS pin Adafruit_MAX31865 max = Adafruit_MAX31865(10); // use hardware SPI, just pass in the CS pin Adafruit_MAX31865 max = Adafruit_MAX31865(10);Once started, you can initialize the sensor with one of the following, depending on what kind of RTD you've got connected!
Download File Copy Code max.begin(MAX31865_2WIRE) max.begin(MAX31865_3WIRE) max.begin(MAX31865_4WIRE) max.begin(MAX31865_2WIRE) max.begin(MAX31865_3WIRE) max.begin(MAX31865_4WIRE)Reading Resistance
If you want to know the actual resistance (not temperature) you can do that fairly easily. You can read ratio from the MAX31865 with
Download File Copy Code max.readRTD() max.readRTD()This will give you the raw 16-bit unsigned value where 0xFFFF is '1.0 ratio'. Chances are you want to convert it to the resistance. We recommend this code:
Download File Copy Code Serial.print("RTD value: "); Serial.println(rtd); float ratio = rtd; ratio /= 32768; Serial.print("Ratio = "); Serial.println(ratio,8); Serial.print("Resistance = "); Serial.println(RREF*ratio,8); Serial.print("RTD value: "); Serial.println(rtd); float ratio = rtd; ratio /= 32768; Serial.print("Ratio = "); Serial.println(ratio,8); Serial.print("Resistance = "); Serial.println(RREF*ratio,8);You'll need to define RREF - in this case its 430.0 for PT100 and 4300.0 for PT1000
Calculating Temperature
Once you have the resistance you can look up in an RTD table or use a calculation to do a best-fit approximation. We use the example from this app note: http://www.analog.com/media/en/technical-documentation/application-notes/AN709_0.pdf
It's fast and seems to work very well! We have a one-stop function that does everything for you, just call:
Download File Copy Code max.temperature(100, RREF) max.temperature(100, RREF)Where the first argument is the resistance of the RTD at 0°C (for PT100 that's 100) and the second argument is the value of the reference resistor. This function returns the tempreature in °C
Faults
The MAX31865 has a wide-ranging fault mechanism that can alert you via pin or function when something is amiss. Don't forget to test this functionality before relying on it!
You can read faults with
Download File Copy Code max.readFault() max.readFault()Which will return a uint8_t type with bits set for each of 6 different fault types. You can test for each one with this set of code:
Download File Copy Code // Check and print any faults uint8_t fault = max.readFault(); if (fault) { Serial.print("Fault 0x"); Serial.println(fault, HEX); if (fault & MAX31865_FAULT_HIGHTHRESH) { Serial.println("RTD High Threshold"); } if (fault & MAX31865_FAULT_LOWTHRESH) { Serial.println("RTD Low Threshold"); } if (fault & MAX31865_FAULT_REFINLOW) { Serial.println("REFIN- > 0.85 x Bias"); } if (fault & MAX31865_FAULT_REFINHIGH) { Serial.println("REFIN- < 0.85 x Bias - FORCE- open"); } if (fault & MAX31865_FAULT_RTDINLOW) { Serial.println("RTDIN- < 0.85 x Bias - FORCE- open"); } if (fault & MAX31865_FAULT_OVUV) { Serial.println("Under/Over voltage"); } max.clearFault(); } // Check and print any faults uint8_t fault = max.readFault(); if (fault) { Serial.print("Fault 0x"); Serial.println(fault, HEX); if (fault & MAX31865_FAULT_HIGHTHRESH) { Serial.println("RTD High Threshold"); } if (fault & MAX31865_FAULT_LOWTHRESH) { Serial.println("RTD Low Threshold"); } if (fault & MAX31865_FAULT_REFINLOW) { Serial.println("REFIN- > 0.85 x Bias"); } if (fault & MAX31865_FAULT_REFINHIGH) { Serial.println("REFIN- < 0.85 x Bias - FORCE- open"); } if (fault & MAX31865_FAULT_RTDINLOW) { Serial.println("RTDIN- < 0.85 x Bias - FORCE- open"); } if (fault & MAX31865_FAULT_OVUV) { Serial.println("Under/Over voltage"); } max.clearFault(); }In particular, the last four are ones that indicate a hardware failure. The first two are threshold faults, we don't have code for setting those thresholds at this time.
Page last edited March 08, 2024
Text editor powered by tinymce.
RTD Wiring & Config Python & CircuitPython Related Guides Adafruit MOSFET Driver By Liz Clark beginner Soundboard Speaker for Bikes & Scooters By Ruiz Brothers intermediate Introducing Adafruit Trellis By lady ada beginner Adafruit HDC302x Precision Temperature & Humidity... By Liz Clark beginner Adafruit Proximity Trinkey By Kattni Rembor beginner Adafruit SEN6x Breakout By Liz Clark beginner Playing Arduboy Games on Arcada By lady ada intermediate Your browser does not support the video tag. This links to the guide Reindeer Mask with Animated Eyes. Reindeer Mask with Animated Eyes By Dano Wall beginner Adafruit RS-232 Full Pinout Level-Shifter Breakout By Liz Clark intermediate Adafruit LTR390 UV Sensor By Bryan Siepert beginner Adafruit QT 3V to 5V Level Booster Breakout By Liz Clark beginner Wizzy: A Needle Felted Cat By Rick Winscot beginner Adafruit 555 PWM Output STEMMA By Liz Clark beginner Adafruit Stepper + DC Motor FeatherWing By lady ada intermediate Adafruit PCM5122 I2S DAC By Liz Clark beginnerCreate Wishlist
× Title Description Close Search SearchCategories
Tag » Arduino Pt1000 Circuit
-
PT1000 Converter For Arduino - AEQ-WEB
-
Reading The Output Of An RTD PT1000 - Sensors - Arduino Forum
-
How To Connect A PT1000 Temperature Sensor To Arduino Nano
-
PT1000 W/voltage Divider Circuit - Sensors - Arduino Forum
-
Pt1000 With Arduino And Self Build Transmitter (400°C)
-
PT1000 Temperature Sensor Code - Arduino Forum
-
Temperature Sensing With Pt1000 Sensor - Interfacing - Arduino Forum
-
Measuring Temperature From PT100 Using Arduino - Instructables
-
4x Multiplexed RTD Temperature Sensor Module
-
How To Connect Pt 1000 - Stack Overflow
-
How To Connect A PT1000 To An Arduino Based PLC
-
How To Use RTD Sensor ( PT100 With Arduino Tutorial ) - YouTube
-
Getting Started With High Precision Temperature Sensing - Digikey
Adafruit MOSFET Driver By
Soundboard Speaker for Bikes & Scooters By
Introducing Adafruit Trellis By
Adafruit HDC302x Precision Temperature & Humidity... By
Adafruit Proximity Trinkey By
Adafruit SEN6x Breakout By
Adafruit RS-232 Full Pinout Level-Shifter Breakout By
Adafruit LTR390 UV Sensor By
Adafruit QT 3V to 5V Level Booster Breakout By
Wizzy: A Needle Felted Cat By
Adafruit 555 PWM Output STEMMA By
Adafruit Stepper + DC Motor FeatherWing By
Adafruit PCM5122 I2S DAC By