Hi all, new here, I'm very much an amateur though have some past PIC C programming experience, I wanted to try out the Teensy as it seems ideal for my car project. I'm replacing the 80s retro looking dash thermometer in a Porsche 968 with something that looks the part but the hope is to develop the project over time to control dash display of other CAN sourced data, I plan to add a CAN bus to the car and gather a lot more data in time... Anyway I started out with the thermometer part of the project as an intro to the Arduino/Teensy world.

I attached a TM 1637 4x 7 segment board to the Teensy on pins 2-3 via a level shifter, all went well, I coded for temperature display from a float value, all worked fine. Perhaps being overconfident I then soldered an Adafruit clone MAX31865 board into the prototype. I cannot get any reading from the 31865 sadly. Ive extracted the code relating to the Max read and run it standalone, its pasted below, so no interaction with the TM 1367 library. The Adafruit library rtd() ADC read function returns zero as does fault(), cant even get an error code. Ive looked at much of the relevant library code though I admit I get lost in it a bit, I checked the pin config parameters seem to be being passed correctly though.

I'm sure many will say I should have breadboarded this, oh well. I went for software SPI on pins 29-32, the connections are shown in my photo. I've listed them in the attached test code. Connections seem good, no shorts, continuity from breakout to the Teensy pins is as expected and documented here. 3.3v breakout supply and good ground as expected. The 3 wire PT100 RTD is connected as shown, approx 108R accross the centre 2 screw terminals and 0.6 R across the yellow/blue wires as expected. The RTD resistance increases as I warm it so it seems good. The breakout has the correct RREF, 430R. The code below loops fine, counting/flashing the LED but outputting 0 for rtd and fault values (there is an invalid calculated temp) via the serial terminal. I've run the code with/without #includes, no different, guess the Adafruit code sorts those. Ive tried setting the CS pin 29 as output/low in my code, again no different.

Just wonder if anyone has had success with the Adafruit library and software SPI on the Teensy 4.1? I guess I could rewire so that Im using hardware SPI, I was intending to save that channel for other devices perhaps. I should really be able to make the current configuration work? Next step might be to play with a cheap logic analyser on the SPI bus I think, though I wonder if dead communications due to non-working code is more likely the problem. Im surprised none of the library functions returns an error really. I cannot 100 pc rule out a dead breakout board I suppose, but Ive done nothing bad to it that I know about. Any advice appreciated!

Steve


Click image for larger version. 

Name:	Boardpic.jpg 
Views:	27 
Size:	99.7 KB 
ID:	22221

Code:
/*   Hardware:
 *   
 *   Teensyduino 4.1 ARM processor board, note 3.3V I/O 
 *
 *   MAX 31865 PTD100 interface (3.3V Vin, 430R ref), 3 wire PTD, connected pins 29 CS, 30 SDI, 31 SDO, 32 CLK 
 *   
 *   
 */


//#include <Arduino.h>
//#include <Wire.h>
//#include <SPI.h>
#include <Adafruit_MAX31865.h>

// MAX 31867 setup:

#define RREF 430                                                    //RTD reference resistor value used for the PT100 sensor
#define RNOMINAL 100                                                // Nominal 0C resistance for PT 100 RTD

Adafruit_MAX31865 thermo = Adafruit_MAX31865(29,30,31,32);        //Set up thermometer object, defining interface pins for MAX RTD interface



// The amount of time (in milliseconds) for default delays
#define DELAY   2000


int led = 13;                     // Pin 13 has the LED on Teensy
float temp = 0;
int ctr = 0;
int rtd = 0;


void setup()
{
 
  pinMode(led, OUTPUT); 
  //pinMode(29, OUTPUT);           //Slave select pin MAX 31865 is 29 
  //digitalWrite(29, LOW);
  flashLED();
  thermo.begin(MAX31865_3WIRE);           // Set up MAX interface for the 3 wire RTD in use
}

  
void loop()
{
  ctr ++;
  
  int fault = thermo.readFault();

  temp = thermo.temperature(RNOMINAL, RREF);                 // Read temp, returns float value
  
  rtd = thermo.readRTD();                                    // Read the raw ADC data, returns int value

  Serial.print("Reading no: "); Serial.println (ctr);
  Serial.print("Fault code: "); Serial.println(fault);
  Serial.print("RTD value: "); Serial.println(rtd);
  Serial.print("Temp: "); Serial.println(temp);
  
  flashLED();
}

void flashLED (void)
{
  digitalWrite(led, HIGH);         // turn the LED on 
  delay(100);                      // one LED flash
  digitalWrite(led, LOW);          // turn the LED off
  delay (DELAY);
}