03-04-13, 05:50 AM | #8 |
Master EcoRenovator
Join Date: Aug 2012
Location: Toronto
Posts: 958
Thanks: 40
Thanked 158 Times in 150 Posts
|
Here is the current code which is purely a copied code from the Adafruit site "using a thermister". Then, I added the last line from Jeffs approach in bold. It seems to ignore the added code and continues to post in ohms. I am looking for a reason for this but the program doesn't come up with any errors.
Code:
// the value of the 'other' resistor #define SERIESRESISTOR 10000 // What pin to connect the sensor to #define THERMISTORPIN A0 void setup(void) { Serial.begin(9600); } void loop(void) { float reading; reading = analogRead(THERMISTORPIN); Serial.print("Analog reading "); Serial.println(reading); // convert the value to resistance reading = (1023 / reading) - 1; reading = SERIESRESISTOR / reading; Serial.print("Thermistor resistance "); Serial.println(reading); float logcubed = log(reading); logcubed = logcubed * logcubed * logcubed; float kelvin = 1.0 / (-7.5e-4 + 6.23e-4 * log(reading) - 1.73e-6 * (logcubed)); float celsius = kelvin - 273.15; delay(1000); } Last edited by Piwoslaw; 03-04-13 at 01:55 PM.. |
|
|