#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
char tempChar[8] = {
B00100,
B01010,
B01010,
B01010,
B01110,
B11111,
B11111,
B01110
};
unsigned long interval = 5000;
unsigned long previousMillis = 0;
unsigned long currentMillis;
const float BETA = 3950;
float meranie = 0;
float vysledok = 0;
int analogValue;
void setup() {
lcd.init();
lcd.backlight();
lcd.createChar(1, tempChar);
lcd.setCursor(0,0);
lcd.print("Meranie teploty");
lcd.setCursor(0,1);
lcd.print("Timotej Ilko");
}
void loop() {
currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
measure();
}
}
void measure(){
meranie = 0;
for(int i = 0; i<5; i++){
analogValue = analogRead(A3);
meranie = meranie + (1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15);
vysledok = meranie/5.0;
delay(10);
}
display();
}
void display(){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("\x01TEPLOTA:");
lcd.setCursor(10,0);
char vysledokStr[3];
dtostrf(vysledok, 4, 1, vysledokStr);
lcd.print(vysledokStr);
lcd.setCursor(14,0);
lcd.print((char) 223);
lcd.print("C");
}