Introduction: Homemade 6 Digits Precision Thermometer With Farenheit,Reamur,Kelvin and Celcius

Guys,
In this article I wanna share my experiment on building a homemade digital thermometer with 6 digits precision,
I used a simple NTC and ATMEGA128.
Let's get started with preparing the parts....

Step 1: The Parts Needed for This Experiment...

We need some parts for this experiment :
1. ATMEGA128 board, schematic please refer to https://www.instructables.com/id/Create-yourself-a-message-flasher-with-ATMEGA128/
2. LCD 16x2
3. USBASP for debugger
4. NTC 10K
5  10K resistor

Step 2: Connect the NTC and Resistor to PF0

The next step is connect all the wires from LCD to the board,
D0-D7 to PORTA of ATMEGA128
and the control of LCD to PORTD of ATMEGA128,

For NTC, I'm gonna use ADC port 0, so connect it to PF0 of ATMEGA128,
the circuit of NTC, you can see at : https://www.instructables.com/id/Build-yourself-a-clock-and-thermometer/step2/Connect-your-arduino-to-LCDRTC-and-NTC/

Step 3: The Next Step Is Coding This ATMEGA128 to Read ADC

The next step is coding this ATMEGA128 to read ADC,
I compiled it with AVR Studio 6 and uploaded to my board with USBASP

void adc_init()
{
// enable ADC, select ADC clock = F_CPU / 128 (i.e. 125 kHz)

ADCSRA = (1<<ADEN | 1<<ADPS2 | 1<<ADPS1 | 1<<ADPS0 );

//Do a conversion

ADMUX=(1<<REFS0 | ADC_0);                  //Conversion on channel 0, thermistor input
//Internal VCC Voltage Reference
ADCSRA |= (1<<ADSC);                      //Start conversion
loop_until_bit_is_clear(ADCSRA, ADSC);    //Wait for conversion complete
}


uint16_t read_adc(void)
{
ADMUX=(1<<REFS0) | (1<<ADLAR) | ADC_0;                  // Conversion on channel 0, AVCC reference, 10 bit mode
ADCSRA |= (1<<ADSC);                     // Start conversion
loop_until_bit_is_clear (ADCSRA, ADSC);         // Wait for conversion complete
return(ADCH);
}

and convert the result to string, so it can be displayed on your LCD
double ntc_get_temp(long adcresistence, double A, double B, double C)
{
// use the Steinhart-Hart Thermistor Equation
// temperature (Kelvin) = 1 / (A + B*ln(R) + C*(ln(R)^3))
double t;
t = log( adcresistence );
t = 1 / (A + (B * t) + (C * t * t * t));
t = -1*(t - 273.15); // convert Kelvin to Celcius
//t = (t * 9.0) / 5.0 + 32.0; // convert Celcius to Fahrenheit
return t;
}

if (adcA != 0)
   {
    // itoa(adcA,volts,5);
    sprintf(volts,"adc=%.6fmV",adcA);
    lcd_string(volts);
    _delay_ms(2000);
    //measure temperature
    lcd_cmd(0x80);//put the cursor into the first row
    _delay_ms (10);
    lcd_cmd(0x01);//Clear display
    adcresistance = (long)(10230000/adc_result-10000);
   
    //d = ntc_get_temp(adcresistance, (double)0.947070725e-3, (double)2.450662058e-4, (double)1.853992838e-7);
    d = ntc_get_temp(adcresistance, (double)0.947070725e-3, (double)2.450662058e-4, (double)2.059992838e-7);
       sprintf(tempCelcius,"temp=%.6fC",d);
    //display temp to LCD
    lcd_string("Temp Value");
    lcd_cmd(0xC0);//goto second row
    //lcd_string("Value of PF0");
    _delay_ms(100);
    lcd_string(tempCelcius);
    _delay_ms(3000);
   }
   else
   {
    lcd_string("No Result!");
    _delay_ms(2000);
   }

Step 4: Test It and Have Yourself a Homemade Thermometer With 6 Digits Precision

Test it and have yourself a homemade thermometer with 6 digits precision
Checkout the video :


With Reamur, Farenheit and Kelvin

Thanks for reading

Epilog Challenge V

Participated in the
Epilog Challenge V

Pocket Sized Electronics

Participated in the
Pocket Sized Electronics