Header Ads

Header ADS

Room Temperature and Humidity Monitor Device using OLED and DHT Sensor | JLCPCB  







📌Only $2 for 5pcs 2 Layer & 4Layer PCBs: https://jlcpcb.com/cyt

The PCB board will be needed to make this circuit board like the picture above. I made my PCB board from http://www.jlcpcb.com. Gerber file is required to order on this website. If you want to get the Gerber file of this PCB, enter this link https://youtu.be/tpIZDV5NqpI. And if you want to design a PCB yourself, then go. at http://easyeda.com.

Hi, friends in this blog, I am going to share with you How to Make a Room Temperature monitor device using OLED Display, DHT11/DHT22 Sensor & Arduino programming.

Components:

1. 0.96inch OLED Display 1p

2.ATmega328p IC 1p

3.DHT 11 or DHT22 sensor 1p

4. 28pin IC base 1p

5.l7805 1p

6.power socket 1p

7.16MHz crystal 1p

80.1micro ferud, 50volt 1p

8.RED LED 1p

9.22pico ferud ceramic capacitor 2p

10. 10k ohm resistor 1p

11.1k ohm resistor 2p

12. F to M IC header

13. M to M IC header



Arduino Programming Code

_____________________________________________________________________________________________________________________________________________________________________


#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>

#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);

#define DHTPIN 2     // Digital pin connected to the DHT sensor

// Uncomment the type of sensor in use:
#define DHTTYPE    DHT11     // DHT 11
//#define DHTTYPE    DHT22     // DHT 22 (AM2302)
//#define DHTTYPE    DHT21     // DHT 21 (AM2301)

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(115200);

  dht.begin();

  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  delay(2000);
  display.clearDisplay();
  display.setTextColor(WHITE);
}

void loop() {
  delay(5000);

  //read temperature and humidity
  float t = dht.readTemperature();
  float h = dht.readHumidity();
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
  }

  //clear display
  display.clearDisplay();

  // display temperature
  display.setTextSize(1);
  display.setCursor(0,0);
  display.print("Temperature: ");
  display.setTextSize(2);
  display.setCursor(0,10);
  display.print(t);
  display.print(" ");
  display.setTextSize(1);
  display.cp437(true);
  display.write(167);
  display.setTextSize(2);
  display.print("C");
  
  // display humidity
  display.setTextSize(1);
  display.setCursor(0, 35);
  display.print("Humidity: ");
  display.setTextSize(2);
  display.setCursor(0, 45);
  display.print(h);
  display.print(" %"); 
  
  display.display(); 
}


Video:


2 comments:

  1. Informative one. This is cool tech device to measure temperature and humidity. Thanks for sharing with code..

    See this post also : Get more clients to your business

    ReplyDelete

Theme images by Bim. Powered by Blogger.