Adafruit PT100 library MAX31865

Hello guys,

I´m trying to use a PT100 breakout from Adafruit with my Photon (Adafruit Board). The library is not in the Web IDE so I used the “+” to include it in the project. I´m always getting this error when I compile…

What should I do ?

@rdavidsson,

I added it to the Particle library and you can find it here: https://build.particle.io/libs/Adafruit_MAX31865_library

System firmware needs to be >= 0.6.2

1 Like

Thank´s alot, now it compiles ! :smile:

On more question, regarding the SPI. The example is for Arduino where the pins are 10,11,12,13, hardware pins. In my case, I´m trying to use A2, A3, A4, A5. How do I do that here:

// Use software SPI: CS, DI, DO, CLK
Adafruit_MAX31865 sensor = Adafruit_MAX31865(2, 5, 4, 3);
// use hardware SPI, just pass in the CS pin

The code:
#include <Adafruit_MAX31865.h>

// Use software SPI: CS, DI, DO, CLK
Adafruit_MAX31865 sensor = Adafruit_MAX31865(2, 5, 4, 3);
// use hardware SPI, just pass in the CS pin
//Adafruit_MAX31865 sensor = Adafruit_MAX31865(2);

// The value of the Rref resistor. Use 430.0!
#define RREF 430.0


void setup() {
  Serial.begin(115200);
  Serial.println("Adafruit MAX31865 PT100 Sensor Test!");

  sensor.begin(MAX31865_4WIRE);  // set to 2WIRE or 4WIRE as necessary
}


void loop() {
  uint16_t rtd = sensor.readRTD();

  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("Temperature = "); Serial.println(sensor.temperature(100, RREF));

  // Check and print any faults
  uint8_t fault = sensor.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");
}
sensor.clearFault();
  }
  Serial.println();
  delay(10000);
}

For software SPI:

Adafruit_MAX31865 sensor = Adafruit_MAX31865(A2, A5, A4, A3);

You should instead the Hardware SPI initialization:

Adafruit_MAX31865 sensor = Adafruit_MAX31865(A2);
1 Like

So finally did it work ? The lib works great on arduino but I can’t get correct values using the particle photon (0.6.2)…
I tried both SPI and SPI1 pins…

Just for nit-picking, the preferable syntax would be

Adafruit_MAX31865 sensor(A2);

as this constructs the object in-place while the other syntax first creates a default object Adafruit_MAX31865(), a temporary object Adafruit_MAX31865(A2) and then assigns the latter to the former.

1 Like

Yes it worked when I use hardware SPI. My code is like this:

#include "application.h"
#include <Adafruit_MAX31865.h>


// use hardware SPI, just pass in the CS pin
Adafruit_MAX31865 sensor = Adafruit_MAX31865(A2);

// The value of the Rref resistor. Use 430.0!
#define RREF 430.0


void setup() {
  Serial.begin(115200);
  Serial.println("Adafruit MAX31865 PT100 Sensor Test!");
  SPI.begin();
  sensor.begin(MAX31865_4WIRE);  // set to 2WIRE or 4WIRE as necessary
}


void loop() {
  uint16_t rtd = sensor.readRTD();

  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("Temperature = "); Serial.println(sensor.temperature(100, RREF));

  // Check and print any faults
  uint8_t fault = sensor.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");
    }
    sensor.clearFault();
  }
  Serial.println();
  delay(10000);
}

Yay! I don’t know what went wrong but I copy pasted your code and it works :slight_smile: Thank you Ragnar

Hello Guys. I changed the code a little bit today but now I cannot compile the project…

I get the following error when compiling:

"lib/Adafruit_MAX31865_library/src/Adafruit_MAX31865.h:54:23: fatal error: WProgram,h: No such file or directory
#include “WProgram.h”
^
It´s the same error I was getting before Kenneth installed the library in the WEB IDE…

@ScruffR @kennethlimcp

Standard response: What system version are you targeting? (double check :wink: )
Stating this initially (along with other standard info) might save you the extra iterations in a thread.

Firmware on Photon: v0.6.2. Adafruit_MAX31865_library: v1.0.0.

I havent changed anything since last time when it worker but I can see that the library name is not the same now (waw without “_library”)…

Still double check, sometimes Web IDE suffers from amnesia :wink:

BTW, how come there is a comma in the error message WProgram,h?

You could also try adding this before your other includes

#define ARDUINO (100)
#include <Arduino.h>