Environmental monitoring on the cheap with the ESP8266 (temperature, humidity, etc.)

Curious about logging temperature, humidity, etc. or the ESP8266 microcontroller platform?  Looking to come up with your own environmental monitoring platform?  In this article I share some of the fun projects I’ve created to do just this.  Best of all it’s cheap and you can do this at your home/location without deep development experience (and I share code you can re-use to get started).

I’ve been meaning to setup some true DIY home IoT (Internet of Things) projects for a while now (read years). This summer during vacation I made a bit of time to try out the ESP8266 microcontroller platform.

The neat thing about the ESP8266 platform is that it has a native WiFi chipset, and as of about 18 months ago is supported by the Arduino IDE. All this makes programming and connectivity very simple.  They’re also available for only a few dollars each, which is a big plus as this is really just a tinkering project.  Over this last summer I ended up purchasing a total of 12 of these (plus an Arduino Uno R3 and several Raspberry Pis – but those are subject for future articles)

Some information on the platform itself.  I’ve tried a few different models and (for now) have mostly standardized on the NodeMCU v.2 as a development board, you can get them on Amazon here (2 for $13 as of writing).  My reasoning for picking this board is that it’s got the integrated USB to Serial converter, lots of digital inputs and importantly is narrow enough to fit on a standard breadboard with enough space to connect it.  You can find more details on this site comparing ESP8266 based boards, but as you can see below the spacing makes a big difference.

ESP8266 v2 versus v3
ESP8266 v3 (left) versus v2 (right) – big difference on the breadboard!

Okay, so what did I make with these things and how can I get a cheap environmental monitoring system out of them?

While I made several “models” with alternating sensors (photo resistors, ultrasonic distance sensors, etc.) what I made sure to include on every one of my ESP8266 based projects was either a DHT22 or DHT11.  What this meant is that everywhere I put one of these things I could get data on the temperature and humidity.

The DHTs generally require a small resistor wired between the voltage and digital input, however you can buy modules that already have the resistor on a small circuit so they’re ready to connect directly to your ESP.  Here is an example you can get on Amazon.  Additionally, I recommend the DHT22 over the DHT11 as they are much more accurate, but they’re also more expensive.

There are plenty of articles out there that will show you how to connect up a DHT to an ESP 8266 (which is not what I’m going to go into detail on in this article).  I’ve shared some code you can reuse on my GitHub repository here if you need something to get started: ESP8266 Environmental Monitor.  With that code (INO, PHP and MySQL) you can take the temp/humidity data and log it into a database, and from there all kinds of fun projects can be made because…data!

For example, I have a fun dashboard running on a old tablet that is mounted on the wall:

Environmental Monitoring Dashboard
Environmental Monitoring Dashboard

I also leveraged Fusion Charts so I could graph the temperature and humidity over time:

ESP8266 Temp and Humidity on my front Porch graphed
ESP8266 Temp and Humidity on my front Porch over the last 7 days graphed

(If you want see some of the code I used for these examples be sure to visit my WeatherUnderground PHP MySQL and FusionCharts Multiaxis PHP MySQL code repositories.

A few more pictures from some of the projects here:

I hope this inspires you to learn and try something new!


Technology, science, building things and experiencing the world. What more could anyone ask for?

Leave a Reply

Notify of