EveryCircuit
Contact
Reviews
Home
crake
modified 7 years ago

Thermistor Temp Sensor With 7 Seg

7
7
592
09:38:10
The circuit here is a simplification of what the code below is for. If you would like to use the code below, use an Arduino, two BCD's and two 7 Segment displays, Thermistor, resistor and an op amp. If you have questions, feel free to ask. The code below samples the voltage across a Thermistor and then uses this voltage to calculate temperature. The temperature (F) is then rounded to the nearest two digits and printed on the 7 segment displays. My Parts list: Arduino UNO or Nano microcontroller. lds-c514ri Seven Segment Display. hd74ls48p BCD. LT1006 Opamp. Antique Thermistor. 56k ohm resistor. const bool bcd[11][40] = {{0,0,0,0}, //DCBA --> 0 {0,0,0,1}, //DCBA --> 1 {0,0,1,0}, //DCBA --> 2 {0,0,1,1}, //DCBA --> 3 {0,1,0,0}, //DCBA --> 4 {0,1,0,1}, //DCBA --> 5 {0,1,1,0}, //DCBA --> 6 {0,1,1,1}, //DCBA --> 7 {1,0,0,0}, //DCBA --> 8 {1,0,0,1}, //DCBA --> 9 {1,1,1,1}}; //DCBA --> 10 "blank" const int pin = 0; const float res = 0.00471261; //const float To = 293.00; const float To = 298.00; const float Ro = 50000.0; //const float beta = 5066.0; //Beta for Antique Thermistor const float beta = 3095.0; //Beta for MF52C1503F3950 const float numSample = 10.0; void writeToBCD1(int); void writeToBCD2(int); float getTempFar(); void setup() { Serial.begin(9600); pinMode(pin, INPUT); pinMode(2, OUTPUT); //D1 --> pin2 pinMode(3, OUTPUT); //C1 --> pin3 pinMode(4, OUTPUT); //B1 --> pin4 pinMode(5, OUTPUT); //A1 --> pin5 pinMode(6, OUTPUT); //D2 --> pin6 pinMode(7, OUTPUT); //C2 --> pin7 pinMode(8, OUTPUT); //B2 --> pin8 pinMode(9, OUTPUT); //A2 --> pin9 } void loop() { int i = 0; float tempFarAvg = 0; while(i < numSample) { tempFarAvg += getTempFar(); i++; delay(7); Serial.print("Sample: "); Serial.println(i); } int rounded = round(tempFarAvg/numSample); Serial.print("Rounded temp = "); Serial.println(rounded); if(rounded < 0) { writeToBCD1(0); writeToBCD2(0); } else if(rounded > 0 && rounded < 10) { writeToBCD1(10); writeToBCD2(rounded); } else if(rounded >= 100) { writeToBCD1(9); writeToBCD2(9); } else { int firstDig = rounded/10; writeToBCD1(firstDig); int subtractor = firstDig*10; int secDig = rounded - subtractor; writeToBCD2(secDig); } } void writeToBCD1(int msd) { for(int i = 0; i < 4; i++) { digitalWrite(i + 2, bcd[msd][i]); } } void writeToBCD2(int lsd) { for(int i = 0; i < 4; i++) { digitalWrite(i + 6, bcd[lsd][i]); } } float getTempFar() { float volt = analogRead(pin)*res; float Rdel = 50470/((4.596/volt)-1); float tempKel = (To*beta)/(To*log(Rdel/Ro)+beta); float tempFar = (9.0/5.0)*(tempKel-273) + 32; return(tempFar); }
published 7 years ago
lenzrulz
7 years ago
Excellent description. Just one question, what ideal applications would this temperature sensor be useful?
crake
7 years ago
This temperature sensor? This sensor is going to be used to measure room temperature. Ideally, Thermistors are used in Industrial, Automotive and other applications where quickly changing temperature is measured within some narrow band (since they are non-linear). Once my order of non-antique thermistors arrives I plan on using this setup within 0 - 99 F and testing it against another temperature sensor. The cool thing is, this code could quickly be modified for a different temp sensor, should a Thermistor not be a sensor someone would like to use.
lenzrulz
7 years ago
Thanks crake...👍
crake
7 years ago
You're welcome, lenz.
crake
7 years ago
Using the new Thermistor, i have tested this setup against another thermometer at 20F and 76F. The setup seems to track temperature very well. I measured my body temp too lol. It read 98F. Pretty good. This is worth using if anyone wants a fun project.
crake
7 years ago
Cantherm / MF52C1503F3950 is the Thermistor
hurz
7 years ago
@crake, you reall think Lenny cares your comments? LOL

EveryCircuit is an easy to use, highly interactive circuit simulator and schematic capture tool. Real-time circuit simulation, interactivity, and dynamic visualization make it a must have application for professionals and academia. EveryCircuit user community has collaboratively created the largest searchable library of circuit designs. EveryCircuit app runs online in popular browsers and on mobile phones and tablets, enabling you to capture design ideas and learn electronics on the go.

Copyright © 2025 by MuseMaze, Inc.     Terms of use     Privacy policy