/*
Madelaino Neto Da Silva
4BIOT1
13-9-2024
*/
#include <LiquidCrystal_I2C.h>
#include <OneWire.h>
#include <DallasTemperature.h>
OneWire oneWire(10);
DallasTemperature sensor1(&oneWire);
DallasTemperature sensor2(&oneWire);
#define I2C_ADDR 0x27
#define LCD_COLUMNS 20
#define LCD_LINES 4
LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUMNS, LCD_LINES);
void setup(void) {
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
Serial.begin(115200);
delay(2);
sensor1.begin();
sensor2.begin();
delay(20);
////////////////////
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0); // Set the cursor on the LCD screen
lcd.print("De boven kamer is:"); // Type on the screen this phrase
lcd.setCursor(0, 2); // Set the cursor on the LCD screen
lcd.print("De beneden kamer is:"); // Type on the screen this phrase
}
void loop(void) {
sensor1.requestTemperatures();
sensor2.requestTemperatures();
Serial.print("De boven kamer is ");
delay(1);
Serial.println(sensor1.getTempCByIndex(0));
delay(1);
Serial.print("De beneden kamer is ");
delay(1);
Serial.println(sensor2.getTempCByIndex(0));
delay(1);
/////////////////////////////////////////
lcd.setCursor(0, 1);
lcd.print(sensor1.getTempCByIndex(0));
lcd.setCursor(0, 3);
lcd.print(sensor2.getTempCByIndex(0));
if(sensor1.getTempCByIndex(0) > 25) { // Correct function call with index
digitalWrite(3, LOW); // Turn off if temperature > 25
} else {
digitalWrite(3, HIGH); // Turn on if temperature <= 25
}
if(sensor2.getTempCByIndex(0) > 25) { // Correct function call with index
digitalWrite(4, LOW); // Turn off if temperature > 25
} else {
digitalWrite(4, HIGH); // Turn on if temperature <= 25
}
}