Hello,
thank you for your reply. I'v tried to only use the CS pin and it works, but... yes, there is always a but :-) the results are not very accurate. From the moment a set a brightness in the screen, the values of the temperatures grows.
I try to read the temp in a separate task, but it didn't change anything.
Here is my code
#include "Adafruit_MAX31855.h"
#include <SPI.h>
#include <M5Stack.h>
// Example creating a thermocouple instance with software SPI on any three
// digital IO pins.
#define MAXCS 17
Adafruit_MAX31855 thermocouple(MAXCS);
void task1(void * pvParameters) {
for (;;) {
float avg = 0;
/* Read nbReadToAvg times to make an average of the temp */
for (int i = 0; i < nbReadToAvg; i++) {
float c = thermocouple.readCelsius();
avg = avg + c;
delay(100);
}
avg = avg / nbReadToAvg;
Serial.println(avg);
}
}
void setup() {
Serial.begin(115200);
Serial.print("MOSI=");
Serial.println(MOSI);
Serial.print("MISO=");
Serial.println(MISO);
Serial.print("SCK=");
Serial.println(SCK);
Serial.print("SS=");
Serial.println(SS);
thermocouple.begin();
Serial.print("Internal Temp = ");
Serial.println(thermocouple.readInternal());
while (!Serial) delay(1); // wait for Serial on Leonardo/Zero, etc
Serial.println("MAX31855 Initializing ...");
// M5.Lcd.setTextColor(WHITE, BLACK);
// wait for MAX chip to stabilize
delay(1000);
xTaskCreatePinnedToCore(
task1,
"task1",
4096,
NULL,
1,
NULL,
0
);
Serial.println("M5 begin without LCD");
M5.begin(false, false);
delay(10000);
Serial.println("LCD Start");
M5.Lcd.begin();
for(int j=0;j<100;j++) {
//Serial.printf("Brigthness=%d\n", j);
M5.Lcd.setBrightness(j);
delay(200);
}
//delay(10000);
Serial.println("LCD Shutdown set Brightness to 20");
M5.Lcd.setBrightness(10);
//M5.Lcd.sleep();
M5.Lcd.setTextSize(4);
M5.Lcd.print("test");
M5.update();
}
void loop() {
}
And here is the result :
20.27
20.50
20.35
20.45
20.27
18.52
20.12
20.58
20.42
LCD Start
20.27
18.60
21.55
22.73
21.58
21.77
21.98
20.87
21.40
22.40
21.65
23.60
23.40
24.02
24.48
24.62
24.55
29.67
26.83
25.52
29.15
LCD Shutdown set Brightness to 20
23.48
22.27
22.15
21.50
22.92
20.50
21.67
22.60
21.92
22.12
22.42
Why can see that between the line LCD start and the LCD shutdown, the temperature grows and that why the brightness of the screen is increasing. After the line "LCD Shutdown" the brightness is set to 20 and the value are higher that the values at the beginning but they don't moved.