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);
    }
}

Step 4: Pics and Video