Hello,
This is my first time posting on this forum and I had a question regarding displaying temperature and humedity into my SSD1306 OLED 128x32 Screen. I don't have no experience programming, since I'm doing my first Arduino project for a college class. The code I used is mostly compiled from YouTube videos I seen and adjust toward my Arduino. Hopefully, you guys can assist for a fellow beginner on his project. It include the information of my name, but not the temperature and humidity.
Here's my code showing my code I have so far:
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <dht.h>
dht DHT;
#define DHT11_PIN 2
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup() {
Serial.begin(9600);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
delay(600);
display.clearDisplay();
//OLED Display
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(7, 7);
// Display static text
display.println("ARDUINO");
display.println("SMART");
display.println("WATCH");
display.display();
delay(600);
display.println("(C)2019 by");
display.println("Alexander Gomez");
display.display();
delay(600);
display.begin(128, 64);
}
void loop()
{
int chk = DHT.read11(DHT11_PIN);
display.setCursor(7,7);
display.println("Temp: ");
display.println(DHT.temperature);
display.println((char)223);
display.println("C");
display.setCursor(7,7);
display.println("Humidity: ");
display.println(DHT.humidity);
display.println("%");
delay(1000);
}