#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x27
#define LCD_COLUNAS 20
#define LCD_LINHAS 4
#define ledQuente 7
#define ledFrio 8
const float BETA = 3950; // should match the Beta Coefficient of the thermistor
LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUNAS, LCD_LINHAS);
void setup() {
// Init
lcd.init();
lcd.backlight();
Serial.begin(9600);
pinMode(ledQuente, OUTPUT);
pinMode(ledFrio, OUTPUT);
Serial.print("Sensor de temperatura com alerta para temperaturas insalubres, \nconforme Norma Regulamentadora No. 15 (NR-15). \nFonte: https://www.gov.br/trabalho-e-emprego/pt-br/acesso-a-informacao/participacao-social/conselhos-e-orgaos-colegiados/comissao-tripartite-partitaria-permanente/normas-regulamentadora/normas-regulamentadoras-vigentes/norma-regulamentadora-no-15-nr-15");
}
void loop() {
int analogValue = analogRead(A0);
float celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
float farenheit = (celsius * 1.8) + 32;
Serial.print("\nTemperatura: ");
Serial.print(celsius);
Serial.print(" ℃ \nTemperatura: ");
Serial.print(farenheit);
Serial.print("ºF");
Serial.print("\n***");
lcd.setCursor(0, 0);
lcd.print(celsius);
lcd.setCursor(7, 0);
lcd.print("oC");
lcd.setCursor(0,1);
lcd.print(farenheit);
lcd.setCursor(7,1);
lcd.print("oF");
delay(1000);
if(celsius < 12){
digitalWrite(ledFrio, HIGH);
} else if(celsius > 26.7){
digitalWrite(ledQuente, HIGH);
} else{
digitalWrite(ledFrio, LOW);
digitalWrite(ledQuente, LOW);
}
}