Introduction: Temperature and Humidity Internet Logger With Display Using ESP8266
I wanted to share a small project that I think you will like. It is a small, durable internet enabled temperature and humidity internet logger with display. This logs to emoncms.org and optionally, either locally to a Raspberry PI or your own emoncms server. It features the LOLIN (formerly WEMOS) D1 Mini which incorporates the ESP8266 core. Temperature and Humidity sensor is the LOLIN DHT 3.0 I2C sensor. The software is Arduino and naturally, open source. I've now built 7 of these and a mate of mine wants 3 more.
I've encased it in a "Systema" 200ml plastic case. These are available in Australia for ~$2. Total cost of the components, including a USB micro cable is < $AU30 so you should be able to build this in the US for ~$20
The complete component list is
- LOLIN DI Mini V3.1.0
- LOLIN DHT Shield 3.0 temperature and humidity
- TFT 1.4 Shield V1.0.0 for WeMos D1
- TFT I2C Connector Shield V1.1.0 for LOLIN (WEMOS) D1 mini
- TFT Cable 10P 200mm 20cm for WEMOS SH1.0 10P double head cable
- I2C Cable 100mm 10cm for LOLIN (WEMOS) SH1.0 4P double head cable
- Plastic case - SYSTEMA 200ml - in Australia Coles/Woolies/KMart
- USB Micro to USB-A power cable
All the active components can be bought on the LOLIN store on AliExpress.
Tools and miscellaneous hardware
- Soldering iron. You will need to solder the headers on the shields
- 1.5mm cap head bolts ~ 1cm long and driver to suit
- 1.5mm drill or reamer for bolt holes
- Round file or Dremel to cut slot for cables
Step 1: Assembly
Assembly is straight forward. There are 2 shields to stack however I prefer to have the D1 shield as the top board as the exit path for the USB cable is straighter and easier to organise once you clip the lid on.
The D1 arrives with 3 header combinations
- Socket and long pins
- Socket and short pins
- Short pin only
Use the long socket/long pin combination for the DI. Ensure you are soldering it with the right orientation. Here is a small jig I use to get the pins aligned straight for soldering.
Using a breadboard, position two rows of Short Pin headers in rows B & I longer pins down. They will go flush with the surface. Then position two rows of Socket and short pins in rows A & J outside of the short pin headers.
You can then place the long pin headers on the short pins in the board and then position the D1 ready for soldering. Note: The D1 is upside down at this point. The USB socket and antenna trace are under the board. Solder the pins to the board. Try not to use too much solder as excess will wick down under the D1 and may travel down to the socket portion of the board. You might ask why I didn't just use the short pin headers on the D1? I have other plans including a Real Time Clock and SD card for times where WiFi access isn't possible so I have provided for other shields to be stacked if required.
Next step is to solder the connector board. Remove the socket and pin headers from rows A & J and slip them on the now soldered D1 pins. You can now slip the connector shield on these pins. Do not push the sockets completely down, just rest them on top. Reason? If you use too much solder, it will "wick" down and your connector will be permanently soldered to the D1.
Ensure that the connector is correctly oriented. The connector shield should also be "upside down" at this point. The pinouts are marked on each board. Ensure that they match i.e. the Tx Pin on the D1 is directly below the Tx pin on the Connector board etc. Check again and solder the connector board to its header.
Soldering is now completed. Remove the board from the jig if you are using it. Clip them together, again checking the orientation. Unlike the Arduino Uno boards, its possible to have one board 180 degrees out. At this point you can connect the I2C cable from the connector board to the DHT and the 10pin TFT cable to the TFT. The internal pins are quite small so check the orientation before insertion.
Connect a USB micro cable to the D1 and the backlight of the TFT should light. You are now ready to load the Arduino sketch.
Step 2: Loading the Firmware
Load the latest Arduino IDE. I had 1.8.5 running at the time of building this project.
The IDE needs to be configures to compile the sketch for the WEMOS (ESP8266). To do this you need start the IDE and go to File / Preferences and then click the icon to the right of "Additional Boards Managers URLS". An editor will be displayed. Paste the following
into the editor and click OK and then OK to close the preferences editor. You must then close the IDE and reopen it. The Arduino IDE will then connect and download the required "tool chain" and libraries to build and compile sketches for the ESP8266 which the D1 is based on.
You will also need the AdaFruit libraries for the TFT screen. These can be obtained from
github.com/adafruit/Adafruit-ST7735-Library & github.com/adafruit/Adafruit-GFX-Library
unzipped and saved in your libraries folder in your Arduino projects folder. Note: the Github downloads often append "-master" to the folder so you may need to rename them.
You also need the LOLIN/WEMOS DHT 3.0 library from
Download the IoTTemp_basic.ino file and place it in an Arduino projects folder called "IOTTemp_basic".
Open the sketch in the IDE and go to Tools / Board and select the "Boards Manager". In "filter your search" just put "D1" and you should see "esp8266 by ESP8266 Community" Hit "More Info" and you should be able to select the latest version and "Install". The IDE will then commence to download the tool chain and associated libraries.
Once this has completed, plug your IotTemp into your computer and after detection, select the port the device is installed on in "tools/port". You are now ready to compile and load.
In the top of the sketch, you need to configure some variables to suit your local environment
const char* ssid = "<My SSID>"; // Your local WiFi SSID
const char* password = "<My WiFi Password>"; // Password for local node
const char* host = "emoncms.org"; // base URL for EMONCMS logging. Note NO "http://"<br>
const char* APIKEY = "<your API Key"; // Write API key from emonCMS
const char* nodeName = "Kitchen"; // Descriptive name for your node
Hit the "tick" icon to check the code and if there are no significant errors you should be OK to upload the code to the D1. Once this has completed, it takes a minute or two, you should now see the TFT light up with the "TMP" and "R/H" (Relative Humidity) values.
As we haven't configured the EMONCMS account etc, you will see "Connection failed" with your host name.
The sketch is also has a basic serial monitor. Connect using the Arduino serial monitor, Putty or any other serial comms program for further information on what is going on inside the IoT Temp.
I tinker with the code so you can find my latest code at
Step 3: Final Assembly
You are now ready to complete the assembly. This involves mounting the components into the box.
Start by mounting the TFT on the inside of the lid. Disconnect the D1 from the power and then disconnect the TFT from the connector board. Offer the TFT up to the lid trying to position the TFT as close to the top edge of the lid as possible. This will give you better clearance for the D1/Connector board. I use a sharp reamer to push a small mark in the plastic, remove the TFT and then ream a small hole. The mounting holes for the TFT are quite small at 1.5mm. I have a collection of cap head bolts which fit but no nuts to suit. I push the cap head from the front, screwing them through and plastic and then I simply use low temperature hot glue to secure the TFT to the bolts.
Mount the DHT sensor to the outside of the lid. To separate the sensor from the shield (the "shield" mounts aren't used), turn the DHT upside down and score the isthmus (the thin bit) with a hobby knife. The sensor will then snap free of the shield.
Almost the last step is to cut a relief slot in the bottom edge of the lid and the base to accommodate the USB cable and connection to the DHT. I use a Dremel but it can easily go a bit wild so take your time. The SystemA box has a silicon seal in the lid which you shouldn't need to cut.
Assemble the unit in the box. A touch of low temp hot glue under the connector board helps to locate it in the box. Run the USB and DHT cables out the slot and put a dab of hot glue over the top of the two cables.
Secure the DHT to the outside of the box with a short 1.5 mm bolt. Use a little hot glue under it if your are want - I don't bother.
Connect your IOT Temp to 5V power and admire your work.