Adds

24 June 2015

Arduino with a thermistor to get temperature


Simple Arduino circuit to get temperature from a simple thermistor, prints data to Serial Monitor. 

Please let me know if you experience any problems with this code. Be sure to check back for more Arduino code.

Schematic:



Code:


 /*  
   
 Oliver Holden  
 Created 28/10/2014  
   
 Components:  
 * Arduino UNO  
 * Thermistor  
 * 10K resistor  
   
 - Gets Temperature form a Thermistor  
   
 Prints the data to the Serial Monitor  
   
 Schematic for this project is on:  
 www.breadboarder.blogspot.co.uk  
   
    
 */  
   
   
 int ThermistorPin = A0;   // Thermister Reading pin  
   
 void setup()   
 {  
 Serial.begin(9600);   // Opening serial connection at 9600bps  
 Serial.println("Thermistor temperature measurement:");   // Printing Serial Monitor header  
 Serial.println("\n      Vo      Rt      T (C)");  
 }  
   
 void loop() {  
    
 int Vo;   // Integer value of voltage reading  
   
 float R = 9870.0;   // Fixed resistance in the voltage divider  
 float logRt,Rt,T;  
 float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;  
   
 Vo = analogRead(ThermistorPin);   // Reading voltage of Thermistor Reading pin      
   
 Rt = R*( 1023.0 / (float)Vo - 1.0 );  
   
 logRt = log(Rt);  
   
 T = ( 1.0 / (c1 + c2*logRt + c3*logRt*logRt*logRt ) ) - 273.15;   // Convertion to get temperature from thermistor  
   
 Serial.print("     "); Serial.print(Vo);   // Printing data to Serial Monitor  
   
   
 Serial.print("     "); Serial.print(Rt);  
   
   
 Serial.print("     "); Serial.println(T);  
   
 delay(1000);   // Printing data once per second  
 }  

No comments:

Post a Comment