This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Hello, everyone, I have a problem with temperature printing on LCD the temperature values in Keil console ar showing the correct result but when printing on LCD it's showing incorrect values and I don't know where the problem is. please can someone

Here is the codes, the result on Keil console is right but on the LCD shown incorreclty please someone should help me out am new in microcontrollers. thanks in advance

float logR2, R2, T;
float R1=9950;
float c1 = 0.001125308852122, c2 = 0.000234711863267, c3 = 0.000000085663516;
char write[16]=" ";

lcd_init(_LCD_4BIT, _LCD_FONT_5x8, _LCD_2LINE);
lcd_print(1,1, "temperature");
HAL_Delay(10);

HAL_ADC_Start (&hadc1);
HAL_ADC_PollForConversion (&hadc1, 5);
adc_Val = HAL_ADC_GetValue(&hadc1);
R2 = (R1*adc_Val/(4096-adc_Val));
logR2 = log(R2);
T =(1/ (c1 + c2*logR2 + c3*logR2*logR2*logR2));
T= (T-273.15);
sprintf(write,"%.2f C",T);
HAL_Delay (500);