Introduction: 7 Segment Digital Thermometer Using ATtiny 85
This is a complete DIY project which requires a handful of components such as the ATtiny 85, LM35,MAX7219 and a couple of resistors and capacitors running off a regulated 5 V supply.
Temperature Measurement Range : 0 to 150'C
32 to 300’F
Controller: ATtiny 85
Display type - 4 digit multiplexed 7 segment display(Common Cathode type)
Programming Language: Arduino
The setup can display both in Celsius and Fahrenheit. By default the temperature is shown in Celsius but can be toggled to display in Fahrenheit using the push button.
Step 1: Working
The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is linearly proportional to the Celsius temperature. The LM35 does not require any external calibration or trimming to provide typical accuracies of ±1⁄4°C at room temperature and ±3⁄4°C over a full −55 to +150°C temperature range. The LM35’s low output impedance,linear output, and precise inherent calibration make interfacing to MCU easy.As it draws only 60 μA from its supply, it has very low self-heating, less than 0.1°C in still air.
The MAX7219 is a compact, serial input/output common-cathode display drivers that interface microprocessors (µPs) to 7-segment numeric LED displays of up to 8 digits. It implements a SPI compatible slave interface that can be controlled from the Arduino using only 3 of the digital output pins.
All the necessary calculations and control signals are generated by the ATtiny85. The Data, CLK & Load pin of MAX7219 is connected to pin 2,1,0 of the ATtiny85 respectively. Analog output from LM35 is feed to the ADC channel 3 of the ATtiny85.
Step 2: Circuits and Schematics:-
Circuits and Schematics used for this project.
Step 3: Code:-
#include "LedControl.h" // need the library
LedControl lc=LedControl(2,1,0,1); // lc is our object
// pin 2 is connected to the MAX7219 pin 1
// pin 1 is connected to the CLK pin 13
// pin 0 is connected to LOAD pin 12
// 1 as we are only using 1 MAX7219
int buttonState=0; // current state of the button
int lastButtonState=0; // previous state of the button
const int buttonPin=4;
int tempPin=3;
float sample;
float tempC;
float tempF;
void setup()
{
pinMode(buttonPin,INPUT);
pinMode(tempPin,INPUT);
lc.shutdown(0,false);// turn off power saving, enables display
lc.setIntensity(0,15);// sets brightness (0~15 possible values)
lc.clearDisplay(0);// clear screen
}
void printNumber(float num)
{
int ones;
int tens;
int hundreds;
int v=(int)num;
float diff=num-v;
diff=diff*100;
int fones,ftens;
fones=(int)diff%10;
diff=diff/10;
ftens=(int)diff%10;
diff=diff/10;
ones=v%10;
v=v/10;
tens=v%10;
v=v/10;
hundreds=v;
//Now print the number digit by digit
lc.setDigit(0,4,(byte)hundreds,false);
lc.setDigit(0,3,(byte)tens,false);
lc.setDigit(0,2,(byte)ones,true);
lc.setDigit(0,1,(byte)ftens,false);
lc.setDigit(0,0,(byte)fones,false);
}
void loop()
{
buttonState=digitalRead(buttonPin);
sample=0;
for(int i=0;i<150;i++)
{
sample+=analogRead(tempPin); //read the value from the sensor
delay(2);
}
sample=sample/150;
tempC=(5.0*sample*100.0)/1023.0; //convert the analog data to temperature
if(buttonState!=lastButtonState)
{
lastButtonState=buttonState;
}
if(lastButtonState==1)
{
printNumber(tempC);
delay(200);
}
if(lastButtonState==0)
{
tempF=((tempC*9)/5)+32;
printNumber(tempF);
delay(200);
}
}
14 Comments
5 years ago
Can you please provide a more readable circuit schematic please as I can't properly understand the one attached please?
Reply 5 years ago
Also is missing information from where to get the LedControl.h file. so incomplete instructables from my point of view
6 years ago
hey buddy plz help me plz
6 years ago
hey buddy plz send the library ledcontrol.h
7 years ago
Does supply voltage affect the calculation of the temp in the coding part?
7 years ago on Introduction
Cool!
8 years ago on Introduction
Awesome project. Thanks.
9 years ago on Introduction
I was wondering if this thermometer can measure temperatures below freezing? In your instructable, you said that the Lm35's full range was from -55 degrees to 150 degrees, so is it just the coding that prevents this thermometer from measuring freezing temperatures?
9 years ago on Introduction
Interesting project, but it would be nice if you added a step
showing how to actually program the ATtiny 85 -- using an
AVR programmer or by some alternate method.
10 years ago on Introduction
Great project, I was able to follow your guide and set up my LED's and temp. sensor. Can you help me to understand how one part of the CODE works ? This is the part I don't understand, I am very new to programming I have been trying to teach myself:
void printNumber(float num)
{
int ones;
int tens;
int hundreds;
int v=(int)num;
float diff=num-v;
diff=diff*100;
int fones,ftens;
fones=(int)diff%10;
diff=diff/10;
ftens=(int)diff%10;
diff=diff/10;
ones=v%10;
v=v/10;
tens=v%10;
v=v/10;
hundreds=v;
//Now print the number digit by digit
lc.setDigit(0,4,(byte)hundreds,false);
lc.setDigit(0,3,(byte)tens,false);
lc.setDigit(0,2,(byte)ones,true);
lc.setDigit(0,1,(byte)ftens,false);
lc.setDigit(0,0,(byte)fones,false);
I think this is how the numbers are printed to the LED, but how is the data passed to the function from the sensor ?
thanks
Bill
10 years ago on Introduction
Can I use individual LEDs rather than a multiplexed one?
10 years ago on Introduction
Please tell me what is this arduino thing and how can I even use the codes above...(not to mention my eletronic knowledge is limited in recognising the signs)
10 years ago on Introduction
Great project, I have built something similar but mine reads Temperature and Humidity and displays it on a webpage. My project can be found at www.arduinoprojectshq.com and has a full parts list.
James
10 years ago on Introduction
nice project, what are you using this thermometer for?