I have always wanted a weather station, and with them costing about $150ish for one with decent quality, that you could possibly connect to a network with the aid of a 400MHz receiver, they are a little too expensive and the hunt was on to find something a bit cheaper!
I picked up a couple of ESP8266 Arduino clones on eBay recently, along with some DHT22 Temperature and humidity sensors.
They come as a kit, and only need a small amount of soldering to bring it all together, perfect for those little projects!

Even better! These little guys will send information directly to InfluxDB (over UDP) allowing you to graph it all out wit Grafana!

First step is to solder them all up, and connect the 2 parts together

You will need to grab the Sensor & DHT Libraries for your sketch to compile.

Found Here: Adafruit_DHT_Unified-master Adafruit_Sensor-master
Ensure that your sensor is on PIN4 (even though it says 2 in the code). Or mess around until you find the right pin.
The Arduino Sketch is as follows:

#include <ESP8266WiFi.h>
#include <WiFiUDP.h>
#include "DHT.h"

#define DHTPIN 2
#define DHTTYPE DHT22
// the IP address of your InfluxDB host
byte host[] = {192, 168, 0, 0};
// the port that the InfluxDB UDP plugin is listening on
int port = 8888;
WiFiUDP udp;
const char* ssid = "YOUR WIFI NAME";
const char* password = "YOUR WIFI PASSWORD";
void setup() {
 // We start by connecting to a WiFi network
 Serial.print("Connecting to ");
 WiFi.begin(ssid, password);
 while (WiFi.status() != WL_CONNECTED) {
 Serial.println("WiFi connected"); 
 Serial.println("IP address: ");
int value = 0;
void loop() {
 String line, temperature, humidity;
 // wait 10 seconds
 // get the current temperature from the sensor, to 2 decimal places
 // Reading temperature or humidity takes about 250 milliseconds!
 // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
 float h = dht.readHumidity();
 // Read temperature as Celsius (the default)
 float t = dht.readTemperature();
 temperature = t;
 humidity = h;
 // concatenate the temperature into the line protocol
 line = String("temperature,host=NAME_OF_PROBE_HERE value=" + temperature);
 // send the packet
 Serial.println("Sending UDP packet...");
 udp.beginPacket(host, port);
 line = String("humidity,host=NAME_OF_PROBE_HEREvalue=" + humidity);
 // send the packet
 Serial.println("Sending UDP packet...");
 udp.beginPacket(host, port);



DIY Stevenson screen to protect the sensor

Head down to your local K-Mart, or cheap home wares retailer and pickup some small bowls.
The ones you see here came in a 6 pack for $2.

Drill out 2 or more bowls right in the center.
Note! Don’s cut a hole in the top one!
Stack them all together and drill 3 holes all the way through all of the bowls

Add some threaded rod and some nuts to sandwhich and control the bowls height off eachother.

Keep going!

Yay! Now add the last screws at the top and check they are even distance apart from one another.
(Yes I know they are not the same distance apart in this photo…..)

At this stage, you have no way of mounting it though!
Lets add a rusty piece of metal to the top as a bracket.

Hrrm…. but i want this one to be magnetic……
Grab some small bolts.

Attach one of those hard drive magnets you have lying around the shed.

Cut off all of the loose thread and make it look pretty! (As pretty as 3 stacked bowls can look like!)

Here it is the USB cable that I am going to extend. This sensor, looks butt ugly, and needs to be positioned out of sight.
By adding a few meters of extension to the USB Cable, we have freedom on where we can hide it!

USB Cable soldered.

The other end, looking up the bottom of the bowl.
A small cable tie to hold it all into place.

You can see that the magnet is super useful in allowing you to attach the contraption to just about anything metallic.

Hrrm… is this IP66 rated?
Need to waterproof that….

Now fire up Grafana, and ensure that you have added the Temperature data source that should have been created when you started logging.
You could modify the sketch to input into any database you like!

Setup your Query, and which way you like……. and you can end up with something like this!

That’s it!

Yes, its VERY humid here tonight, everything is wet outside.
Now you can see that there are 2 sensors reporting, and being show in the graph. In my case, the outside temperature and my shed temperature.
its interesting to see the difference a non insulated shed can make to the figures!
The sensor in the shed, is a little less elegantly constructed…….


Thanks to RKI for the know how, in how to do all this! 🙂

ESP8266 Wifi Weather station + DIY Stevenson screen
Tagged on:                 

2 thoughts on “ESP8266 Wifi Weather station + DIY Stevenson screen

  • July 29, 2018 at 7:53 pm

    After how many months did the DHT give up the will to live? A friend of mine tried a similar trick but his sensors would corrode away in an instant.

    • August 5, 2018 at 10:13 am

      Mine are still going strong!
      1.5 years later.
      We are not next to the ocean, but not too far away either and have had no issues with Corrosion.
      Little spider made a home out of it, but that’s about it!


Leave a Reply

Your email address will not be published. Required fields are marked *