Simple Arduino circuit to get temperature from a thermistor, prints data to Serial Monitor and PLX-DAQ Excel spreadsheet.
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
Data is sent to an Excel spreadsheet through data
acquisition software, PLX-DAQ, Download http://www.parallax.com/downloads/plx-daq
Schematic for this project is on
http://breadboarder.blogspot.co.uk/
*/
int ThermistorPin = A0; // Thermister Reading pin
int x = 0; // For PLX-DAQ
int row = 0; // For PLX-DAQ
void setup()
{
Serial.begin(9600); // Opening serial connection at 9600bps
Serial.println("Thermistor temperature measurement:"); // Printing Serial Monitor header
Serial.println("LABEL, Time, Vo, Rt, T (C)"); // Setting headers of colums in PLX-DAQ spreadsheet
Serial.println("\n Vo Rt T (C)");
}
void loop() {
int Vo;
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);
row++; // For PLX-DAQ
x++; // For PLX-DAQ
delay(1000); // Printing data once per second
}
No comments:
Post a Comment