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

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:
  • NodeMCU ESP8266 module (or any other ESP8266)
  • DHT22 sensor
  • 3 female-female wires
  • USB power supply
You can either order these items from Banggood or from my own online shop. 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?

Related:  ESP8266 Weather Station: Measuring Inside and Outside Temperature - Part 1

< Part 1

Now a beer! Did you like this post? It often takes me several hours of my free time to write one. If I was your neighbour would you offer me a beer for the hard work I did for you? The beauty is: beers can be teletransported with a painless donation using Paypal. A beer in a Swiss bar costs about USD $4.80. Or use this affiliate link if you order something on Banggood and I'll get a small kickback. Thank you!