I just ran to a very odd situation trying to get an SPI bus to work with an Adafruit MAX31865 RTD sensor that uses the SPI bus for communication.
It turns out that on an ESP32D1MINI chip (WROOM32), the CLK signal works on some pins, but not others. I verified this finding by swapping the ESP with others and the problem is the same.
I should note that this is tested with ONLY the Max module hooked up to the ESP and nothing else. MISO and MOSI are on any useable GPIO, but when the CLK pin is hooked to any of GPIO 1/5/4/9, the problem manifests like this. Output would indicate a wiring issue:
[13:22:28][W][max31865:018]: Overvoltage/undervoltage fault between measurements
[13:22:28][W][max31865:021]: RTDIN- < 0.85 x V_BIAS (FORCE- open) between measurements
[13:22:29][W][max31865:024]: REFIN- < 0.85 x V_BIAS (FORCE- open) between measurements
[13:22:29][W][max31865:027]: REFIN- > 0.85 x V_BIAS between measurements
[13:22:29][W][max31865:031]: RTD Low Threshold between measurements
[13:22:29][W][max31865:034]: RTD High Threshold between measurements
[13:22:29][E][max31865:051]: Fault detection incomplete (0xFF) after 6004μs (datasheet spec is 600μs max)! Aborting read.
Now simply change the CLK pin to be on GPIO0 or GPIO26 in ESPHome and it magically works just fine:
[21:40:56][V][max31865:057]: Fault detection completed in 576μs.
[21:40:56][V][max31865:150]: RTD read complete. 0.25211 (ratio) * 4280.0Ω (reference) = 1079.05Ω --> 20.29°C
This is about 65F, the temp of my shop where the sensor is located. So it works perfectly.
So far, I’ve found that GPIO 1/5/4/9 ALL do not work for CLK and thats as far as I got. GPIO0 and GPIO26 work great for CLK. I even swapped ESP32 modules and they’re both the same. Not something I expected at all. I also tried ALL the different supported SPI bus speeds and got the same results, so it sure seems to be pin related.
Testing on a S3 and C3 variant chips and this problem doesn’t happen. All useable GPIO pins seem to work fine for the CLK signal on those variants.
I also confirmed the problem still exists when using an Arduino sketch as well, so it’s not just ESPHome. And it happens on both Arduino and ESP-IDF frameworks in ESPHome.
I wasted 2 days chasing down this problem. Hopefully this helps someone else.