Hi everyone!
I'm try to use a MAX6675 module on ESP32. Because of PCB design, I have to use custom SPI pins. I guess that's why I got only 0.00 (zero) values at readings. Yes, I know it's a common problem, but I could not find a solution on the forum.
Measured Vcc is 3.26 V
I tried tu use MAX6675 library, and define a new SPI instance, but it doesn't help.
The module is works, because the basic example of library shows right values.
Here is my code:
#define MAX6675_SCK 25
#define MAX6675_CS 23
#define MAX6675_SO 32
unsigned long timeToShowTemp = 0;
void setup(void) {
Serial.begin(9600);
}
void loop() {
if ( millis() > timeToShowTemp ) {
timeToShowTemp = millis() + 10000; //every 10 seconds
Serial.println(readThermocouple());
}
}
double readThermocouple() {
uint16_t v;
pinMode(MAX6675_CS, OUTPUT);
pinMode(MAX6675_SO, INPUT);
pinMode(MAX6675_SCK, OUTPUT);
digitalWrite(MAX6675_CS, LOW);
delay(1);
// Read in 16 bits,
// 15 = 0 always
// 14..2 = 0.25 degree counts MSB First
// 2 = 1 if thermocouple is open circuit
// 1..0 = uninteresting status
v = shiftIn(MAX6675_SO, MAX6675_SCK, MSBFIRST);
v <<= 8;
v |= shiftIn(MAX6675_SO, MAX6675_SCK, MSBFIRST);
digitalWrite(MAX6675_CS, HIGH);
if (v & 0x4)
{
// Bit 2 indicates if the thermocouple is disconnected
return NAN;
}
// The lower three bits (0,1,2) are discarded status bits
v >>= 3;
// The remaining bits are the number of 0.25 degree (C) counts
return v*0.25;
}
Can someone help me?