// Define the pins for the MAX6675
const int thermoDO = 5; // SO
const int thermoCS = 4; // CS
const int thermoCLK = 3; // SCK
const int outputPin = 6; // Define the output pin
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO); // Create an instance of the MAX6675 class
unsigned long previousMillis = 0;
const long interval = 30000; // 30 seconds
float maxTempC = -9999.0; // Initialize max temperature variable with a very low value
void setup() {
u8g2.begin();
pinMode(outputPin, OUTPUT); // Set the output pin as an output
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
maxTempC = -9999.0; // Reset max temperature after 30 seconds
}
float tempC = thermocouple.readCelsius();
int tempCInt = int(tempC); // Convert float to integer
// Update max temperature
if (tempCInt > maxTempC) {
maxTempC = tempCInt;
}
// Set output pin high if temperature is over 650 degrees Celsius
if (tempC > 650) {
digitalWrite(outputPin, HIGH);
} else {
digitalWrite(outputPin, LOW);
}
// Draw to the OLED display
u8g2.firstPage();
do {
u8g2.drawBitmap(0, 0, 16, 64, epd_bitmap_Tempgauge_128x64);
u8g2.setFont(u8g2_font_ncenB14_tr);
u8g2.setCursor(2, 30);
u8g2.print("Temp: ");
u8g2.print(tempC);
u8g2.print(" C");
u8g2.setCursor(2, 50);
u8g2.print("Max: ");
u8g2.print(maxTempC);
u8g2.print(" C");
} while (u8g2.nextPage());
I changed the display and now the Bitmap does not work as it should. The writing in the code is displayed correctly.
the code:
include
include
include
// Initialize the OLED display using U8G2 library U8G2_SH1107_64X128_1_HW_I2C u8g2(U8G2_R1, / reset=/ U8X8_PIN_NONE);
// 'Tempgauge_128x64', 64x128px const unsigned char epd_bitmap_Tempgauge_128x64 [] PROGMEM = {
};
// Define the pins for the MAX6675 const int thermoDO = 5; // SO const int thermoCS = 4; // CS const int thermoCLK = 3; // SCK const int outputPin = 6; // Define the output pin
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO); // Create an instance of the MAX6675 class
unsigned long previousMillis = 0; const long interval = 30000; // 30 seconds
float maxTempC = -9999.0; // Initialize max temperature variable with a very low value
void setup() { u8g2.begin(); pinMode(outputPin, OUTPUT); // Set the output pin as an output }
void loop() { unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) { previousMillis = currentMillis; maxTempC = -9999.0; // Reset max temperature after 30 seconds }
float tempC = thermocouple.readCelsius(); int tempCInt = int(tempC); // Convert float to integer
// Update max temperature if (tempCInt > maxTempC) { maxTempC = tempCInt; }
// Set output pin high if temperature is over 650 degrees Celsius if (tempC > 650) { digitalWrite(outputPin, HIGH); } else { digitalWrite(outputPin, LOW); }
// Draw to the OLED display u8g2.firstPage(); do { u8g2.drawBitmap(0, 0, 16, 64, epd_bitmap_Tempgauge_128x64); u8g2.setFont(u8g2_font_ncenB14_tr); u8g2.setCursor(2, 30); u8g2.print("Temp: "); u8g2.print(tempC); u8g2.print(" C"); u8g2.setCursor(2, 50); u8g2.print("Max: "); u8g2.print(maxTempC); u8g2.print(" C"); } while (u8g2.nextPage());
delay(1000); // Update display every second }
![IMG_20240530_232636](https://github.com/olikraus/u8g2/assets/171293143/c51b876b-2825-4fb3-b12e-c811704ab414)