#include <Wire.h>. //code for OLED display
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
void setup() {
pinMode(6, OUTPUT);
Serial.begin(9600);
//This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
for (;;);
}
}
void loop() {
display.clearDisplay();
delay(2000);
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0, 10);
display.println("moisture");
display.setCursor(0, 30);
display.println("humidity");
display.setCursor(0, 50);
display.println("temperature");
display.display();
delay(500);
}