#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#define DHTPIN 2 // pin where the DHT11 is connected
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x3F, 16, 2,33); // Set the LCD address to 0x3F for a 16 chars and 2 line display
void setup() {
Serial.begin(115200);
dht.begin();
lcd.init(); // initialize the LCD
lcd.backlight(); // turn on backlight
}
void loop() {
delay(2000); // Wait for 2 seconds before measuring the temperature again
float temp = dht.readTemperature(); // Read temperature in Celsius
float fahr = temp * 1.8 + 32; // Convert Celsius to Fahrenheit
lcd.clear(); // Clear the LCD screen
lcd.setCursor(0,0); // Set the cursor to the top left corner of the LCD screen
lcd.print("Temp:"); // Print "Temp:" on the LCD screen
lcd.setCursor(6,0); // Set the cursor to the 7th column of the first row
lcd.print(fahr); // Print the temperature in Fahrenheit on the LCD screen
lcd.setCursor(12,0); // Set the cursor to the 13th column of the first row
lcd.print("F"); // Print "F" for Fahrenheit on the LCD screen
Serial.print("Temperature: ");
Serial.print(fahr);
Serial.println("F");
}