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

MAX31865 with Arduino showing error message with RP
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

MAX31865 with Arduino showing error message with RP

by juliusau93 on Wed Feb 26, 2020 9:49 pm

I have connected the MAX31865 to an Arduino following the diagram provided by Adafruit and connected the Arduino to the RP. I have also include the MAX31865 .h file and .cpp file into /home/pi/sketchbook/libraries from Github. I am not sure what is wrong here.

Error message
/home/pi/sketchbook/libraries/Adafruit_MAX31865/Adafruit_MAX31865.cpp:24:17: fatal error: SPI.h: No such file or directory
compilation terminated.

Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_MAX31865.h>

Adafruit_MAX31865 thermo = Adafruit_MAX31865(10, 11, 12, 13);

#define RREF      430.0
#define RNOMINAL  100.0

unsigned long int avgValue;  //Store the average value of the sensor feedback
int factor  = 0;
int pH = 0;
int buf[10],temp;
float b;
int FLOAT_SENSOR  = 3;
int WATER_PUMP    = 4;
int ALKALINE_PUMP = 5;
int PH_PROBE      = 6;

void setup() {
  Serial.begin(115200);
  thermo.begin(MAX31865_3WIRE);  // set to 2WIRE or 4WIRE as necessary

  pinMode(3, INPUT_PULLUP); //float sensor
  pinMode(4, OUTPUT); //water pump
  pinMode(5, OUTPUT); //alkaline pump
  pinMode(6, INPUT); //pH probe
}


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

  float ratio = rtd;
  ratio /= 32768;
 
  // Check and print any faults
  uint8_t fault = thermo.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");
    }
    thermo.clearFault();
  }
 

if(thermo.temperature(RNOMINAL, RREF) >=20.000 && thermo.temperature(RNOMINAL, RREF) <=20.999);
      {factor = -0.017208883;}

    if(thermo.temperature(RNOMINAL, RREF) >=21.000 && thermo.temperature(RNOMINAL, RREF) <=21.999);
      {factor = -0.017125634;}

    if(thermo.temperature(RNOMINAL, RREF) >=22.000 && thermo.temperature(RNOMINAL, RREF) <=22.999);
      {factor = -0.017069507;}

    if(thermo.temperature(RNOMINAL, RREF) >=23.000 && thermo.temperature(RNOMINAL, RREF) <=23.999);
      {factor = -0.017013747;}

    if(thermo.temperature(RNOMINAL, RREF) >=24.000 && thermo.temperature(RNOMINAL, RREF) <=24.999);
      {factor = -0.016958350;}

    if(thermo.temperature(RNOMINAL, RREF) >=25.000 && thermo.temperature(RNOMINAL, RREF) <=25.999);
      {factor = -0.016903313;}

    if(thermo.temperature(RNOMINAL, RREF) >=26.000 && thermo.temperature(RNOMINAL, RREF) <=26.999);
      {factor = -0.016848632;}

    if(thermo.temperature(RNOMINAL, RREF) >=27.000 && thermo.temperature(RNOMINAL, RREF) <=27.999);
      {factor = -0.016794303;}

     if(thermo.temperature(RNOMINAL, RREF) >=28.000 && thermo.temperature(RNOMINAL, RREF) <=28.999);
       {factor = -0.016740324;}

     if(thermo.temperature(RNOMINAL, RREF) >=29.000 && thermo.temperature(RNOMINAL, RREF) <=29.999);
       {factor = -0.016686691;}

     if(thermo.temperature(RNOMINAL, RREF) >=30.000 && thermo.temperature(RNOMINAL, RREF) <=30.999);
       {factor = -0.016638935;}


//pH
for(int i=0;i<10;i++)       //Get 10 sample value from the sensor for smooth the value
  {
    buf[i]=analogRead(PH_PROBE);
    delay(100);
  }
  for(int i=0;i<9;i++)        //sort the analog from small to large
  {
    for(int j=i+1;j<10;j++)
    {
      if(buf[i]>buf[j])
      {
        temp=buf[i];
        buf[i]=buf[j];
        buf[j]=temp;
      }
    }
  }
  avgValue=0;
  for(int i=2;i<8;i++)                      //take the average value of 6 center sample
    avgValue+=buf[i];
  float phValue=(float)avgValue*5.0/1024/6; //convert the analog into millivolt


         
pH = (phValue*factor)-7; // get ph value with temperature compensation

        Serial.print("Temperature = ");
        Serial.println(thermo.temperature(RNOMINAL, RREF));
        Serial.print("pH          =");
        Serial.println(pH);
        Serial.println("");

       
//while (digitalRead(FLOAT_SENSOR) == LOW);
    {
  //    digitalWrite(WATER_PUMP, HIGH);  // loops until float switch is HIGH
    }

//alkaline pump
//if (pH >=6.700 && pH <=7.000)  // Add in alkaline solution for 3 seconds
     {
  //     digitalWrite(ALKALINE_PUMP, HIGH);
    //   delay(30);
      // digitalWrite(ALKALINE_PUMP, LOW);     
     }

     
//else if (pH >=6.500 && pH <=7.000)     // Add in alkaline solution for 5 seconds
     {
  //     digitalWrite(ALKALINE_PUMP, HIGH);
    //   delay(50);
      // digitalWrite(ALKALINE_PUMP, LOW); 
     }
     
//else
     {
  //     digitalWrite(ALKALINE_PUMP, LOW);     
     } 
//delay(100); // 10 minutes



}

juliusau93
 
Posts: 22
Joined: Tue Dec 17, 2019 12:33 am

Re: MAX31865 with Arduino showing error message with RP

by juliusau93 on Thu Feb 27, 2020 12:51 am

I realized i forgot to include #include <SPI.h>
I will reply if there is further issues.

juliusau93
 
Posts: 22
Joined: Tue Dec 17, 2019 12:33 am

Re: MAX31865 with Arduino showing error message with RP

by juliusau93 on Thu Feb 27, 2020 4:13 pm

Include the #include <SPI.h> and it gave me a lot of errors.

Code: Select all | TOGGLE FULL SIZE
/home/pi/sketchbook/libraries/Adafruit_MAX31865/Adafruit_MAX31865.cpp:12:8: error: ‘SPISettings’ does not name a type
 static SPISettings max31865_spisettings =
        ^
/home/pi/sketchbook/libraries/Adafruit_MAX31865/Adafruit_MAX31865.cpp: In member function ‘void Adafruit_MAX31865::readRegisterN(uint8_t, uint8_t*, uint8_t)’:
/home/pi/sketchbook/libraries/Adafruit_MAX31865/Adafruit_MAX31865.cpp:254:9: error: ‘class SPIClass’ has no member named ‘beginTransaction’
     SPI.beginTransaction(max31865_spisettings);
         ^
/home/pi/sketchbook/libraries/Adafruit_MAX31865/Adafruit_MAX31865.cpp:254:26: error: ‘max31865_spisettings’ was not declared in this scope
     SPI.beginTransaction(max31865_spisettings);
                          ^
/home/pi/sketchbook/libraries/Adafruit_MAX31865/Adafruit_MAX31865.cpp:271:9: error: ‘class SPIClass’ has no member named ‘endTransaction’
     SPI.endTransaction();
         ^
/home/pi/sketchbook/libraries/Adafruit_MAX31865/Adafruit_MAX31865.cpp: In member function ‘void Adafruit_MAX31865::writeRegister8(uint8_t, uint8_t)’:
/home/pi/sketchbook/libraries/Adafruit_MAX31865/Adafruit_MAX31865.cpp:278:9: error: ‘class SPIClass’ has no member named ‘beginTransaction’
     SPI.beginTransaction(max31865_spisettings);
         ^
/home/pi/sketchbook/libraries/Adafruit_MAX31865/Adafruit_MAX31865.cpp:278:26: error: ‘max31865_spisettings’ was not declared in this scope
     SPI.beginTransaction(max31865_spisettings);
                          ^
/home/pi/sketchbook/libraries/Adafruit_MAX31865/Adafruit_MAX31865.cpp:291:9: error: ‘class SPIClass’ has no member named ‘endTransaction’
     SPI.endTransaction();
         ^

juliusau93
 
Posts: 22
Joined: Tue Dec 17, 2019 12:33 am

Re: MAX31865 with Arduino showing error message with RP

by mikeysklar on Thu Feb 27, 2020 5:05 pm

juliusau93,

Are you able to run our example code?

Arduino->File->Examples->Adafruit_MAX31865->max31865
https://learn.adafruit.com/adafruit-max ... duino-code

mikeysklar
 
Posts: 1974
Joined: Mon Aug 01, 2016 8:10 pm

Re: MAX31865 with Arduino showing error message with RP

by juliusau93 on Thu Feb 27, 2020 7:41 pm

Using Windows with the Arduino Uno the example code works but not when Windows is replaced by Raspian.

What does the error message mean ?

juliusau93
 
Posts: 22
Joined: Tue Dec 17, 2019 12:33 am

Re: MAX31865 with Arduino showing error message with RP

by mikeysklar on Mon Mar 02, 2020 8:44 pm

This error looks like a library mismatch.

Which version of the max31865 library are you running on you 'working' windows system versus the not working Raspbian system?

Which version of the Arduino application are you running on both systems/

mikeysklar
 
Posts: 1974
Joined: Mon Aug 01, 2016 8:10 pm

Re: MAX31865 with Arduino showing error message with RP

by juliusau93 on Mon Mar 02, 2020 11:55 pm

On my Mac the MAX31865 library is on version 1.0.3. On the RP I am not sure because it doesn't have manage library. I went to https://github.com/adafruit/Adafruit_MAX31865 to get the .h and .cpp file and it doesn't say the version. Arduino on Mac is version 1.8.13 and on the RP I am not too sure also. Could it be that I have to configure my RP with sudo raspi-config?

I will update the arduino on RP and get the same MAX31685 onto the RP and see what happens.

Thank you. I will post the results when its done.

juliusau93
 
Posts: 22
Joined: Tue Dec 17, 2019 12:33 am

Please be positive and constructive with your questions and comments.