EveryCircuit
Powering up...
Circuit
Public
Private
Unlisted
Save

Thermistor Temp Sensor With 7 Seg

@crake
8 years ago
https://everycircuit.com/circuit/5813409303232512
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); }
Comments
Post