Project tutorial
Weather station: Arduino, DHT11 sensor, Oled display

Weather station: Arduino, DHT11 sensor, Oled display © LGPL

How to make a mini weather station (temperature, humity monitor) using Arduino, DHT11 sensor and Oled display

  • 12,575 views
  • 10 comments
  • 10 respects

Components and supplies

Apps and online services

About this project

Using a display to view the temperature and humidity of your environment can be possible using the DHT11 sensor with the easy to use Arduino. For this project, we will be using the Oled I2C SSD1306 display module to display the temperature and humidity readings gathered from the environment using the DHT11 temperature and humidity sensor.

Schematic:

Video guide and demo:

I hope that you like this project. And subscribe my youtube channel.

Thanks for your watching!!!

Code

weather station codeC/C++
#include "DHT.h"
#define DHT11Pin 2
#define DHTType DHT11
//OLED
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

DHT HT(DHT11Pin,DHTType);
float humi;
float tempC;
float tempF;

//OLED define
#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);
  //For DHT11
  HT.begin();
  //For OLED I2C
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  display.display(); //Display logo
  delay(1000); 
  display.clearDisplay();
}

void loop() {
 delay(1000);
 humi = HT.readHumidity();
 tempC = HT.readTemperature();
 tempF = HT.readTemperature(true);

 Serial.print("Humidity:");
 Serial.print(humi,0);
 Serial.print("%");
 Serial.print(" Temperature:");
 Serial.print(tempC,1);
 Serial.print("C ~ ");
 Serial.print(tempF,1);
 Serial.println("F");

 display.clearDisplay();
 oledDisplayHeader();
 

 oledDisplay(3,5,28,humi,"%");
 oledDisplay(2,70,16,tempC,"C");
 oledDisplay(2,70,44,tempF,"F");
 
 display.display(); 
 
}
void oledDisplayHeader(){
 display.setTextSize(1);
 display.setTextColor(WHITE);
 display.setCursor(0, 0);
 display.print("Humidity");
 display.setCursor(60, 0);
 display.print("Temperature");
}
void oledDisplay(int size, int x,int y, float value, String unit){
 int charLen=12;
 int xo=x+charLen*3.2;
 int xunit=x+charLen*3.6;
 int xval = x; 
 display.setTextSize(size);
 display.setTextColor(WHITE);
 
 if (unit=="%"){
   display.setCursor(x, y);
   display.print(value,0);
   display.print(unit);
 } else {
   if (value>99){
    xval=x;
   } else {
    xval=x+charLen;
   }
   display.setCursor(xval, y);
   display.print(value,0);
   display.drawCircle(xo, y+2, 2, WHITE);  // print degree symbols (  )
   display.setCursor(xunit, y);
   display.print(unit);
 }
 
}

Schematics

Weather station schematic
weatherstation_NLzOTuPPyX.fzz

Comments

Similar projects you might like

DHT11 Humidity + Temperature Sensor with 16x2 LCD display

Project showcase by onatto22

  • 53,183 views
  • 13 comments
  • 58 respects

ThingSpeak Arduino Weather Station

Project tutorial by neverofftheinternet

  • 11,022 views
  • 6 comments
  • 12 respects

Arduino Easy Weather Station With BME280 Sensor

Project tutorial by Nick Koumaris

  • 35,116 views
  • 1 comment
  • 48 respects

eNVIRO: 7" Touch Panel Weather Station with Remote Sensor

Project in progress by antiElectron

  • 7,974 views
  • 4 comments
  • 25 respects

Using DHT11

by arcaegecengiz

  • 119,477 views
  • 35 comments
  • 61 respects
Add projectSign up / Login