#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
/*define prototypes*/
void LCD_Init(void);
float SensorTemp(void);
void setup() {
LCD_Init();
// put your setup code here, to run once:
}
void loop() {
lcd.setCursor(0,0);
lcd.print("Temp Current");
lcd.setCursor(0,1);
lcd.print(SensorTemp());
lcd.setCursor(5,1);
lcd.print("C");
delay(1000);
// put your main code here, to run repeatedly:
}
/*@param void LCD_Init(void)
* @param This function initialize config to LCD
* @param return none
*/
void LCD_Init(void){
lcd.init();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("SensingTemp");
lcd.setCursor(0,1);
lcd.print("With NTC Sensor");
delay(1000);
lcd.clear();
}
/*@param float SensorTemp(void)
* @param this function return value the sensor
* @param return value sensor in tyoe data float
*/
float SensorTemp(void){
float analogValue;
analogValue = analogRead(A0);
return (1 / (log(1 / (1023. / analogValue - 1)) / 3950 + 1.0 / 298.15) - 273.15);
}