/****************************************************************************
To interface with DHT22 and DS1307 RTC sensors, you will need to use appropriate libraries for your microcontroller board. For example, for Arduino, you can use the Adafruit DHT library for the DHT22 sensor and the Adafruit RTClib library for the DS1307 RTC sensor.
To interface with the OLED and LCD displays, you will need to use the appropriate libraries for the I2C interface. For example, for Arduino, you can use the Adafruit_SSD1306 library for the OLED display and the LiquidCrystal_I2C library for the LCD display.
Once you have installed the necessary libraries, you can use the following steps to display humidity on the LCD 1602 and time on the OLED:
Initialize the DHT22 sensor and DS1307 RTC sensor using the appropriate library functions.
Initialize the OLED display and LCD display using the appropriate library functions.
Continuously read the humidity value from the DHT22 sensor using the appropriate library function.
Continuously read the time value from the DS1307 RTC sensor using the appropriate library function.
Display the humidity value on the LCD display using the appropriate library functions.
Display the time value on the OLED display using the appropriate library functions.
Here is some example code that demonstrates these steps:
author arvind patil 20m,arch 2023
*****************************************************************************/
#include <DHT.h>
#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <LiquidCrystal_I2C.h>
#include <RTClib.h>
#define DHTPIN 2 // DHT22 sensor pin
#define DHTTYPE DHT22 // DHT22 sensor type
DHT dht(DHTPIN, DHTTYPE);
RTC_DS1307 rtc;
Adafruit_SSD1306 display(128, 64, &Wire);
LiquidCrystal_I2C lcd(0x27, 16, 2); // Initialize with 16 columns and 2 rows
void setup() {
Serial.begin(9600);
dht.begin();
rtc.begin();
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
lcd.begin(20, 4); // Specify the number of columns and rows
lcd.backlight();
}
void loop() {
// Read humidity from DHT22 sensor
float humidity = dht.readHumidity();
// Read time from DS1307 RTC sensor
DateTime now = rtc.now();
// Display humidity on LCD display
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Humidity: ");
lcd.print(humidity);
lcd.print("%");
lcd.setCursor(0, 1);
lcd.print(" project by: ");
// lcd.print(humidity)
delay(500);
lcd.setCursor(0, 2);
lcd.print("arvind patil: ");
// lcd.print(humidity)
delay(500);
lcd.setCursor(0, 3);
// lcd.print(": ");
// lcd.print(humidity)lcd.setCursor(0, 2);
lcd.print("nandurbar India ");
// lcd.print(humidity)
delay(500);
// Display time on OLED display
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.print("Time:");
display.setCursor(0, 16);
display.print(now.hour(), DEC);
display.print(':');
display.print(now.minute(), DEC);
display.print(':');
display.print(now.second(), DEC);
display.display();
}