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

Do you like this post? A regular project like the PlaneSpotter Color takes many hours of my free time to develop and maintain. Would you offer me a beer for my hard work if I was your neighbour? Modern technology called teleportation makes it easy to send me a beer. Just click here. 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. Great project! Have all components and already suceeded ploting data from sdr but esp+oled always feel magical 😉

    One question, you have mentioned wemos d1 mini, what driver are you using? my existing doesnt work with it although it uses ch340g (it works with witty)?

  2. Great project, I made a small copy under Arduino IDE as I have problems starting up with platform IO. now adding the displayfunctions… I also ordered a magnetometer, my final idea is to point the device in the direction of a plane that I can see and that the display shows me the info on that plane. Do you think that is feasible?

    1. Hi Hans. I guess the magnetometer would be a very cool addition to the orginal project and should be very much feasible. Maybe even add a GPS module into the mix and you won’t have to hard code the current coordinates. You mentioned that you had some issues with platformio. I heard that from several people but never really in details. Can you tell me a bit about the problems you ran into? I might write a clearing article about it then…
      – Daniel

    2. Hans, any chance you could gift me a copy of your Arduino IDE code for this project as I can’t get it working with PlatformIO either?

      PlatformIO always says that it can’t find port COM 9. I’ve tried modifying the platformio.ini file and this makes no difference.

      1. Hi Stephen. If I’m not mistaken just rename the main.cpp into Plainspotter.ino and move everything into a folder called Plainspotter. Now Download all libraries using the library manager (the platformio.ini contains a line defining all libraries) and you should be good to go. @Hans, please correct me if you had to do more than that… About the com port: which OS are you using? Is the Arduino Ide seeing the port? Maybe an issue with drivers or r/w permissions?

        1. Hi Daniel, everything builds successfully, but when I try to upload to the module I always get his error message.

          error: Failed to open COM9
          error: espcomm_open failed
          error: espcomm_upload_mem failed
          scons: *** [upload] Error -1
          [ ERROR ] Took 34.57 seconds

          I’m using Win10 Pro 64 bit and the ESP8266 is on COM4. The Arduino IDE program finds and uses the COM port with no issue, but PlatformIO always gives me the above error message.

          So I can use the WeatherStation program with no issues because it is an Arduino IDE project, but I can’t use PlaneSpotter because it needs PlatformIO, and PlatformIO is a problem for me.

          1. Hi Daniel
            Just an update for you.
            I got to the bottom of why I constantly got the error message I got in my previous post. My internet security program was treating PlatformIO as malicious software and wouldn’t let it send any data.
            Using your PlaneSpotterDemo and Arduino IDE 1.6.4, Plane Spotter is now working perfectly on your WeatherStation Kit!
            I’m now trying to figure out how to decode more data, in addition to “To/From” and “Aircraft Type”, such as “Operator Code”, and display it too.
            Many thanks for a great project!

          2. Stephen, looks like you’ve came across some other problem too;) You see, as you said you got esp on COM4 but look at the info from platformIO: it tries to connect on COM9. It happens when you don’t have upload_port specified in your platform.ini file and use multiple USB ftdi base devices. Just add to platform.ini upload_port=COMx, where x is current port you are using for ESP and you should be all set;)
            Best wishes

  3. Hi, cool project! I ordered one of your ‘Weather Station Kits’ so I could build it. Today I got a package but it only contained the MCU, not the display nor the jumpers. Could you email me? Cheers!

    1. Hi Costa
      As mentioned in the email to you the following sometimes happens: my supplier splits the order into two or more deliveries to ship parts of it faster. If you chose to pay for additional tracking you can follow each of the separate parcels and track them up to your door steps. Please let me know (here) when everything arrived…
      Kind regards,

  4. Hi,
    I’m new to all this I tried your weather app, so I moved on to this, for the life of me I cant get it to work, when uploaded to the Wemos I just have a blanks display, do you have a version of code that runs for the arduino-1.6.9 version


    1. Hi Paul
      My first suspect would be that you have the pins set wrong. Two suggestions to make sure this is true: do you get results from fetching the data from in the serial console? If yes, this means that everything is fine and just the display is not working. In that case I suggest that you first get the display working in the Arduino IDE with the OLED library example (File > Examples > ESP8266 OLED display driver for SSD1306 > SSD1306UiDemo) or from here:
      Make sure that you have the correct pins attached:

      // D3 -> SDA
      // D5 -> SCL
      SSD1306 display(0x3c, D3, D5);

      And there is also a chance that your display or the output pins that you planed to use are broken. Try to use other pins and don’t forget to adapt the code! Please let me know if it helped!

      1. Ok the simple demo works just fine.

        the planespotter app wont compile as I get the following error
        GCC error ‘D3’ was not declared in this scopeat line 70 col 40
        GCC error ‘D4’ was not declared in this scopeat line 70 col 44
        GCC error ‘SCL_PIN’ was not declared in this scopeat line 77 col 55
        GCC error ‘D3’ was not declared in this scopeat line 70 col 15

        any ideas>

        1. Ok just to add now working. I had to change the display code so it now just this

          SSD1306 display (0x3c, D3, D4);
          OLEDDisplayUi ui( &display );

  5. Hi Daniel,
    congratulations for your great project(s)!
    I have added a few lines to your code in order to display a message when there are no planes in range. I have added them to the “drawHeaderOverlay” function…
    else if (!adsbClient.isAircraftVisible()) {
    display->drawString(10, 10, “No planes”);
    Is it the right place to add this? Is “drawHeaderOverlay” the right place to interact with other I/O, for example adding a few leds or a neopixels in order to tell me when there are visible planes in range?
    Thanks and best regards!

    1. Hi Fernando
      Yes, the drawHeaderOverlay function is the right place to display the “No planes” message. Good idea, by the way. You could even add some information like “No airplane seen in the last 5 minutes”…
      I wouldn’t add interaction with other hardware into the drawOverlay functions. It would work but it is really bad style, since the drawOverlay function is for drawing to the display. A better place would probably be to add it to the main loop. And if you are worried about smooth animations you probably should make sure that you have enough cycles left in order to do the hardware interaction with this block of the main loop:

      int remainingTimeBudget = ui.update();
      if (remainingTimeBudget > 0) { ..}

      I hope that helps!

  6. I used a GPS like that on another project ( I might try to combine both systems to show the planepositions on my map…

  7. I also added an offset to the heading arrow in order to have it pointing the direction the screen and i am facing:
    #define LOCALHEADING 170 // this is what you measure holding a compass the direction you are facing at
    Then i subtract it in the drawHeading call:
    drawHeading(display, 78, 52, adsbClient.getHeading()-LOCALHEADING);
    In my case it is 170 degrees as this is the orientation of my terrace (170 degrees = almost oriented to the South). This is how I will be looking both at the screen and at the planes.
    As the arrow is drawn with trigonometric functions we just subtract the offset without caring about it being negative, right?

  8. Nice project
    How difficult would it be to combine this with your weather app on the same hardware?
    I’d love to create something like this with a toggle switch to select either weather or plane spotting mode.
    Is this feasible?

  9. Great project !
    I have been trying to use it with a Wemos OLED shield (64×48). Unfortunately the library used in your project is specific to the 128×64 pixel OLED display. In other words, the code is running but I can only see a part of the “real display”.

    Any idea on how I could use the 64×48 display ?

    Thanks in advance.

  10. Hello!

    I try this weekend to build my own planespotter (via arduino weather). But so far, I have no luck. I get the error:
    PlaneSpotterDemo:79: error: ‘D3’ was not declared in this scope

    const int SDA_PIN = D3;


    PlaneSpotterDemo:80: error: ‘D4’ was not declared in this scope

    const int SDC_PIN = D4;

    What have I done wrong?

    1. The D3 and D4 pins are only declared if you use an ESP8266 NodeMCU or Wemos board. For other boards you have to replace D3 and D4 with your GPIO pin number… Good luck and let me know if this tip helped!

  11. Finally I managed to get it compiled and on the serial console, I can see a lot of traffic going on. Unfortunately, it seems that I have bought a wrong version of the little tv screen. I have much more connections like RES, DC and CS. Silly me!
    Now I have to find out how to cable it and wait 4 damn weeks until I get the next version from far east.

  12. This allows it to program and serve files faster,in comparison with being attached
    to the department computer serving the applications.

    Intelinet Systems, which was providing IT services more than 26 years
    to companies in diverse sectors, contains the resources along with the expertise to offer such crucial security services for network backup
    software in an attempt to make sure your valuable business records are increasingly being
    safely stored. The enterprise information is fed into pricing and risk analysis data warehouse models.

  13. Seems that adsbexchange has changed from http to https for the public-api. To get it work I changed:

    // const char host[] = “”;
    const char host[] = “”;

    (Still waiting for my display)

    1. Reply to myself, its much better so change to https, and thats easy:

      In AdsbExchangeClient:
      use WiFiClientSecure client; instead of Wificlient
      set the httpsPort to 443 (I defined a new variable)

      I haven’t expected that the small esp is able to decrypt ssl-connections.

  14. Oliver thanks for your advice. Unfortunately I still can’t connect to adsbexchange. Would it be possible for you or Daniel to post a step by step guide to reconnecting to adsbexchange, or perhaps to FlightAware? Thanks

  15. Hi,
    for connectiing to adsb-exchange you need to edit the AdsbexchangeClient.cpp (I am working in arduino-IDE).
    Go to line 11 and change WifiClient to WifiClientSecure
    Go to line 18 and edit httPort, change 80 to 443

    Upload again to your planespotter and it should work again.
    At the moment (06 Nov 2016, 14:10) it seems that there are no data on adsbexchange. Cannot see any plane even on the webpage.

  16. Oliver
    Thank you for this, it was very helpful.
    As you say, there was no data on adsbexchange for a number of hours. It has just come back to life and I’m now receiving data, it maybe was a server outage?

  17. Hello,
    Thank you for these projects that are very instruction for a beginner like me.
    I started a Piaware and a plane spotter and I would liked to send an http request ( when the number of aircraft is greater than or equal to 1 ….
    i made several attempts but not being computer scientist, my tests were not conclusive.
    Can you give me the syntax for this type of request?
    thank you in advance

    1. Hi Gael
      I am not quite following. Are you trying to call to your PiAware instance from your ESP8266? And what would be the desired outcome?

      1. Hello,
        i want to send a HTTP request between the Wemos Plane Spotter and other wemos with color LED.
        i want to change the color of this led when an airplane fly over my house…
        i used this project “”
        i need to send a request like this when a plane fly over my house :
        And when he does not have a plane flying over my house :

        Thanks et “Bonne nuit”

      2. Hello,
        i want to send a HTTP request between the Wemos Plane Spotter and other wemos with color LED.
        i want to change the color of this led when an airplane fly over my house…
        i used this project “”
        i need to send a request like this when a plane fly over my house :
        And when he does not have a plane flying over my house :
        Thanks et “Bonne nuit”

  18. Squix78 – Tell what bar you like (i.e. best options), ask them if they accept Paypal and let me know their address, I will pay you not only one but a couple of beers! this is what I was looking for and cant afford the time, but I can afford the beers!!

  19. Hi all, since some time there was a little bug in the code with the daylight saving time. My station was not picking that up so during winter the time was off 1 hour and I kept changing UTC_OFFSET every 6 months between 1 for summer and 2 for winter. I found a little workaround. I am posting this here too. Dani had already made some code which can get the time from the local wunderground station so I used this today and it works like a charm!

    In the main sketch just locate the function bool drawFrame1() and change here 1 line, the one where string time gets the time assigned:
    bool drawFrame1(SSD1306 display, SSD1306UiState state, int x, int y) {


    //String time = timeClient.getFormattedTime();

    String time = wunderground.getHours() + “:” + wunderground.getMinutes() + “:” + wunderground.getSeconds();


    I do have it correct right? Or is there a reason why you did not use this timesource?

  20. I bought two weather station kit with DHT11, all work good, but I can’t get DHT11 working good, always got NAN information from the module. Im using WeatherStationDemo and esp8266-dht-thingspeak-logger where modify those lines to use DHT11 and D6 pin in MCU

    // DHT Settings
    #define DHTPIN 6 // what digital pin we’re connected to. If you are not using NodeMCU change D6 to real pin

    // Uncomment whatever type you’re using!
    #define DHTTYPE DHT11 // DHT 11
    //#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
    //#define DHTTYPE DHT21 // DHT 21 (AM2301)

    Always got this

    WiFi connected
    IP address:
    connecting to
    Requesting URL: /update?api_key=———————–&field1=nan&field2=nan
    HTTP/1.1 200 OK
    Content-Type: text/html; charset=utf-8
    Content-Length: 2
    Connection: close
    Status: 200 OK
    X-Frame-Options: ALLOWALL
    Access-Control-Allow-Origin: *
    Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS, DELETE, PATCH
    Access-Control-Allow-Headers: origin, content-type, X-Requested-With
    Access-Control-Max-Age: 1800
    ETag: “6364d3f0f495b6ab9dcf8d3b5c6e0b01”
    Cache-Control: max-age=0, private, must-revalidate
    X-Request-Id: 4539c208-db0e-4f85-ba42-a32d92c8ac38
    X-Runtime: 0.049378
    X-Powered-By: Phusion Passenger 4.0.57
    Date: Mon, 27 Mar 2017 12:56:55 GMT
    Server: nginx/1.9.3 + Phusion Passenger 4.0.57

    Any idea what i should do to solve this issue.

    Thanks in advance

  21. Coffee money was sent! Thanks for all the great code and documentation. Built both the small OLED and Color weather stations. Now just wrapped up a variant of the color version Fowlerk created. Fantastic mods he did to your original.

Leave a Reply