Arduino Temperature Sensor Kit
by kristeller62 in Circuits > Microcontrollers
18428 Views, 104 Favorites, 0 Comments
Arduino Temperature Sensor Kit
3-pin wire leads connect a thermistor to an analog pin on the Arduino. Once the Arduino is programmed, a 9-volt battery can supply
the power. The thermistor can be replaced with other types of sensors and the Arduino can be reprogrammed to display those sensor value readings.
kit can be ordered from Jameco http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?langId=-1&storeId=10001&productId=2184579&catalogId=10001&CID=CLO
Parts List
Arduino Mini
Power and Data Connections
Sensor
the thermistor/resistor module does not need to be soldered into the 3-pin clip. When inserted into the clip end of the 3-pin clip, the
bare thermistor leg should connect to the BLACK wire, the resistor leg should connect to the RED wire and the thermistor leg that has the resistor soldered should connect to the DATA wire (the DATA wire could be YELLOW, WHITE or even BLUE)
Arduino Header Pins
7-Segment Pins
so it fits in the GND hole on the TOP FRONT of the Arduino.
7-Segment Ground Pin
on the FRONT TOP of the Arduino.
Program Arduino
Connect your computer to the Arduino with your FTDI connection and upload the thermistor program (source program included here made up of parts taken from samples online)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Ai5 = A5;
int Value5;
boolean hb = HIGH;
int hbCNT = 0;
int digit1 = 10; // 11; //PWM Display pin 1
int digit2 = 11; // 10; //PWM Display pin 2
int segD = 12; // A1; // 5; //Display pin 3
//not used 13; // pin 4
int segE = A0; // A0; //Display pin 5
int digit3 = A1; // 12; // 9; //PWM Display pin 6
int dp3 = A2; // 9; // 12;
Step 11 - 7 segment BOTTOM
Confirm the pins on the 7 segment display fit in the holes on the BOTTOM FRONT of the Arduino.
int digit4 = A3; // 13; // 6; //PWM Display pin 8
int segB = 9; // 3; //Display pin 16
int segG = 8; //Display pin 15
int segA = 7; //5; // A1; //Display pin 14
int segC = 6; // 4; //Display pin 13
//not used 5; // pin 12
int segF = 4; // 7; // 7; //Display pin 11
int dphb = 3; // A3; pin 10
// GND // pin 9
void setup() {
pinMode(segA, OUTPUT);
pinMode(segB, OUTPUT);
pinMode(segC, OUTPUT);
pinMode(segD, OUTPUT);
pinMode(segE, OUTPUT);
pinMode(segF, OUTPUT);
pinMode(segG, OUTPUT);
pinMode(digit1, OUTPUT);
pinMode(digit2, OUTPUT);
pinMode(digit3, OUTPUT);
pinMode(digit4, OUTPUT);
pinMode(dp3, OUTPUT);
pinMode(Ai5,INPUT);
Serial.begin(9600);
Serial.println();
}
void loop()
{
//show temp
displayNumber(Value5);
//show heartbeat
if (!(hbCNT % 100)) hb=!hb;
//query temp
if (hbCNT++ > 300)
{
hbCNT = 1;
//store thermistor resistance value
Value5 = analogRead(Ai5); //Read the value of AI1 (pin2) and write it to Value1
Serial.print(Value5);
Serial.print(" [] ");
Serial.print( 1000/(float(1023 / float(Value5)) -1));
float steinhart, average;
average = 1023 / float(Value5) - 1;
average = 10000 / average;
steinhart = average / 1000; // (R/Ro)
steinhart = log(steinhart); // ln(R/Ro)
steinhart /= 3636; // 1/B * ln(R/Ro)
steinhart += 1.0 / (25 + 273.15); // + (1/To)
steinhart = 1.0 / steinhart; // Invert
Serial.print(" [] ");
Serial.print(average);
Serial.print(" [k] ");
Serial.print(steinhart);//kelvin
Serial.print(" [c] ");//celcius
steinhart -= 273.15;
Serial.print(steinhart);
Serial.print(" [f] ");//fahrn
steinhart = steinhart * 9 / 5 + 32;
Serial.print(steinhart);
Serial.print(" ||| ");
Value5 = steinhart*10;
Serial.println(Value5);
}
}
void displayNumber(int toDisplay) {
#define DISPLAY_BRIGHTNESS 500
#define DIGIT_ON HIGH
#define DIGIT_OFF LOW
long beginTime = millis();
for(int digit = 4 ; digit > 0 ; digit--) {
digitalWrite(dp3, HIGH);
//Turn on a digit for a short amount of time
switch(digit) {
case 1:
digitalWrite(digit1, DIGIT_ON);
break;
case 2:
digitalWrite(digit2, DIGIT_ON);
break;
case 3:
digitalWrite(digit3, DIGIT_ON);
digitalWrite(dp3, !hb);
break;
case 4:
digitalWrite(digit4, DIGIT_ON);
break;
}
digitalWrite(dphb, !hb);
//Turn on the right segments for this digit
lightNumber(toDisplay % 10);
toDisplay /= 10;
delayMicroseconds(DISPLAY_BRIGHTNESS); //Display this digit for a fraction of a second (between 1us and 5000us, 500 is pretty
good)
//Turn off all segments
lightNumber(10);
//Turn off all digits
digitalWrite(digit1, DIGIT_OFF);
digitalWrite(digit2, DIGIT_OFF);
digitalWrite(digit3, DIGIT_OFF);
digitalWrite(digit4, DIGIT_OFF);
}
while( (millis() - beginTime) < 10) ; //Wait for 20ms to pass before we paint the display again
}
//Given a number, turns on those segments
//If number == 10, then turn off number
void lightNumber(int numberToDisplay) {
#define SEGMENT_ON LOW
#define SEGMENT_OFF HIGH
switch (numberToDisplay){
case 0:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_ON);
digitalWrite(segE, SEGMENT_ON);
digitalWrite(segF, SEGMENT_ON);
digitalWrite(segG, SEGMENT_OFF);
break;
case 1:
digitalWrite(segA, SEGMENT_OFF);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_OFF);
digitalWrite(segE, SEGMENT_OFF);
digitalWrite(segF, SEGMENT_OFF);
digitalWrite(segG, SEGMENT_OFF);
break;
case 2:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_OFF);
digitalWrite(segD, SEGMENT_ON);
digitalWrite(segE, SEGMENT_ON);
digitalWrite(segF, SEGMENT_OFF);
digitalWrite(segG, SEGMENT_ON);
break;
case 3:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_ON);
digitalWrite(segE, SEGMENT_OFF);
digitalWrite(segF, SEGMENT_OFF);
digitalWrite(segG, SEGMENT_ON);
break;
case 4:
digitalWrite(segA, SEGMENT_OFF);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_OFF);
digitalWrite(segE, SEGMENT_OFF);
digitalWrite(segF, SEGMENT_ON);
digitalWrite(segG, SEGMENT_ON);
break;
case 5:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_OFF);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_ON);
digitalWrite(segE, SEGMENT_OFF);
digitalWrite(segF, SEGMENT_ON);
digitalWrite(segG, SEGMENT_ON);
break;
case 6:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_OFF);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_ON);
digitalWrite(segE, SEGMENT_ON);
digitalWrite(segF, SEGMENT_ON);
digitalWrite(segG, SEGMENT_ON);
break;
case 7:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_OFF);
digitalWrite(segE, SEGMENT_OFF);
digitalWrite(segF, SEGMENT_OFF);
digitalWrite(segG, SEGMENT_OFF);
break;
case 8:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_ON);
digitalWrite(segE, SEGMENT_ON);
digitalWrite(segF, SEGMENT_ON);
digitalWrite(segG, SEGMENT_ON);
break;
case 9:
digitalWrite(segA, SEGMENT_ON);
digitalWrite(segB, SEGMENT_ON);
digitalWrite(segC, SEGMENT_ON);
digitalWrite(segD, SEGMENT_ON);
digitalWrite(segE, SEGMENT_OFF);
digitalWrite(segF, SEGMENT_ON);
digitalWrite(segG, SEGMENT_ON);
break;
case 10:
digitalWrite(segA, SEGMENT_OFF);
digitalWrite(segB, SEGMENT_OFF);
digitalWrite(segC, SEGMENT_OFF);
digitalWrite(segD, SEGMENT_OFF);
digitalWrite(segE, SEGMENT_OFF);
digitalWrite(segF, SEGMENT_OFF);
digitalWrite(segG, SEGMENT_OFF);
break;
}
}