BizHostNC IT & Networking

Monitor your Home Lab Temperature & Humidity Environment with ESP8266 and DHT11 Sensor

Ever wanted to monitor ambient temperature and humidity in your home lab or server room, but didn’t want to spend money on something extravagant? Most guys who work with electronics already have these parts laying around whether in a kit, or just deals. Otherwise you can get these parts for under 10$ and put this simple piece of hardware anywhere you want to monitor temperature and humidity. The footprint of the hardware is quite small, and we have implemented ESP8266 deep sleep to reduce the amount of power usage as well. Our setup is monitoring the temperature in our home lab, which has quite a few electronics running and we like to know what the ambient is to ensure our GPU and CPU temps are stable. We also have this same setup running at multiple businesses on closed networks for their automation.

The code I am using is written in the Arduino IDE, so you will have to download it. The code is quite simple, it will read the data from the sensor; then send that data to a ThingSpeak channel. This will allow you to aggregate the data somewhere central, without fighting a bunch of local servers and code. It works great, and allows you to send your data and deep sleep for your required delay. We will add more technical data and information as this post matures.

You will need to have, or order the following parts:

It’s quite simple, wire up your ESP-8266 NodeMCU with 3v to the positive pin, Ground to the Negative (-) pin, and then your Sensor pin will go to D5 on your NodeMCU.

Then, you will need to open up your Arduino IDE and install the DHTesp Library. There will be two DHT libraries, but we want the one that has ESP8266 in the description. You may also need to add the ESP8266 to your board manager if you have not already, follow the instructions here: https://arduino-esp8266.readthedocs.io/en/latest/installing.html

Now that you have your sensor wired up, and your code in the Arduino IDE. You will need to fill in the settings (WiFi, and ThingSpeak). Sign up on thingspeak and create your channel, then add the API key to your code.

Once you are signed in, click on Channels > My Channels.

Then, you click on “New Channel”

Insert your information (Our code is setup as Temperature in Field 1, Humidity in 2)

Click on API Keys, and copy/paste your Write API key to your Arduino script.

 

When you are doing your upload, please make sure your deep sleep pin is disconnected. To enable the deep sleep mode, you will need to connect D0 to RST pin. It will be GPIO 16 (known as D0 on NodeMCU). You CANNOT upload your script to your ESP8266 with these pins connected, so simply remove for flashing then reconnect once it’s complete.

Now that everything is setup, you can 3D print a case to make it look pretty or just simply leave it how it is and stash it somewhere with a 5V power source. Mine is powered from a USB port on one of my towers, and I mounted it in a case from Thingiverse on the wall away from any of my PC fans. Then monitor your data!

 

Original Code we adapted from: https://github.com/squix78/esp8266-dht-thingspeak-logger

Top