/*
* Project Name: CPU Temperature Monitor
* Designed For: Raspberry Pi Pico / Pico W
*
*
* License: GPL3+
* This project is licensed under the GNU General Public License v3.0 or later.
* You are free to use, modify, and distribute this software under the terms
* of the GPL, as long as you preserve the original license and credit the original
* author. For more details, see <https://www.gnu.org/licenses/gpl-3.0.en.html>.
*
* Copyright (C) 2025 Ameya Angadi
*
* Code Created And Maintained By: Ameya Angadi
* Last Modified On: April 06, 2025
* Version: 1.0.0
*
*/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>
/*
Configure the I2C address for the OLED screen. Uncomment only one option below.
If the screen does not display correctly, switch to the other address.
SH110X-based OLED displays commonly use I2C addresses 0x3C or 0x3D.
*/
#define OLED_I2C_ADDRESS 0x3C // Set the I2C address to 0x3C for the OLED screen
//#define OLED_I2C_ADDRESS 0x3D // Set the I2C address to 0x3D if 0x3C doesn't work
#define DISPLAY_WIDTH 128 // Width of the OLED screen in pixels
#define DISPLAY_HEIGHT 64 // Height of the OLED screen in pixels
#define OLED_RESET -1 // Reset pin is not used (-1 indicates no reset pin)
Adafruit_SH1106G display = Adafruit_SH1106G(DISPLAY_WIDTH, DISPLAY_HEIGHT, &Wire, OLED_RESET);
float temp = 0;
#define SPLASH_SCREEN_HEIGHT 64
#define SPLASH_SCREEN_WIDTH 128
static const unsigned char PROGMEM splash_screen_bmp[] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x3f, 0xdf, 0xef, 0x1e, 0xfe, 0x7f, 0xbf, 0x81, 0xe1, 0xfe, 0xf7, 0xbf, 0x87, 0xf8, 0x01,
0x80, 0x26, 0x4c, 0x27, 0xbc, 0x63, 0x30, 0x98, 0xc1, 0xe1, 0x32, 0x63, 0x18, 0xc3, 0x08, 0x01,
0x80, 0x26, 0x4c, 0x26, 0xec, 0x63, 0x30, 0x98, 0xc1, 0x21, 0x32, 0x63, 0x18, 0xc3, 0x08, 0x01,
0x80, 0x26, 0x4c, 0x86, 0x4c, 0x63, 0x32, 0x18, 0xc3, 0x31, 0x32, 0x63, 0x18, 0xc3, 0x20, 0x01,
0x80, 0x06, 0x0f, 0x86, 0x0c, 0x63, 0x3e, 0x1f, 0x03, 0x30, 0x30, 0x63, 0x1f, 0x03, 0xe0, 0x01,
0x80, 0x06, 0x0c, 0x86, 0x0c, 0x7e, 0x32, 0x19, 0x83, 0xf0, 0x30, 0x63, 0x19, 0x83, 0x20, 0x01,
0x80, 0x06, 0x0c, 0x26, 0x0c, 0x60, 0x30, 0x98, 0xc6, 0x18, 0x30, 0x63, 0x18, 0xc3, 0x08, 0x01,
0x80, 0x06, 0x0c, 0x26, 0x0c, 0x60, 0x30, 0x98, 0xc6, 0x18, 0x30, 0x63, 0x18, 0xc3, 0x08, 0x01,
0x80, 0x1f, 0x9f, 0xef, 0xbe, 0xfc, 0x7f, 0xbe, 0x6f, 0x3c, 0xfc, 0x3e, 0x3e, 0x77, 0xf8, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x78, 0xf1, 0xf0, 0xe7, 0x8f, 0xf3, 0xfc, 0x1f, 0x0f, 0xe0, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x3d, 0xe3, 0x18, 0x63, 0x01, 0x82, 0x64, 0x31, 0x86, 0x30, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x37, 0x66, 0x0c, 0x73, 0x01, 0x82, 0x64, 0x60, 0xc6, 0x30, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x32, 0x66, 0x0c, 0x7b, 0x01, 0x82, 0x64, 0x60, 0xc6, 0x30, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x30, 0x66, 0x0c, 0x6b, 0x01, 0x80, 0x60, 0x60, 0xc7, 0xc0, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x30, 0x66, 0x0c, 0x6f, 0x01, 0x80, 0x60, 0x60, 0xc6, 0x60, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x30, 0x66, 0x0c, 0x67, 0x01, 0x80, 0x60, 0x60, 0xc6, 0x30, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x30, 0x63, 0x18, 0x63, 0x01, 0x80, 0x60, 0x31, 0x86, 0x30, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x7d, 0xf1, 0xf0, 0xf3, 0x0f, 0xf1, 0xf8, 0x1f, 0x0f, 0x9c, 0x00, 0x00, 0x01,
0x80, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x21, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x21, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x2d, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x2d, 0x7c, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x2d, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x2d, 0x70, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x2d, 0x70, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x2d, 0x00, 0x0f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x2d, 0x00, 0x0c, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x4c, 0x80, 0x0c, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x9e, 0x40, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x81, 0x3f, 0x20, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x81, 0x7f, 0xa0, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x81, 0x7f, 0xa0, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x81, 0x7f, 0xa0, 0x0c, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x81, 0x3f, 0x20, 0x0c, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x80, 0x9e, 0x40, 0x0f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0xed, 0x49,
0x80, 0x40, 0x80, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xa9, 0x55,
0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0xad, 0xdd,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xa8, 0x55,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xad, 0xd5,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
void setup() {
delay(250); // wait for the OLED to power up
display.begin(OLED_I2C_ADDRESS, true);
display.clearDisplay();
display.setTextColor(SH110X_WHITE);
display.drawBitmap(0, 0, splash_screen_bmp, 128, 64, 1); //Displays the Splash Screen
display.display();
delay(3000);
}
void loop() {
temp = analogReadTemp();
display.clearDisplay();
display.drawRect(2, 2, 126, 62, SH110X_WHITE);
display.setTextSize(2);
display.setCursor(15, 15);
display.println("CPU Temp:");
display.setTextSize(2);
display.setCursor(25, 35);
display.println(String(temp, 2));
display.setCursor(90, 35);
display.print("C");
display.display();
delay(750); //Small delay between the readings
}
Comments
Please log in or sign up to comment.