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 
DHT dht(DHTPIN, DHTTYPE);
int localHum = 0;
int localTemp = 0;


void setup() 
{
  Serial.begin(115200);
  display.init(); 
  display.flipScreenVertically();
}


void loop() 
{
  getDHT(); // getting value of temperature C and humidity %
  display.clear();
  drawDHT(); // display temperature and humidity on the OLED
  display.display();
  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;
    return;
  }
}


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


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


  display.setFont(ArialMT_Plain_10);
  display.setTextAlignment(TEXT_ALIGN_LEFT);
  display.drawString(95 + x, 5 + y, "Temp");


  display.setFont(ArialMT_Plain_24);
  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.

 

 

 

This project is still a work in progress.. Stay tuned for more updates ...