Good evening;
since I am new to programming, very likely I am missing something. I have just added a 2.2" TFT display https://www.pjrc.com/store/display_ili9341.html to my project and now am experiencing difficulties with the data transfer of the temperature measurement. The display itself works fine and the temperature measurement does too, as long as not both are running. The temperature measurement somehow gets clobbered on the SPI bus by the TFT display use of the SPI bus.
With the code for the TFT display commented out, it works fine, providing this data:
PT100 resistance 110.25 Temperature 26.32
PT100 resistance 110.25 Temperature 26.32
PT100 resistance 110.25 Temperature 26.32
PT100 resistance 110.25 Temperature 26.32
PT100 resistance 110.23 Temperature 26.29
PT100 resistance 110.25 Temperature 26.32
PT100 resistance 110.23 Temperature 26.29
PT100 resistance 110.25 Temperature 26.32
PT100 resistance 110.22 Temperature 26.26
PT100 resistance 110.23 Temperature 26.29
However if the I am using the complete code, this data is transferred:
PT100 resistance 110.27 Temperature 26.39
PT100 resistance 76.54 Temperature -59.50
PT100 resistance 75.02 Temperature -63.32
PT100 resistance 76.54 Temperature -59.50
PT100 resistance 75.02 Temperature -63.32
PT100 resistance 75.02 Temperature -63.32
PT100 resistance 76.54 Temperature -59.50
Note that the very first transfer is always correct!
since I am new to programming, very likely I am missing something. I have just added a 2.2" TFT display https://www.pjrc.com/store/display_ili9341.html to my project and now am experiencing difficulties with the data transfer of the temperature measurement. The display itself works fine and the temperature measurement does too, as long as not both are running. The temperature measurement somehow gets clobbered on the SPI bus by the TFT display use of the SPI bus.
Code:
// MAX31865_RTD trial with PJRC 2.2" TFT display
#include <MAX31865.h>
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#define TFT_DC 20
#define TFT_CS 9
// Use hardware SPI
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
// PT1000 / PT100 board from Charles Hallard (http://hallard.me)
// -------------------------------------------
// 3V3 (!not 5V) --> NRF Connector pin 8 (VCC)
// GND --> NRF Connector pin 1 (GND)
// CS: pin 10 --> NRF Connector pin 7 (CSN)
// MOSI: pin 11 --> NRF Connector pin 6 (MOSI)
// MISO: pin 12 --> NRF Connector pin 4 (MISO)
// SCK: pin 13 --> NRF Connector pin 3 (SCK)
// -------------------------------------------
#define RTD_CS_PIN 10
MAX31865_RTD rtd( MAX31865_RTD::RTD_PT100, RTD_CS_PIN, 390 ); // PT100 configuration
float RTD_PT_1 = 0; // Global storage for RTD temperature measurement 1
float PTxxx_OHM = 0; // Global storage for PT resistance 1
const int TFT_DC_PIN = 20;
const int TFT_CS_PIN = 9;
const int RTD_PIN = 10;
void setup() {
Serial.begin(115200); // Set up serial port
pinMode (RTD_PIN, OUTPUT);
pinMode (TFT_DC_PIN, OUTPUT);
pinMode (TFT_CS_PIN, OUTPUT);
digitalWrite (RTD_PIN, HIGH);
digitalWrite (TFT_DC_PIN, HIGH);
digitalWrite (TFT_CS_PIN, HIGH);
SPI.setSCK(14); // SCK pin default
SPI.begin(); // Setup and begin SPI library:
SPI.setClockDivider(SPI_CLOCK_DIV16); // SPI speed to SPI_CLOCK_DIV16 (1MHz)
SPI.setDataMode(SPI_MODE3); // MAX31865 works in MODE1 or MODE3
rtd.configure( true, true, false, true, MAX31865_FAULT_DETECTION_NONE, true, true, 0x0000, 0x7fff ); // MAX31865 configuration
delay(5000); // Delay any further action for 5 seconds
}
void loop(){
// ******************** RTD reading ********************
digitalWrite (RTD_PIN, LOW);
rtd.read_all();
PTxxx_OHM =rtd.resistance();
RTD_PT_1 = rtd.temperature( );
digitalWrite (RTD_PIN, HIGH);
// ************** end RTD no-fault handling *************
digitalWrite (TFT_DC_PIN, LOW);
digitalWrite (TFT_CS_PIN, LOW);
/*
tft.begin();
tft.setRotation(1);
tft.fillScreen(ILI9341_BLACK);
tft.setCursor(0, 0);
tft.setTextColor(ILI9341_RED); tft.setTextSize(4);
tft.println("Temperature");
tft.setTextSize(6);
tft.println();
tft.println(RTD_PT_1, 2);
*/
digitalWrite (TFT_DC_PIN, HIGH);
digitalWrite (TFT_CS_PIN, HIGH);
// ASCII dump printing on USB port
Serial.print("PT100 resistance ");
Serial.print(PTxxx_OHM);
Serial.print(" Temperature ");
Serial.println(RTD_PT_1);
delay(2000);
}
With the code for the TFT display commented out, it works fine, providing this data:
PT100 resistance 110.25 Temperature 26.32
PT100 resistance 110.25 Temperature 26.32
PT100 resistance 110.25 Temperature 26.32
PT100 resistance 110.25 Temperature 26.32
PT100 resistance 110.23 Temperature 26.29
PT100 resistance 110.25 Temperature 26.32
PT100 resistance 110.23 Temperature 26.29
PT100 resistance 110.25 Temperature 26.32
PT100 resistance 110.22 Temperature 26.26
PT100 resistance 110.23 Temperature 26.29
However if the I am using the complete code, this data is transferred:
PT100 resistance 110.27 Temperature 26.39
PT100 resistance 76.54 Temperature -59.50
PT100 resistance 75.02 Temperature -63.32
PT100 resistance 76.54 Temperature -59.50
PT100 resistance 75.02 Temperature -63.32
PT100 resistance 75.02 Temperature -63.32
PT100 resistance 76.54 Temperature -59.50
Note that the very first transfer is always correct!
Last edited: