Arduino MKR1000 + Adafruit MAX31865 Temperature sensor

Hello! I have been trying to connect Adafruit MAX 31865 temperature sensor to Arduino MKR1000 and stream the data to thinger.io platform. Following is the code I am using but doesn’t seem to work. Can anyone please tell me which part of code is incorrect here? Is my definition of output resource “temperature” correct?

#include <ThingerWifi101.h>
#include <Adafruit_MAX31865.h>

#define USERNAME “Testuser”
#define DEVICE_ID “0001”
#define DEVICE_CREDENTIAL “devicetest@1234”

#define SSID “XXX-XXX”
#define SSID_PASSWORD “$$$$$$”

ThingerWifi101 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

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

// 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() {
// configure wifi network
thing.add_wifi(SSID, SSID_PASSWORD);

Serial.begin(115200);

thermo.begin(MAX31865_4WIRE); /

thing[“temperature”] >> [](pson& out){
uint16_t rtd = thermo.readRTD();
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(thermo.temperature(RNOMINAL, RREF));
out = thermo.temperature(RNOMINAL, RREF);
};

}

void loop() {
thing.handle();

}

Hi, please paste the code in the right way, select all and press the button “</>” into the toolbar, to give the appropriate format and make it easier to read.

Do you see the variable in serial console?

Try with this kind of definition to see if it works:
out["Temp"] = thermo.temperature(RNOMINAL, RREF);

Hope this helps.

Hi! I modified the code and tested but no luck. Below is the code. Normally the function for temperature sensor is written under void loop () to get multiple samples. I am not sure if I am following the correct method. @ega No I don’t see the variable in serial console. Have you already tried connecting any adafruit (I2C) sensor to Arduino and streamed the data to thinger.io cloud platform? If yes, could you please share the code?

#include <ThingerWifi101.h>
#include <Adafruit_MAX31865.h>

#define USERNAME "Testuser"
#define DEVICE_ID "0001"
#define DEVICE_CREDENTIAL "devicetest@1234"

#define SSID "XXX-XXX"
#define SSID_PASSWORD "$$$$$$"

#define RREF      430.0
#define RNOMINAL  100.0

ThingerWifi101 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

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

void setup() {
  // configure wifi network
  thing.add_wifi(SSID, SSID_PASSWORD);
  Serial.begin(115200);
  Serial.println("Adafruit MAX31865 PT100 Sensor Test!");

  thermo.begin(MAX31865_4WIRE); 

  thing["temperature"] >> [](pson& out){ 
    uint16_t rtd = thermo.readRTD();
    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(thermo.temperature(RNOMINAL, RREF));
    out["Temp"] = thermo.temperature(RNOMINAL, RREF);
  };
  
}

void loop() {
  thing.handle();

}

Sorry but I have no experience with adafruit sensors, I have read that they are friendly but have never tried them.

What I recommend you is to make the uC-sensor pair work properly, maybe you can get help on the arduino forum (forum.arduino.cc), once you can get the sensor readings on the serial console, we can help you upload the data to the cloud, but it’s so hard for me to even try to help you because I don’t have the sensor, nor the board, so I’m basically tied to try to recreate your issue.

I think that should be the path to follow developing in this particular field, get the things working locally, after that, work with the communications, before attacking the whole situation, because we have no certain where could be the issue, but if we split the development, we can asure that one stage is working ok and the issue is outside that process/routine/stage.

Hope this helps.