top of page

Arduino and Thermistors - Part 2 (Implementation)


Moving on to the next part, we will be implementing the concepts discussed in Part 1.


Parts Required:

  • Arduino Mega (You can use Arduino UNO but we needed more analog channels)

  • Thermistor 100k - 104JG1F

  • Resistors for reference (4.7K and 6.8K are used here)

  • High-Temperature Wires

Prerequisites/Tools

Steps:

  • I made all the connections on a perf board to not damage the Arduino and added hot glue on the connections to secure them.


  • A rule of thumb to select the reference resistor is to check the resistance of the thermistor at the temperature you want to measure (115°C and 100°C in this case)

  • Make the connections as follows.


  • Load the code.


/*=============================================================================

| Title: Arduino and Thermistors

|

| Author: Pranav Ravuri

| Last Modified: 1st October, 2022

|

+-----------------------------------------------------------------------------

|

| Description: This script is used to get thermistor values from arduino

| and print it in terminal. The values are read by ArduSpread

| and save to an excel sheet

|

|

*===========================================================================*/


#define RT0 100000 //Ω These values are in the datasheet

//--------------------------------------


#define A 0.6031048741e-3 // The calculated A value

#define B 2.298755477e-4 // The calculated B value

#define C 0.6893798565e-7 // The calculated C value

#define VCC 5 //Supply voltage


// I am using two different resistor values, change these according to your setup

#define R1 4700 //R=100KΩ

#define R2 6800 //R=100KΩ



// Pin definition

#define Thermistor_1_pin A0

#define Thermistor_2_pin A1

#define Thermistor_3_pin A2

#define Thermistor_4_pin A3

#define Thermistor_5_pin A8

#define Thermistor_6_pin A9

#define Thermistor_7_pin A10



//Variables


float RT1, VR1, TX1, VRT1;

float RT2, VR2, TX2, VRT2;

float RT3, VR3, TX3, VRT3;

float RT4, VR4, TX4, VRT4;

float RT5, VR5, TX5, VRT5;

float RT6, VR6, TX6, VRT6;

float RT7, VR7, TX7, VRT7;



void setup() {

Serial.begin(9600);

}


void loop() {

VRT1 = analogRead(Thermistor_1_pin); //Acquisition analog value

VRT1 = (5.00 / 1023.00) * VRT1; //Conversion to voltage

VR1 = VCC - VRT1; //Calculate voltage drop across the thermistor

RT1 = VRT1 / (VR1 / R1); //Resistance of RT

TX1 = 1 / (A + B * log(RT1) + C * log(RT1) * log(RT1) * log(RT1)); //S-H formula

TX1 = TX1 - 273.15; //Conversion to Celsius


////////////// Repetition //////////////


VRT2 = analogRead(Thermistor_2_pin);

VRT2 = (5.00 / 1023.00) * VRT2;

VR2 = VCC - VRT2;

RT2 = VRT2 / (VR2 / R1);

TX2 = 1 / (A + B * log(RT2) + C * log(RT2) * log(RT2) * log(RT2));

TX2 = TX2 - 273.15;


//////////////////////////////////////////////////////////////////////////


VRT3 = analogRead(Thermistor_3_pin);

VRT3 = (5.00 / 1023.00) * VRT3;

VR3 = VCC - VRT3;

RT3 = VRT3 / (VR3 / R1);

TX3 = 1 / (A + B * log(RT3) + C * log(RT3) * log(RT3) * log(RT3));

TX3 = TX3 - 273.15;


//////////////////////////////////////////////////////////////////////////


VRT4 = analogRead(Thermistor_4_pin);

VRT4 = (5.00 / 1023.00) * VRT4;

VR4 = VCC - VRT4;

RT4 = VRT4 / (VR4 / R1);

TX4 = 1 / (A + B * log(RT4) + C * log(RT4) * log(RT4) * log(RT4));

TX4 = TX4 - 273.15;

/////////////////////////////////////////////////////////////////////////////


VRT5 = analogRead(Thermistor_5_pin);

VRT5 = (5.00 / 1023.00) * VRT5;

VR5 = VCC - VRT5;

RT5 = VRT3 / (VR5 / R2);

//RT = 4453;

TX5 = 1 / (A + B * log(RT5) + C * log(RT5) * log(RT5) * log(RT5));

TX5 = TX5 - 273.15;


//////////////////////////////////////////////////////////////////////////


VRT6 = analogRead(Thermistor_6_pin);

VRT6 = (5.00 / 1023.00) * VRT6;

VR6 = VCC - VRT6;

RT6 = VRT6 / (VR6 / R2);

TX6 = 1 / (A + B * log(RT6) + C * log(RT6) * log(RT6) * log(RT6));

TX6 = TX6 - 273.15;


/////////////////////////////////////////////////////////////////////////////


VRT7 = analogRead(Thermistor_7_pin);

VRT7 = (5.00 / 1023.00) * VRT7;

VR7 = VCC - VRT7;

RT7 = VRT7 / (VR7 / R2);

TX7 = 1 / (A + B * log(RT7) + C * log(RT7) * log(RT7) * log(RT7));

TX7 = TX7 - 273.15;


////// Printing comma separated themperature values to console /////////////

Serial.print(TX1);

Serial.print(",");

Serial.print(TX2);


  Serial.print(",");

Serial.print(TX3);

Serial.print(",");

Serial.print(TX4);

Serial.print(",");

Serial.print(TX5);

Serial.print(",");

Serial.print(TX6);

Serial.print(",");

Serial.print(TX7);

Serial.print("\n");

delay(1900);


}


  • Open the serial terminal, the values should start printing.

  • Now that temperature values are being printed to the console, we will use ArduSpread to save the values into an excel sheet.

  • Download ArduSpread directly from Arduino Extension Download and extract the files into the tools folder of the Arduino installation, like so (be careful with the folders, extract it directly).



  • Now restart Arduino IDE.

  • You should see ArduSpread under tools.



  • Check mark the timestamp to add a new column with the timestamp.



  • Click on Save/Append button to save the values or append the values to an existing document at the end.

The Values will be appended to the existing document if the document is already created.




28 views0 comments

Recent Posts

See All
bottom of page