Home Automation

Enter Your Electronics & Design Project for a chance to win a $100 Shopping Cart!

Back to The Project14 homepage

Project14 Home
Monthly Themes
Monthly Theme Poll


This is a small Weather Station based on the ESP8266, and will only need a small spot on you study table or workbench .

Update 1 : Here is a quick looks at the circuit, and the components used

  • Adafruit HUZZAH ESP8266 Breakout
  • DHT22 temperature and Humidity sensor
  • 10K ohms resistor
  • SSD1306 OLED – I think I purchased this about a year ago, and finally have got around to using it.
  • Breadboard and wire for now, but as part of the final build we will add all these components to the 3D printed parts.


Update 2: 3D design and 3D printing

To put all these electronic components neatly together, the idea is to 3D print a case , which will make the OLED screen easily visible and give enough air to the DHT22 sensor so that we can capture the indoor temperature and humidity. The 3D printed components were designed in Fusion 360 and the STL files for the base and top lid are attached below. In my case I used 1.75 mm red PLA to print the STL files on a Flashforge Creator Pro.


Detecting Indoor temperature and Humidity using DHT22 sensor, and displaying it on OLED screen

Here is the code put together with the help of some Adafruit libraries, using the Arduino IDE

#include <Wire.h>  
#include "SSD1306.h" 
SSD1306  display(0x3c, 5, 4); // SDA on OLED connected to HUZZAH ESP8266 #4 and SCL to #5

/* DHT22 */
#include "DHT.h"
#define DHTPIN 0 // DHT pin connected to pin#0 on HUZZAH ESP8266   
#define DHTTYPE DHT22 
int localHum = 0;
int localTemp = 0;

void setup() 

void loop() 
  getDHT(); // getting value of temperature C and humidity %
  drawDHT(); // display temperature and humidity on the OLED
  delay (2000);

void getDHT()
  float tempIni = localTemp;
  float humIni = localHum;
  localTemp = dht.readTemperature(); // this is in centigrade 
  localHum = dht.readHumidity();
  if (isnan(localHum) || isnan(localTemp))   // read failed
    Serial.println("Failed to read from DHT sensor!");
    localTemp = tempIni;
    localHum = humIni;

void drawDHT() 
  int x=0;
  int y=0;
  display.drawString(0 + x, 5 + y, "Hum");
  display.drawString(43 + x, y, "INDOOR");

  String hum = String(localHum) + "%";
  display.drawString(0 + x, 15 + y, hum);
  int humWidth = display.getStringWidth(hum);

  display.drawString(95 + x, 5 + y, "Temp");

  String temp = String(localTemp) + "°C";
  display.drawString(70 + x, 15 + y, temp);
  int tempWidth = display.getStringWidth(temp);


Update 3: Adding the electronic components to the 3D printed parts

Now to add the electronic components to the 3D printed parts you will have to use a smaller beadboard as shown in the picture below, and also use bread-boarding wire cut to length as space it limited in the 3D printed base. In addition you will also have to solder breadboarding  wire to the 4 pins on the I2C OLED display. And a suggestion here, is to add the the DHT22 sensor to the mini breadboard after placing it in the 3D printed part using forceps, and then push the breadboard to the right of so that the DHT22 sensor just comes out half way through the 3D printed part.

And, you will also need a USB Micro-B breakout board, or you can cut the end of a USB cable and solder the +ve and -ve to the HUZZAH ESP8266 VBAT and GND pins.

In my case, as you see in the picture above, I have still FTDI serial cable still connected to the   HUZZAH ESP8266 , as I am still in the process of implementing the Arduino sketch for getting data from the Openweathermap.org API to show the weather forecast. Here is a picture showing the inside temperature and humidity based on the sketch above.




Update 4: Getting weather data from Openweathermaps

To get weather from the Openweathermaps.org you will have to create an account and generate an API key, and then upload the code from - https://github.com/ThingPulse/esp8266-weather-station-color  to the ESP8266. As part of the code don 't forget to update your API key for Openweathermap , your home WiFi network name and password. Here are the board setting to upload the ino file to the ESP8266. In my case, I also modified the code to add the indoor temperature and humidity from the DHT22 sensor.


Here is a picture showing the date and time, and as part of the code remember to update the time zone variable TZ

Showing the weather condition and temperature in your town/city, to get an accurate reading update your town/cities location id variable in the ino file.

This picture shows the Forecast for the next few days

Getting the indoor temperature from the DHT22 sensor


Here is a video demo of the Mini Weather station in a dark room ....