The goal of this project is to make a temperature/humidity monitor that wirelessly logs the temperature and humidity to a remote server. We will use an Arduino Uno (or clone), a DHT11, an ESP8266, and ThingSpeak.com for this project. This is a great project to start using the ESP8266 for some basic data logging so let's get started!

Step 1: Gather Your Supplies

For this project I used an Arduino Uno clone but any Arduino board or clone will work.

Step 2: Create a ThingSpeak Channel

In order to log your temperature and humidity measurements online you need to have a website or webservice that can accept GET http commands. In this Instructable I am using ThingSpeak but there are other, similar services out there so feel free to use something else to log your data. To create a ThingSpeak account click here.

If you use ThingSpeak you will need to make a channel with two fields, one for temperature and one for humidity. They have a number of options for displaying data in graphs so I encourage you to explore these options and see what you like best. I settled on two simple line graphs with a 10 point average to smooth out occasional blips in the data. ThingSpeak will give you a Key for your channel that you will need to put into the code so that your channel will accept your data.

Step 3: Wiring

First we should cover some basics of the ESP8266 and the DHT11. Then we will move on to wiring them to the Uno.

The image above shows the front of the ESP8266 with the 8 broken out pins labeled. The ESP8266 runs at 3.3 V so make sure you connect the Vcc pin to the 3.3 V pin on the Uno. This also means that you will need to use a logic level shifter or make a voltage divider for the serial connection from the arduino board to the ESP8266 or you risk ruining it. If you don't want to buy a logic level shifter then you will need to make a voltage divider which you can do using two resistors. Sparkfun has a great tutorial on this so you can see how they build theirs and calculate which value resistors you will need to use. I used a 220 Ohm resistor and a 470 Ohm resistor for mine which got me close enough to 3.3 V. Since the ESP8266 outputs 3.3 V and the Arduino boards can take that voltage there is no need to do anything to the serial line from the ESP8266 to the Arduino.

The DHT11 spec is only +/- 5% humidity and 2 degrees Celsius so it is not a super accurate sensor. It's also only good for temperatures above freezing. The DHT22 is a bit more accurate so if that's important to you opt for it instead. Both sensors work with voltages between 3.3 - 5 V. The signal pin will need to be connected to a pull-up resistor, which I used a 4.7 kohm resistor for.

The Fritzing diagram above shows the wiring. For ease of use all connections to 5 V or 3.3 V are red and all connections to ground are blue. The wiring connections are as follows:

  • Uno | ESP8266
  • RXD | TXD
  • TXD | RXD (through voltage divider)
  • 3.3 V | Vcc, CH_PD, Reset
  • GND | GND
  • Uno | DHT11
  • 5 V | Vcc
  • GND | GND
  • D7 | Signal (connect to Vcc via pull-up resistor)

Step 4: Code

Before you can use my code you will need to download and install the DHT library from Adafruit. They have a description of how to install and use their library and a link to their GitHub repository. Their library comes with other features such as a heat index calculator which I don't show here but feel free to log that as well if you're interested in it!

The baud for the ESP8266 is set near the top of the .ino file. The version of the ESP8266 I bought comes in either 9600 baud or 115200 baud. Both of the chips I have ordered are set to 115200 baud but if you're trying to use this code and it doesn't seem to work try changing the baud to 9600 as your first step in debugging.

There are several places in code with values in '<' '>' brackets. Those are places where you will need to paste in your own values to make this work. This includes the name and password for your WiFi network and the Key for your ThingSpeak channel. There is code in place to use a red and green LED for debugging and status monitoring but those are not shown in the wiring diagrams. If you'd like to have a quick way to visibly see if things are running smoothly you can wire up a couple of LEDs.

A final thing that tripped me up for a while is that the serial pins CANNOT both be connected between the ESP8266 and the Uno while uploading the sketch. The sketch will fail to upload if they are connected so you must first disconnect one or both serial pins on either the Uno or the ESP8266 and then upload the sketch.

The code is attached to this step and can also be found on my GitHub page here.

Step 5: Use Your Sensor!

Congratulations, you've created your very own wireless temperature and humidity logger! I usually leave mine in my basement so that I can monitor the temperature, and more importantly, the humidity since it's unfinished and I don't want my things getting moldy from too much humidity. I have also mounted it to a piece of cardboard to make it easy to move around. I hope you found this helpful and had fun making it! In the future I plan to program the ESP8266 directly and bypass the Arduino altogether so look for that to come soon.

<p>How to convert fahrenheit to celsius?</p>
<p>Can you plz look at this</p><p><a href="https://www.instructables.com/community/security-system-not-responding-after-combinin-ultr/" rel="nofollow">https://www.instructables.com/community/security-s...</a></p><p>small help thanks</p>
Here is the current setup.
I first got only AT response. Nothing else. The I put 3 AA rechargeable batteries to feed power. That helped and now the system is working great! I changed the frequency to 600000 ms. Otherwise my phone freezes when trying to load Thingspeak charts and they are too heavy. I plan to get readings around my house to see if there is any risk with moist. Thank you so much!
<p>GETTING ERRORS. PLEASE HELP...</p><p>F:\TempHumidThingSpeak-master (1)\TempHumidThingSpeak-master\TempHumidThingSpeakPublic\TempHumidThingSpeakPublic.ino: In function 'void setup()':</p><p>F:\TempHumidThingSpeak-master (1)\TempHumidThingSpeak-master\TempHumidThingSpeakPublic\TempHumidThingSpeakPublic.ino:33:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]</p><p> if(Serial.find(&quot;OK&quot;)){</p><p> ^</p><p>F:\TempHumidThingSpeak-master (1)\TempHumidThingSpeak-master\TempHumidThingSpeakPublic\TempHumidThingSpeakPublic.ino: In function 'bool updateTemp(String, String)':</p><p>F:\TempHumidThingSpeak-master (1)\TempHumidThingSpeak-master\TempHumidThingSpeakPublic\TempHumidThingSpeakPublic.ino:85:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]</p><p> if(Serial.find(&quot;Error&quot;)){</p><p> ^</p><p>F:\TempHumidThingSpeak-master (1)\TempHumidThingSpeak-master\TempHumidThingSpeakPublic\TempHumidThingSpeakPublic.ino:104:21: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]</p><p> if(Serial.find(&quot;&gt;&quot;)){</p><p> ^</p><p>F:\TempHumidThingSpeak-master (1)\TempHumidThingSpeak-master\TempHumidThingSpeakPublic\TempHumidThingSpeakPublic.ino:111:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]</p><p> if(Serial.find(&quot;OK&quot;)){</p><p> ^</p><p>F:\TempHumidThingSpeak-master (1)\TempHumidThingSpeak-master\TempHumidThingSpeakPublic\TempHumidThingSpeakPublic.ino: In function 'boolean connectWiFi()':</p><p>F:\TempHumidThingSpeak-master (1)\TempHumidThingSpeak-master\TempHumidThingSpeakPublic\TempHumidThingSpeakPublic.ino:136:22: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]</p><p> if(Serial.find(&quot;OK&quot;)){</p><p> ^</p>
<p>These look like compiler issues and look like they're only warnings so the program should still run and compile. Are you able to compile the code and upload it to the board still? I did some googling on that specific warning and it looks like an issue using strings instead of const char*. I didn't see these issues when I was using this though.</p>
<p>Thanks for the wonderful project</p><p>I am building this in a couple of day.<br>2 questions, Can be Also use BMP180 sensor and post its reading too ?</p><p>and I get error while compiling as</p><p>Arduino: 1.8.0 (Windows 7), Board: &quot;Arduino/Genuino Uno&quot;</p><p>temp-thing:23: error: 'DHT' does not name a type</p><p> DHT dht(DHTPIN, DHTTYPE);</p><p>I'll be most probably hooking up my Arduino Nano instead of UNO.</p>
<p>Hi ghpk, did you download and install the DHT library from Adafruit? It sounds like the library isn't being found. You can use any sensor you want for the temperature detection but you will need to either write the code to interface with it or find a library online. Good luck with this.</p>
<p>Hi, tcodd86, sorry to use this name, I will be very grateful if you can help me out, I'm Dan, I am trying to do the same project for my final year could you guide me through some steps? I got the code from your github site and some issues are coming up, on compiling errors, and some steps showing errors on some lines which I'm trying to figure out and following your steps, but will need talking to your for help to understand mor,</p><p>Step 1, all the light are showing but on this line bool connected = connectWiFi(); see below:</p><p>if(Serial.find(&quot;OK&quot;)){<br> //connection to wifi netowork<br> bool connected = connectWiFi();<br> if(!connected){<br> failure, need to check your values and try again<br> Error();<br> }<br> }<br> else{<br> <br> Error();<br> <br> }<br> <br> //initalize DHT11 sensor<br> dht11.begin();</p>
<p>Cảm ơn bạn nhiều, một dự &aacute;n rất hay :D</p>
<p>kindly guide me how to setup thingspeak channel.i havemade a channel but still confused about para meters.like what should be my url, what is my channel key etc</p>
<p>Thanks for this! Well done, but if its only about temperature I would definitely go with DS18B20 sensor because of the power consumption and no measurements delay. The DS18B20 consume less than 1 uA (~700nA) which is almost zero, and also gives the possibility to take advantage from PARASITE MODE and use only 2 wires instead of 3, by powering the sensor from the data line. From my experience DHT11 has a big downside in outdoors, can't resist in high moisture.</p><p><a href="http://www.geekstips.com/arduino/arduino-temperature-sensor-tutorial-dht22-vs-ds18b20" rel="nofollow">DS18B20 1 Wire temperature sensor</a></p><p><a href="http://www.geekstips.com/arduino/arduino-temperature-sensor-tutorial-dht22-vs-ds18b20" rel="nofollow">DHT22 Temperature and Humidty</a></p><p><a href="http://www.geekstips.com/arduino/esp8266-01-wifi-module-for-arduino-review-and-tutorial" rel="nofollow">ESP8266 Module tutorial</a></p>
<p>hi. very cool system! congrats!</p><p>i am planning to use it for my little greenhouse.</p><p>could you tell me please, i want to add this a soil humidity sensor. which changes should we made on code, if you are not too busy?</p><p>my tomatoes are dying:)</p>
<p>Good Evening, i haven't been able to get this to work. after uploading, i open the monitor, monitor will print &quot;AT&quot; then nothing, SSID and pw is correct my baud seems to be 9600, is it suppose to show an error or if successful print the AT commands?</p><p>How would i learn more about Serial.find and/or bool connected = connectWiFi();</p><p>I will keep pursuing, just thought you could point me in the right direction, Thanks</p>
<p>Thanks for your tutorial. I need your help.</p><p>I used this code and it didn't work. I connected the ESP8266 module to TR3 and RX3 (it didn't work) and I also connected it to TX0 and RX0 (Arduino IDE stopped and it didn't upload the code).</p>
<p>The ESP8266 needs to be connected to the TX0 and RX0 pins. However, as you noticed, you cannot upload code to the Arduino while it is connected to those pins. To get around this what I did was I disconnected either the TX0 or RX0 pins while uploading the code. Then, after uploading was done, I hooked the TX0 and RX0 pins back up and restarted the Arduino.</p>
<p>Thank you. I also tried this and it didn't work. I noticed that my ESP8266 is defective, because it never responds, even with a FTDI programmer.</p><p>My ESP8266 module always stops when i'm trying to put any code.</p>
<p>Hello, thank you for thiis tuto.. can you please tell me what is exactly the problem here. it won't to send the 2 fields</p><p>thank you</p>
<p>It looks like it's not getting the expected response from your wireless router. Make sure your password is entered correctly and that the BAUD rate is set correctly for your device. Some are 9600 and some are 115200.</p>
<p>why am i getting error when i compile a cobe</p>
<p>Sorry for the delay in getting back to you. Looking at that error message I'm wondering if your install of the DHT package from Adafruit worked. I would try removing any DHT files and trying the install process from Adafruit again. Let me know if you get it working.</p>
<p>Thanks ! Works perfectly at the first try</p>
<p>Congratulations! It's pretty exciting when you first see it updating on Thingspeak. This was my first IoT project and I still have it running.</p>
<p>i finally made it, after flashing new esp8266 firmware, modifying to include industrial flow meter reading, and adding thinghttp action to send email through Pushbox to me at defined values.</p><p>but after almost a week of learning - this is my FIRST touch in arduino - i still have the same annoying problem:</p><p>whenever the esp responds well for the setup procedure (AT --&gt; OK) it continues even for 24h. </p><p>but most of the time i unplug the board from power, or upload a corrected sketch (of course with the rx/tx pins dettached until &quot;upload finish&quot;) i have to press several times on the reset button until the esp responds to the AT command. i even added 2 seconds delay between void setup to the AT command to have the esp &quot;warm up&quot; a little but it didnt help.</p><p>sometimes it takes 2 reset clicks and sometimes 5 or more.</p><p>is it something with the insufficient current from the uno board <strong>Disembodied</strong> mentioned before? </p><p>but </p>
<p>can you please send me the code </p><p>my SSID is Mssa3</p><p>and the password is Mssa2014 </p><p>I want to know how to write the GET String </p>
<p>Congratulations! This project is a pretty heavy lift for a first Arduino project. As for your problem I'm not sure why that is. I had to experiment with different delay values but it sounds like you've already done that. Otherwise I have read on different forums that some ESP units can be a little flaky sometimes so it could just be that it will take a few resets to run, I don't know. I guess it could be insufficient current as the ESP unit is trying to connect to the wifi so if you have a 3.3V power supply handy try powering it separately and see if that fixes it. If it does be sure to reply in the comments so that others can see how you fixed it.</p>
<p>I am facing issues getting response from ESP8266 from Arduino IDE. <br><br>Here are the details of my connection;<br><br>1. I am connecting Arduino(Rx-Tx) to ESP(Tx-Rx) respectively. <br>2. I am using voltage divider to get 3.3V across the ESP RX connection from 5V arduino TX. <br>3.<br> I have seen some forums stating to connect Rx-Rx and Tx-Tx to get the <br>response from ESP when uploading a &quot;BareMinimum&quot; sketch to arduino. I <br>tried this and i got the response. But I feel this is not the way to <br>communicate when you are using ESP as a host. It has to be Rx-Tx <br>connection. <br>4. I am using version ESP8266-01 version. Is this version not compatible?<br>5. Do i need to flash it to the latest firmware?<br>6. ESP8266 blue led is blinking while uploading the code.So I think the wifi module isn't bricked yet. Even red LED blinks. <br><br>I need some guidance what are the other options i need to check for this to work. Let me know if you need any more details</p>
<p>Hi Bhanu Kishan, sorry for the delay getting to this. You need to disconnect the serial lines between the ESP8266 and the Arduino when uploading the sketch to the Arduino. I usually just disconnect one of them while uploading and then reconnect it when the Arduino IDE says upload completed. I also used the ESP8266-01 so I don't think that's the issue. I usually see the blue light on the ESP8266 after the upload is complete and the code is running though only when it is receiving instructions from the Arduino. Let me know if any of that helps or if you are still having problems.</p>
<p>Yes, i always disconnect serial pins when I upload the file. But i didn't get any response so far from ESP8266. I used the same connections as you mentioned in the sketch.</p>
<p>Hi, </p><p>I have had success with this on myhome network and connecting hotspot to a friends iphone 4 though when trying to connect to my schools network, or hotspot to my iphone 6 it will not send data to thingspeak. It appears to be doing so in the serial though nothing is happening on thingspeak. Any ideas? </p><p>I can send data via my browser to my channel by typing in the url. But not via the esp8266 / uno.</p><p>The image attached is hotspotted to my iphone.</p>
<p>This sounds like it's probably a configuration on the network at your school. I'm not sure why it doesn't work with the iPhone hotspot.</p>
Hi, Thanks for your reply. <br>I have done some research and it appears that the esp8266 may have problems connecting to some routers. Would a firmware update fix this? Connecting via ethernet there is no problem. <br>many thanks<br>
<p>I'm not sure but it's certainly worth a shot. Let me know if that fixes it.</p>
<p>Hi,</p><p>Isn't the ESP8266 supposed to run with 200mA? I heard the 3.3v output from the Arduino is only 50mA which will not be sufficient to power it correctly. Am I wrong?</p>
<p>I've read the same thing and think that's generally correct. I think I get away with it here because it's only working in short bursts and not transmitting much data. If you wanted to log continuously or transmit more data it would probably need it's own power supply.</p>
<p>Since I am extremely noob regarding this module, what would I need in order to safely power it? Just Arduino, the ESP8266 and a power supply module? And then a led or a sensor to see things/data going...</p>
<p>That should be all you need but be sure that you are either using an Arduino with 3.3 V power out on the pins or set up a voltage divider like I do. You run the risk of damaging the ESP8266 if you use 5 V to power it (which is the default on many Arduino boards).</p>
<p>This is my output ,But thing speak is not giving any change .No data is logged.</p>
<p>Hi AbhijithA1, sorry for the delay. It seems that everything on the Arduino/ESP8266 is working fine so I would double check that you have your ThingSpeak channel set up correctly.</p>
<p>Hi tcodd86,</p><p>I got just AT on the monitor.</p><p>I checked:</p><p>1. RX and TX connections</p><p>ARDUINO | ESP8266</p><p>RX TX</p><p>TX &gt; voltage converter &gt; RX</p><p>2. Baud rate</p><p>Tried 9,600 and 115,200, configuring the line 9.</p><p>3. Voltage source for ESP</p><p>I am using 3.3Vdc</p><p>4. </p>
<p>Sorry for the unfinished message.</p><p>Do you know what else could be the failure?</p><p>Best,</p><p>Rob</p>
<p>Hi Rob, it seems that the ESP unit is not responding to the serial command from the arduino.The 'AT' command should prompt a response from the ESP8266 to indicate that it's working and communicating. If that's not working you may need to reflash the ESP8266. I have not had to do this myself but there are a couple of decent instructables on this.<a href="https://www.instructables.com/id/Intro-Esp-8266-firmware-update/">This one</a> is a good example. Let me know if that works.</p>
<p>Thanks! I will do it in a couple of days and come back.</p>
<p>How can I see the data written into the channel???</p>
<p>I got it!!! But the data is not logging in thinkspeak channel</p>
<p>How to reflash the firmware???</p>
<p>I had one other thought to try before messing with the firmware. Try adjusting the baud rate. There are two common rates for this chip, 9600 and 115200. My chip worked with 115200 but yours may be different. See line 9 of the code <a href="https://github.com/tcodd86/TempHumidThingSpeak/blob/master/TempHumidThingSpeakPublic.ino">here</a>.</p><p>I've never had to reflash the firmware but <a href="https://www.instructables.com/id/Intro-Esp-8266-firmware-update/step4/Uploading-Firmware/#intro">here </a>is an instructable on how to do it.</p><p>One other question is have you been careful to only use 3.3V with the chip? While it seems to be ok most of the time with 5V you do risk damaging it if that's what you use. So if you have used 5V previously you may have damaged the chip. I used 5V for a while with my chip with no issues but it is possible.</p><p>Let me know if any of this works for you and don't give up! It took me quite a bit of work to get my ESP8266 working the first time.</p>
<p>I used the same code . But only AT is printed in the serial monitor, nothing else is coming. Can you suggest any way to solve this?</p>
<p>Look at line 33 <a href="https://github.com/tcodd86/TempHumidThingSpeak/blob/master/TempHumidThingSpeakPublic.ino">here</a>. The first thing done in the setup is it sends the command 'AT' to the ESP 8266 to see if it's working. If it's connected properly and working you should see the response 'OK'. If the ESP 8266 doesn't respond with 'OK' the setup function jumps to the error function and the rest of the sketch fails to run. Check to make sure your serial lines are connected properly, TX|RX RX|TX, and if that doesn't fix it see if you need to reflash the firmware for the ESP 8266. Let me know if that helps.</p>
<p>Connections are fine , but still not getting the response from the wifi module.</p>

About This Instructable




More by tcodd86:Digital Ultrasonic Tape Measure Wireless Temperature and Humidity Monitor With ESP8266 Motion Detector With LED for Beginners 
Add instructable to: