10 Thermistor with a 10k Resistor on 5v? - SOLVED

Hello, I'm working on just displaying simple temperature sensor using a 10k Thermistor with a 10k Resistor on 5v. Everything is working however in displaying the temperature looks way to high its showing 76c when I know for a fact it is not that hot in my room it shows 21.6c. I'm not sure what is wrong with the coding. I also added a 128x64 oled 1.3". Attching the coding below. I'm not good with temperature stuff or what I'm doing wrong in coding. It is what I found online and modded together.

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <math.h>         //loads the more advanced math functions

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

void setup()   {                
  Serial.begin(9600);

  // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64)
  // init done
  
  // Show image buffer on the display hardware.
  // Since the buffer is intialized with an Adafruit splashscreen
  // internally, this will display the splashscreen.
  display.display();
  delay(2000);
  // Clear the buffer.
  display.clearDisplay();
 // draw a single pixel
  display.drawPixel(10, 10, WHITE);
  // Show the display buffer on the hardware.
  // NOTE: You _must_ call display after making any drawing commands
  // to make them visible on the display hardware!
  display.display();
  delay(2000);
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.print("Designed by "); display.println( "me");
  display.display();
  delay(2000);
  display.clearDisplay();
}

double Thermister(int RawADC) {  //Function to perform the fancy math of the Steinhart-Hart equation
 double Temp;
 Temp = log(((10240000/RawADC) - 10000));
 Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
 Temp = Temp - 273.15;              // Convert Kelvin to Celsius
 Temp = (Temp * 9.0)/ 5.0 + 32.0; // Celsius to Fahrenheit - comment out this line if you need Celsius
 return Temp;
}

void loop() {
  int val;                //Create an integer variable
  double temp;            //Variable to hold a temperature value
  val=analogRead(0);      //Read the analog port 0 and store the value in val
  temp=Thermister(val);   //Runs the fancy math on the raw analog value
 // Serial.println(temp);   //Print the value to the serial port
  display.setCursor(10, 0);
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.print(temp); display.println("c");
  display.display();
  delay(1000);            //Wait one second before we do it again 
  display.clearDisplay();
}

Can someone help me please to figure this problem out?

Edit:

This is the code for the thermistor and This is the code for the LCD display.

Joseph

i'm so sorry, I missed one line that said it is in Fahrenheit. If i would like it in Celsius i need to comment out this line

Temp = (Temp * 9.0)/ 5.0 + 32.0; // Celsius to Fahrenheit - comment out this line if you need Celsius.

Please disregaurd this post. Or Keep it if others have this problem like i did.

Joseph

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.