Chat here is you are connecting ESP-xx type modules to existing AVR based Arduino

Moderator: igrr

User avatar
By Mwawrzyniec
#74240 I am attempting to program a NodeMCU through the Arduino IDE to read data from a PT100 sensor through a Max31865. Currently the serial output is saying the temperature sensor is reading the max value. Any idea where I went wrong? If there is another library or an example with a simple temperature output I would appreciate the information. I did also post this on the Arduino forum.



Code: Select all/***************************************************
  This is a library for the Adafruit PT100/P1000 RTD Sensor w/MAX31865

  Designed specifically to work with the Adafruit RTD Sensor
  ----> https://www.adafruit.com/products/3328

  This sensor uses SPI to communicate, 4 pins are required to 
  interface
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries. 
  BSD license, all text above must be included in any redistribution
 ****************************************************/

#include <Adafruit_MAX31865.h>

// Use software SPI: CS, DI, DO, CLK
//Adafruit_MAX31865 max1 = Adafruit_MAX31865(14, 11, 12, 13);
// use hardware SPI, just pass in the CS pin
Adafruit_MAX31865 max1 = Adafruit_MAX31865(14);

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


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

  max1.begin(MAX31865_3WIRE);  // set to 2WIRE or 4WIRE as necessary
}


void loop() {
  uint16_t rtd = max1.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(max1.temperature(100, RREF));

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



NodeMCU Wiring
Breakout Wiring
NodeMCU Wiring
User avatar
By rudy
#74243 I'm sure this is where your problem is.

Code: Select all// Use software SPI: CS, DI, DO, CLK
//Adafruit_MAX31865 max1 = Adafruit_MAX31865(14, 11, 12, 13);
// use hardware SPI, just pass in the CS pin
Adafruit_MAX31865 max1 = Adafruit_MAX31865(14);


You do not have valid port assignments.
User avatar
By Mwawrzyniec
#74247 here was my solution:

Code: Select all/***************************************************
  This is a library for the Adafruit PT100/P1000 RTD Sensor w/MAX31865

  Designed specifically to work with the Adafruit RTD Sensor
  ----> https://www.adafruit.com/products/3328

  This sensor uses SPI to communicate, 4 pins are required to 
  interface
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries. 
  BSD license, all text above must be included in any redistribution
 ****************************************************/

#include <Adafruit_MAX31865.h>


// Use software SPI:         CS, DI, DO, CLK
//NodeMCU pins connected to: D0, D1, D2, D3
Adafruit_MAX31865 max1 = Adafruit_MAX31865(16, 5, 4, 0);
// use hardware SPI, just pass in the CS pin
//Adafruit_MAX31865 max1 = Adafruit_MAX31865(14);

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


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

  max1.begin(MAX31865_3WIRE);  // set to 2WIRE or 4WIRE as necessary
}


void loop() {
  uint16_t rtd = max1.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(max1.temperature(100, RREF));

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