ESP8266 Weather Station: Measuring Inside and Outside Temperature – Part 2

Do you like this post? Writing posts, developing libraries and programming online font creators is actually hard work. I order most of my electronics from a Chinese website called Banggood. It is save and the items usually arrive in good quality. With every order you do there by following this link you are supporting the blog. Thank you!

In Part 1 of this series you learned how to connect a DHT temperature/humidity sensor directly to your WeatherStation and to display the readings as an additional frame in the carousel rotation. In this second part I will show you how to setup a sensor node and post the readings to a free cloud service before fetching them on a WeatherStation (in another room) and displaying them there.


For the sensor node you’ll need:
You can either order these items from Banggood, from my own online shop or if you life in the US from Amazon. I assume that you have already a working WeatherStation.


The climate node is relatively easy to wire. The DHT breakout board has only three connectors: GND (Ground), VCC (connect to 3.3V) and DAT which is the data line that we connect to pin D6 on the NodeMCU


Thingspeak is a free cloud service which allows you to easily post (sensor) data, to visualize it and to retrieve it again using simple HTTP methods. I’d like to point out that you could also use Wunderground to store your climate data and it probably would be very easy to do as well. But I believe that for education purposes Thingspeak allows you more degrees of freedom. After all you could also send them read outs from a motion sensor or similar things. Thingspeak has some nice additional features which lets you program webhooks to trigger a push notification on your cell phone, etc.
So first of all you have to sign up for a (free) account on Thingspeak. Go to and create the account. After you completed that process, log in to your new account and go to “My Channels”:
There you click on the “New Channel” button. Then fill out the form:
Explanation: The name just helps you to recognize your channel among many others that you might create over time. The important part are the field names. This name will later show up in the chart and with this I’m telling Thingspeak that the value I’m sending later with the field1 attribute should be displayed as Temperature.
Now navigate to the API Keys tab and note the two generated keys:
The first one will allow you to write to this channel in Thingspeak and the second one will allow you to read from it later. Treat them as secrets and with care. Others might be able to spam your channel or to “steal” your data. (BTW: I regenerated the keys after taking a screenshot;-)). We will use these keys soon enough… Also note the channel ID on top of the screen…

Programming the Climate Node

Now we have all ingredients to post the climate data to Thingspeak. We just have to program the ESP8266 accordingly. Go to and download the code as Zip file (or do a git check out, if you know what that means).
Now adapt the settings to your needs:

Especially the Wifi settings and the Thingspeak API key have to be updated. Take the Write API key from the previous step here. For testing you might also play with the update interval which is a number in seconds. Please be aware that the minimum update interval in Thingspeak is about 15 seconds. Below your updates will just be ignored.Now flash your program to the Node MCU and your Climate node should start logging. To check the results you can go back to Thingspeak and look at the charts:

Displaying the data on the WeatherStation

Now to the real easy part. Like a cook in the TV kitchen I have prepared this step a long time ago (possibly to your confusion;-)). The WeatherStationDemo that comes as an example with the WeatherStation library already contains everything needed to display your own Climate Node data:

Look for these lines in the demo and replace the read api key and the channel ID with the ones you got in the Thingspeak step. If you didn’t remove the climate node section in your weather station code you just need to flash your WeatherStation with the updated API key and channel ID and voilà: you just successfully sent the temperature and humidity data from the next room once around the world just to display it on a tiny OLED display. I know some people (including my wife) who wouldn’t be impressed by that at all;-).Explanation: This last step might have been a bit confusing, since the tv cook had prepared everything hours before the TV show actually started, so here the summary in slow motion: the Weather Station library now comes with a class called Thingspeak client which does all the leg work. You pass in the channel id and API key and it downloads a JSON object and picks out just the last data set, since we are currently interested only in that. Have a look at to understand what happens and maybe adapt/ extend it to your needs. Why not display the chart of the last 24 hours on the OLED display?

<Measuring Inside and Outside Part 1

Posted by squix78


  1. Nice article and addition to the first part you wrote some days ago. I wonder if anyone has some ideas how to protect the DTH22 outside. If I want to measure the temperatures outside snow and rain or even a strong wind may destroy the sensor. But I can't just put it in a case because the readings may not be correct then.

    Any ideas?

  2. Hi Taki K

    I have a thingspeak weatherstation myself for a year now. I used a waterproof case (IP68) BUT: punched a tiny hole in it and pointed this downward so if it rains the rain will not get in. I use a BMP180 for airpressure so NO HOLE was no option, then I cannot measure the pressure accurately. DHT22 needs a hole also because otherwise humidity will not be accurate

    • Hi DVE,

      Thanks for your advice. But isn't the temperature in the case other then outside the case? Or does the hole equals the inner and outside temperatures?

  3. Hi Taki K

    The whole case assumes/takes the outside temperature after 10-20minutes so this gives no error. Besides the BMP180 I use is not so calibrated. I found that the temperature readings are quite close to those I see on semi-prof stations in the neighbourhood. Personally I dont mind 1 degree error 🙂

    You could place the station under a small roof or something. Or experiment a little with the case open and compare with closed? I dont think you will see shocking differences.

  4. Nice Article and technical solution.
    How big is the power consumption of the ESP8266 Nodes?
    Is it possible to power them from a battery pack?

  5. Got my WeatherStation fully operational today. Thanks so much! (Beer teleported!)



  6. Have you considered both displaying the data locally using the weather station code and uploading to Thingspeak? That way I can see my home temperature from the office or office temperature from home without too many additional esp8266 boards. I’d be interested in some information on how your scheduling works and how much time is available in the main loop. I presume its the display driver that takes the most time

    • Hi Tim. Basically yes, that should be no problem at all. I was just more interested on the outside temperature while watching the data indoors. The current scheduling is quite simple. Just make sure that the time intensive things don’t happen while you are animating the display or the carousel won’t so smooth anymore. You can check in which state the carousel currently is and only execute when the frames are not moving. If you want to do “background” tasks don’t execute them without such a check. I also wouldn’t execute it during the clock frame, since the seconds might “jump” a lot… If you need more speed, you can also switch to the BRZO version of the I2C driver. This driver is written in assembler and is a lot faster than the built-in I2C driver…

  7. hey i have one doubt ..if i am using weather station demo example by using nodemcu and oled only then will i get graphs on thingspeak channels or its neccessary that i should connect one dht sensor with it…if it is possible then plzz let me know coz i have tried alot but i am not getting it..
    thanks in advance

  8. Got the Thingspeak uploads working. I’m now considering swapping the DHT sensor for an SHT11. Is it acceptable to share the I2C for the display and if so can I get away with a Wire.beginTransmission(eSHT2xAddress); in the main code assuming that the display code has already initialised the pins?

  9. Now consider adding particle counter (PM2.5/PM10) for inside and outside, as well as NO2(outside) and CO2(inside), as well as noise meter (dB meter). Additionally new BMP680 will be a good choice for inside application into air quality measurements. BME280 and BME680 has two I2C addresses, or can be separate controlled by SPI – so there you go – one for inside, one for outside.

Leave a Reply