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.

Re: multiple max31865 code issue

by adafruit_support_bill on Mon Feb 17, 2020 7:32 am

You can't perform math on a literal string. You need to use the raw temperature value that you calculated from the readings:

Code: Select all | TOGGLE FULL SIZE
  // print the raw value
  float rawTemperature = thermo.temperature(RNOMINAL, RREF) * 9 / 5 + 32;
  Serial.print("Raw Temperature = "); Serial.println(rawTemperature);
 
  // print the corrected value
  float CorrectedValue = rawTemperature – .52) * 99.99) / 72) + .01;
  Serial.print("Corrected Temperature = "); Serial.println(CorrectedValue);
 

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

Re: multiple max31865 code issue

by Dre50 on Mon Feb 17, 2020 5:46 pm

I'm still getting the error stray '\342' in program error.
Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_MAX31865.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#define RELAY1  8  // Relay
// 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();
  pinMode(RELAY1, OUTPUT);

  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);
    // print the raw value
  float rawTemperature = thermo.temperature(RNOMINAL, RREF) * 9 / 5 + 32;
  Serial.print("Raw Temperature = "); Serial.println(rawTemperature);
 
  // print the corrected value
  float CorrectedValue = rawTemperature – .52) * 99.99) / 72) + .01;
  Serial.print("Corrected Temperature = "); Serial.println(CorrectedValue);
 
  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 Mon Feb 17, 2020 7:35 pm

Not sure where that error is coming from. There is no "342" in the code you posted. However, you are still attempting to perform math on a literal string - and attempting to assign the result of that ambiguous operation to an undefined variable.

This line does not make sense to the compiler.
Code: Select all | TOGGLE FULL SIZE
  CorrectedValue = ("Temperature = ") – .52) * 99.99) / 72) + .01;

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

Please be positive and constructive with your questions and comments.