Header Ads Widget

Arduino Humidity and Temperature monitor | OLED

 

 Arduino Humidity and Temperature monitor | OLED

Materials-:

  • Arduino UNO
  • DHT11 Temperature and Humidity Sensor
  • OLED Display
  • Breadboard
  • Jumpers
Circuit diagram-:

Code-:
//Sanuka senumitha//https://www.youtube.com/channel/UCbezY8Lqr7Foo1-eLu09SMA/videos#include "DHT.h"  //Download Library#include "U8glib.h"  //Download LibraryU8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE|U8G_I2C_OPT_DEV_0);
#define DHTPIN 2     // what pin we're connected to

#define DHTTYPE DHT11   // DHT 11 
DHT dht(DHTPIN, DHTTYPE, 6);
char str[10];
void drawTest(void) {  u8g.setFont(u8g_font_unifont);  u8g.drawStr( 0, 20, "Sanuka Senumitha");}
void setup() {  Serial.begin(9600);   Serial.println("DHTxx test!");   dht.begin();  u8g.firstPage();    do {    drawTest();  } while( u8g.nextPage() );}
void loop() {  delay(2000);  float h = dht.readHumidity();  // Read temperature as Celsius  float t = dht.readTemperature();  // Read temperature as Fahrenheit  float f = dht.readTemperature(true);    // Check if any reads failed and exit early (to try again).  if (isnan(h) || isnan(t) || isnan(f)) {    Serial.println("Failed to read from DHT sensor!");    return;  }
  float hi = dht.computeHeatIndex(f, h);
  Serial.print("Humidity: ");   Serial.print(h);  Serial.print(" %\t");    Serial.print("Temperature: ");   Serial.print(t);  Serial.print(" *C ");  Serial.print(f);  Serial.print(" *F\t");    Serial.print("Heat index: ");  Serial.print(hi);  Serial.println(" *F");    // picture loop  u8g.firstPage();    do {    u8g.setFont(u8g_font_helvB08);        u8g.drawStr( 0, 15, "Humidity:");    u8g.drawStr( 80, 15, dtostrf(h, 5, 2, str));    u8g.drawStr( 120, 15, "%");        u8g.drawStr( 0, 30, "Temperature:");    u8g.drawStr( 80, 30, dtostrf(t, 5, 2, str));    u8g.drawStr( 120, 30, "\260C");        u8g.drawStr( 80, 45, dtostrf(f, 5, 2, str));    u8g.drawStr( 120, 45, "\260F");        u8g.drawStr( 0, 60, "Heat index:");    u8g.drawStr( 80, 60, dtostrf(hi, 5, 2, str));    u8g.drawStr( 120, 60, "\260F");      } while( u8g.nextPage() );}


Post a Comment

0 Comments