Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

multiple max31865 code issue
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

multiple max31865 code issue

by Dre50 on Wed Feb 12, 2020 10:37 pm

Hello i have two max31865 wired together and i worked with the code and what i can figure out is why im getting a reading of -403 F. not sure what i did wrong. when i run the test code with only one board i get the correct reading. can someone help me?
Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_MAX31865.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
// Define LCD pinout
const int  en = 2, rw = 1, rs = 0, d4 = 4, d5 = 5, d6 = 6, d7 = 7, bl = 3;

// Define I2C Address - change if reqiuired
const int i2c_addr = 0x27;

// DHT-22
//#define DHTPIN 7       // DHT-22 Output Pin connection
//#define DHTTYPE DHT11   // DHT Type is DHT 22 (AM2302)

// Define LCD display connections
LiquidCrystal_I2C lcd(i2c_addr, 16, 2);


// SPI.h: CS, DI, DO, CLK
//Adafruit_MAX31865 thermo = Adafruit_MAX31865(10, 11, 12, 13);
// use hardware SPI, just pass in the CS pin
Adafruit_MAX31865 thermo_1 = Adafruit_MAX31865(10);
Adafruit_MAX31865 thermo_2 = Adafruit_MAX31865(9);

// The value of the Rref resistor. Use 430.0 for PT100 and 4300.0 for PT1000
#define RREF      430.0
// The 'nominal' 0-degrees-C resistance of the sensor
// 100.0 for PT100, 1000.0 for PT1000
#define RNOMINAL  100.0

void setup() {
  Serial.begin(115200);
  Serial.println("Adafruit MAX31865 PT100 Sensor Test!");
  lcd.init();
  // Set display type as 16 char, 2 rows
  lcd.begin(16, 2);
  lcd.backlight();

  thermo_1.begin(MAX31865_2WIRE);  // set to 2WIRE or 4WIRE as necessary
  thermo_2.begin(MAX31865_2WIRE);
}


void loop() {
  uint16_t rtd1 = thermo_1.readRTD();

  Serial.print("RTD value: "); Serial.println(rtd1);
  float ratio1 = rtd1;
  ratio1 /= 32768;
  Serial.print("Ratio1 = "); Serial.println(ratio1, 8);
  Serial.print("Resistance = "); Serial.println(RREF * ratio1, 8);
  Serial.print("Temperature = "); Serial.println(thermo_1.temperature(RNOMINAL, RREF) * 9 / 5 + 32);
  lcd.setCursor(0, 0);
  //lcd.print("Temperature = ");
  lcd.print("Deg.F= ");
  lcd.print(thermo_1.temperature(RNOMINAL, RREF) * 9 / 5 + 32);
 
  uint16_t rtd2 = thermo_2.readRTD();

  Serial.print("RTD value: "); Serial.println(rtd2);
  float ratio2 = rtd2;
  ratio2 /= 32768;
  Serial.print("Ratio2 = "); Serial.println(ratio2, 8);
  Serial.print("Resistance = "); Serial.println(RREF * ratio2, 8);
  Serial.print("Temperature = "); Serial.println(thermo_2.temperature(RNOMINAL, RREF) * 9 / 5 + 32);
  lcd.setCursor(0, 3);
  //lcd.print("Temperature = ");
  lcd.print("Deg.F= ");
  lcd.print(thermo_2.temperature(RNOMINAL, RREF) * 9 / 5 + 32);
 
  delay(1000);
}

Dre50
 
Posts: 15
Joined: Sat Feb 08, 2020 10:56 pm

Re: multiple max31865 code issue

by adafruit_support_bill on Thu Feb 13, 2020 6:44 am

when i run the test code with only one board i get the correct reading. can someone help me?

If you change the test code to address just the second board, do you still get a correct reading?

If you post some photos showing your soldering and wiring, we'll see if we can spot any issues there.

adafruit_support_bill
 
Posts: 78956
Joined: Sat Feb 07, 2009 10:11 am

Re: multiple max31865 code issue

by Dre50 on Thu Feb 13, 2020 5:50 pm

Ok i ran a test and i changed the cs pin on test example code and both boards and both boards read correctly. so its got to be something in my code that's not calculating right or something? any idea?

Dre50
 
Posts: 15
Joined: Sat Feb 08, 2020 10:56 pm

Re: multiple max31865 code issue

by Dre50 on Thu Feb 13, 2020 6:31 pm

ok I got it working. it didn't like the code i was using so i changed things around and it works now. The only problem i see is that one sensor is 8 deg different the the other? any ideas on that?

Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_MAX31865.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
// Define LCD pinout
const int  en = 2, rw = 1, rs = 0, d4 = 4, d5 = 5, d6 = 6, d7 = 7, bl = 3;

// Define I2C Address - change if reqiuired
const int i2c_addr = 0x27;

// DHT-22
//#define DHTPIN 7       // DHT-22 Output Pin connection
//#define DHTTYPE DHT11   // DHT Type is DHT 22 (AM2302)

// Define LCD display connections
LiquidCrystal_I2C lcd(i2c_addr, 16, 2);


// SPI.h: CS, DI, DO, CLK
Adafruit_MAX31865 thermo = Adafruit_MAX31865(10, 11, 12, 13);
Adafruit_MAX31865 thermo1 = Adafruit_MAX31865(9, 11, 12, 13);
// use hardware SPI, just pass in the CS pin
//Adafruit_MAX31865 thermo_1 = Adafruit_MAX31865(10);
//Adafruit_MAX31865 thermo_2 = Adafruit_MAX31865(9);

// The value of the Rref resistor. Use 430.0 for PT100 and 4300.0 for PT1000
#define RREF      430.0
// The 'nominal' 0-degrees-C resistance of the sensor
// 100.0 for PT100, 1000.0 for PT1000
#define RNOMINAL  100.0

void setup() {
  Serial.begin(115200);
  Serial.println("Adafruit MAX31865 PT100 Sensor Test!");
  lcd.init();
  // Set display type as 16 char, 2 rows
  lcd.begin(16, 2);
  lcd.backlight();

  thermo.begin(MAX31865_2WIRE);  // set to 2WIRE or 4WIRE as necessary
  thermo1.begin(MAX31865_2WIRE);
}


void loop() {
  uint16_t rtd1 = thermo.readRTD();

  Serial.print("RTD value: "); Serial.println(rtd1);
  float ratio = rtd1;
  ratio /= 32768;
  Serial.print("Ratio = "); Serial.println(ratio, 8);
  Serial.print("Resistance = "); Serial.println(RREF * ratio, 8);
  Serial.print("Temperature = "); Serial.println(thermo.temperature(RNOMINAL, RREF) * 9 / 5 + 32);
  lcd.setCursor(0, 0);
  //lcd.print("Temperature = ");
  lcd.print("Deg.F= ");
  lcd.print(thermo.temperature(RNOMINAL, RREF) * 9 / 5 + 32);
 
  uint16_t rtd2 = thermo1.readRTD();

  Serial.print("RTD value: "); Serial.println(rtd2);
  float ratio2 = rtd2;
  ratio2 /= 32768;
  Serial.print("Ratio2 = "); Serial.println(ratio2, 8);
  Serial.print("Resistance = "); Serial.println(RREF * ratio2, 8);
  Serial.print("Temperature = "); Serial.println(thermo1.temperature(RNOMINAL, RREF) * 9 / 5 + 32);
  lcd.setCursor(0, 3);
  //lcd.print("Temperature = ");
  lcd.print("Deg.F= ");
  lcd.print(thermo1.temperature(RNOMINAL, RREF) * 9 / 5 + 32);
 
  delay(1000);
}

Dre50
 
Posts: 15
Joined: Sat Feb 08, 2020 10:56 pm

Re: multiple max31865 code issue

by adafruit_support_bill on Thu Feb 13, 2020 7:14 pm

Good to hear you have it working. RTDs are generally very accurate - once they have been calibrated. If you perform a 2-point calibration on your 2 RTDs, they should track each other very closely.

https://learn.adafruit.com/calibrating-sensors

adafruit_support_bill
 
Posts: 78956
Joined: Sat Feb 07, 2009 10:11 am

Re: multiple max31865 code issue

by Dre50 on Fri Feb 14, 2020 5:53 pm

Im trying to implement the map() code and keep getting errors any help? im not sure if im doing it right any help thanks.

CorrectedValue = map(RawValue, RawLow, RawHigh, ReferenceLow, ReferenceHigh);

Code: Select all | TOGGLE FULL SIZE
void loop() {
  uint16_t rtd1 = thermo.readRTD();

  Serial.print("RTD value: "); Serial.println(rtd1);
  float ratio = rtd1;
  ratio /= 32768;

 
  Serial.print("Ratio = "); Serial.println(ratio, 8);
  Serial.print("Resistance = "); Serial.println(RREF * ratio, 8);
  Serial.print("Temperature = "); Serial.println(thermo.temperature(RNOMINAL, RREF) * 9 / 5 + 32);
 thermo.temperature= map("Temperature = ") 29, 191, 32.3, 210);

Dre50
 
Posts: 15
Joined: Sat Feb 08, 2020 10:56 pm

Re: multiple max31865 code issue

by Dre50 on Fri Feb 14, 2020 6:45 pm

I found something interesting I swapped sensors and the temp difference stayed with the first board? so is it something in the board? what should i look for there? the resistance is different.
temoread.jpg
temoread.jpg (15.08 KiB) Viewed 72 times

Dre50
 
Posts: 15
Joined: Sat Feb 08, 2020 10:56 pm

Re: multiple max31865 code issue

by adafruit_support_bill on Fri Feb 14, 2020 7:41 pm

The map function only works with integer values. If you are using floating point values, you need to use the equation as shown in the guide.

Please post some photos showing your soldering and connections to the boards.

adafruit_support_bill
 
Posts: 78956
Joined: Sat Feb 07, 2009 10:11 am

Re: multiple max31865 code issue

by Dre50 on Sat Feb 15, 2020 1:01 pm

adafruit_support_bill wrote:The map function only works with integer values. If you are using floating point values, you need to use the equation as shown in the guide.

Please post some photos showing your soldering and connections to the boards.

so i need to use this formula?
CorrectedValue = (((RawValue – RawLow) * ReferenceRange) / RawRange) + ReferenceLow

Dre50
 
Posts: 15
Joined: Sat Feb 08, 2020 10:56 pm

Re: multiple max31865 code issue

by adafruit_support_bill on Sat Feb 15, 2020 1:34 pm

Yes. That is essentially what 'map' does. But map converts everything to integer values, so if you are starting with floating point, any fractional values get truncated.

adafruit_support_bill
 
Posts: 78956
Joined: Sat Feb 07, 2009 10:11 am

Re: multiple max31865 code issue

by Dre50 on Sat Feb 15, 2020 3:37 pm

so in my code would i use ("Temperature = ") as my rawvalue?

Dre50
 
Posts: 15
Joined: Sat Feb 08, 2020 10:56 pm

Re: multiple max31865 code issue

by adafruit_support_bill on Sat Feb 15, 2020 3:54 pm

Yes.

adafruit_support_bill
 
Posts: 78956
Joined: Sat Feb 07, 2009 10:11 am

Re: multiple max31865 code issue

by Dre50 on Sun Feb 16, 2020 6:37 pm

Im getting stray '\342' in program error any idea what I'm missing?

CorrectedValue = ("Temperature = ") – .52) * 99.99) / 72) + .01;

Dre50
 
Posts: 15
Joined: Sat Feb 08, 2020 10:56 pm

Re: multiple max31865 code issue

by adafruit_support_bill on Sun Feb 16, 2020 7:47 pm

Please post your complete code

adafruit_support_bill
 
Posts: 78956
Joined: Sat Feb 07, 2009 10:11 am

Re: multiple max31865 code issue

by Dre50 on Sun Feb 16, 2020 9:21 pm

Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_MAX31865.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
// Define LCD pinout
const int  en = 2, rw = 1, rs = 0, d4 = 4, d5 = 5, d6 = 6, d7 = 7, bl = 3;

// Define I2C Address - change if reqiuired
const int i2c_addr = 0x27;

// DHT-22
//#define DHTPIN 7       // DHT-22 Output Pin connection
//#define DHTTYPE DHT11   // DHT Type is DHT 22 (AM2302)

// Define LCD display connections
LiquidCrystal_I2C lcd(i2c_addr, 16, 2);


// SPI.h: CS, DI, DO, CLK
Adafruit_MAX31865 thermo = Adafruit_MAX31865(10, 11, 12, 13);
Adafruit_MAX31865 thermo1 = Adafruit_MAX31865(9, 11, 12, 13);
// use hardware SPI, just pass in the CS pin
//Adafruit_MAX31865 thermo_1 = Adafruit_MAX31865(10);
//Adafruit_MAX31865 thermo_2 = Adafruit_MAX31865(9);

// The value of the Rref resistor. Use 430.0 for PT100 and 4300.0 for PT1000
#define RREF      430.0
// The 'nominal' 0-degrees-C resistance of the sensor
// 100.0 for PT100, 1000.0 for PT1000
#define RNOMINAL  100.0

void setup() {
  Serial.begin(115200);
  Serial.println("Adafruit MAX31865 PT100 Sensor Test!");
  lcd.init();
  // Set display type as 16 char, 2 rows
  lcd.begin(16, 2);
  lcd.backlight();

  thermo.begin(MAX31865_2WIRE);  // set to 2WIRE or 4WIRE as necessary
  thermo1.begin(MAX31865_2WIRE);
}


void loop() {
  uint16_t rtd1 = thermo.readRTD();

  Serial.print("RTD value: "); Serial.println(rtd1);
  float ratio = rtd1;
  ratio /= 32768;
  CorrectedValue = ("Temperature = ") – .52) * 99.99) / 72) + .01;
  Serial.print("Ratio = "); Serial.println(ratio, 8);
  Serial.print("Resistance = "); Serial.println(RREF * ratio, 8);
  Serial.print("Temperature = "); Serial.println(thermo.temperature(RNOMINAL, RREF) * 9 / 5 + 32);

  lcd.setCursor(0, 0);
  //lcd.print("Temperature = ");
  lcd.print("Deg.F= ");
  lcd.print(thermo.temperature(RNOMINAL, RREF) * 9 / 5 + 32);

  uint16_t rtd2 = thermo1.readRTD();

  Serial.print("RTD value: "); Serial.println(rtd2);
  float ratio2 = rtd2;
  ratio2 /= 32768;
  Serial.print("Ratio2 = "); Serial.println(ratio2, 8);
  Serial.print("Resistance = "); Serial.println(RREF * ratio2, 8);
  Serial.print("Temperature = "); Serial.println(thermo1.temperature(RNOMINAL, RREF) * 9 / 5 + 32);
  lcd.setCursor(0, 3);
  //lcd.print("Temperature = ");
  lcd.print("Deg.F= ");
  lcd.print(thermo1.temperature(RNOMINAL, RREF) * 9 / 5 + 32);

  delay(1000);

something isn't right where i have it I'm sure so please help me figure this out I'm new to this.

Dre50
 
Posts: 15
Joined: Sat Feb 08, 2020 10:56 pm

Please be positive and constructive with your questions and comments.