## Introduction: How to Use a Thermistor Sensor With Arduino

I had the idea to create something that would show when someone had a fever with LED lights. The idea is that the red Led light will light up when the thermistor has a reading over 99 degrees Fahrenheit but it will also light up a blue LED light when the thermistor reads under 99.

## Supplies

1-Elegoo Uno R3 and USB connector cord

1-Thermistor

2- Resistors 220

1-Red LED

1- Blue LED

## Step 1: Step 1: Supplies

As listed above these are the supplies I used. Make sure to have all of the correct supplies

## Step 2: Step2: the Code

/* Amber Freiburger 11-30-2020 * Inspired by Ricardo Moreno tutorial * https://github.com/rmorenojr/ElegooTutorial/blob/master/Lesson%2023%20-%20Thermometer/Thermometer/Thermometer.ino * The concept is that when someone has a fever * and the temperature reads over 99F * then a red LED will light up. If someone * is under 99F then the Blue LED will light up * */const int thermistorPin = A0; // Thermistor pin const float Resistor2 = 10000.0; // R2 resistor Value const int SampleNumber = 30; // The number of analog samples (30 max for integer) const int aMax = 1023; // Maximum Analog value 1023 const float t25 = 25.0+273.15; // Temperature in Kelvin at 25C const float r25 = 10000.0; // Thermistor resistance at 25C const float Beta = 3950.0; // Thermistor Beta from the datasheet //Steinhart-Hart Coefficient values - calculated const float scA = 0.00102219653793705; const float scB = 0.000253179116444952; const float scC = -0.000000000058799201163101;float R1 = 10000;float logR2, R2, T;float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;int aValues[SampleNumber]; // Analog value Array int index = 0; // Tracks the array index int total = 0; // Keeps a running totalint Vo;int redLED = 6;int blueLED = 7;void setup() { Serial.begin(9600); int aValue = analogRead(thermistorPin); // Get inital analog value seed for(int x=0; x= 72) {digitalWrite(redLED, HIGH); } else if (tFahrenheit >= 46 && tFahrenheit < 71){ digitalWrite (blueLED, HIGH); } else { digitalWrite (redLED, LOW); digitalWrite (blueLED, LOW); } //delay(1000); }/* *********************************************************** * Functions * * ********************************************************* */float readThermistor(){ // Uses a smoothing technique total = total - aValues[index]; // Subtract the last reading aValues[index] = analogRead(thermistorPin); // Get analog value total = total + aValues[index]; // Running total index += 1; // Increment index if (index >= SampleNumber){index = 0;} // Reset index if >= SampleNumber float Average = float(total) / float(SampleNumber); // Calculate average float rThermistor = Resistor2 * (float(aMax)/Average - 1.0); // Thermistor resistance float tKelvin = 1.0/(scA + scB * log(rThermistor) + scC * (pow(log(rThermistor),3))); float tCelsius = tKelvin - 273.15; // Convert Kelvin to Celsius return(tCelsius); //tKelvin = 1 / (0.001129148 + 0.000234125 * log(rThermistor) + 0.0000000876741 * pow(log(rThermistor),3))); // where A = 0.001129148, B = 0.000234125, and C = 0.0000000876741 // how were these calculated?}

## Step 3: Step 3: the Breadboard

I tried to get the diagram as easily read as possible but the setup is pretty simple. Note: Fritzing did not have the thermistor I have so instead I just used the one available for the diagram.

## Step 4: Step 4: Trying It Out

Due to the cold weather I had to adjust the degrees in order to get the thermistor to read a difference. Under 71 degrees, the blue LED stays lit but once it goes over 72 degrees the red LED comes on and the blue turns off temporarily until the temperature goes back down. At first it would read the temperature just from me touching the thermistor but at second attempt on a colder day I had to blow on the thermistor to get the temperature to raise. I hope to get the thermistor to be able to stay at a higher temperature as it started out very low but it seems that atmosphere is influencing the sensor. This was only the start to what I plan on creating.