ESP8266 & SPI conflict

Hi,
I'm faced with a communication issue between a max6675 & my ESP32 when an ILI 9341 is also connected on the SPI bus.

Both components are appropriately working with separate example code,
with different CS pin.

By the way, when using the Adafruit_ILI9341 tft library with adafruit max6675 library, I suspect that the begin() from the Adafruit_ILI9341 is corrupting the SPI connection by setting the default frequency, as I'm not able to read the value of my sensor anymore.
It seems that the provided adafruit max6675 is pretty minimalist in regards the handling of the SPI communication speed...
Any ideas or recommendations?
Tx,
Samuel

Q&D test: lift the connection to the display's MISO pin.

Use the CS (Chip Select) pin the way it is designed to be used.

Is it an ESP8266 or an ESP32 ?
ESP32 has 2 user available SPI busses.

That is possible, but there is also a good possibility that the library leaves the SPI device enabled by not using the CS pin to disable it.

You can switch the frquency back to what you think is correct as you like.

Thanks for your help, I was able to solve my issue.
Just to clarify...
The board is an ESP8266 12-E NodeMCU
The Adafruit_ILI 9341 library is implementing the SPI TFT protocol with its default SPI frequency
#elif defined(ESP8266) || defined(ESP32) #define SPI_DEFAULT_FREQ 40000000
Whereas the max6675 is simply reading the data. Thus the ADAFRUIT_MAX6675 library, is implenting its spiread():

byte MAX6675::spiread(void) {
  int i;
  byte d = 0;

  for (i = 7; i >= 0; i--) {
    digitalWrite(sclk, LOW);
    delayMicroseconds(10);
    if (digitalRead(miso)) {
      // set the bit to 0 no matter what
      d |= (1 << i);
    }

    digitalWrite(sclk, HIGH);
    delayMicroseconds(10);
  }

  return d;
}

leading to this conflicting situation.
I solved this issue by using D0 & D1 for SCK & SO:

#define MAX6675_SO D0
#define MAX6675_CS D8
#define MAX6675_SCK D1
MAX6675 tcouple(MAX6675_SCK, MAX6675_CS, MAX6675_SO);

Hope it can help someone else...
Samuel

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.