ESP8266: Weather Station V2 Code published

ESP32 Development Board WiFi+Bluetooth Ultra-Low Power Consumption Dual Cores ESP-32 ESP-32S Board
Integrated antenna and RF balun, power amplifier, low-noise amplifiers, filters, and power management module. The entire solution takes up the least amount of printed circuit board area. This board is used with 2.4 GHz dual-mode Wi-Fi and Bluetooth chips by TSMC 40nm low power technology, power and RF properties best, which is safe, reliable, and scalable to a variety of applications.
This is a total make over of the earlier weather station. Instead of building my code
on the NodeMCU lua firmware I decided to switch to the Arduino IDE based development setup.
The reason for this was the constant problems with heap memory running out and other instabilities.
When I finally found code that demonstrated the use of my beloved SSD1306 based OLED 128×64 displays the final piece was in place.

I tried to separate the building blocks of the code into different classes, so they can be reused
easiley for other purposes. There is a class for the SSD1306 display and one for talking to the weather API of


This class interfaces with the display over the I2C bus. Please be aware that I set the bus speed relatively high, in order to have faster refreshes of the display. It can happen that for some reason this value is too high for your setup. Then you’d have to experiment with different values


I’m using the API to retrieve localized weather information. The API returns huge JSON objects which I thought would be hard to handle on the ESP8266. For this reason I wrote a little php script which selects interesting information and transforms it into key=value pairs, separated by a new-line charachter.
This can be handled very memory efficiently on the ESP8266. This step costed some self-convincing, since I’m usually a big fan of well structured data. But you have to think differently on embedded platforms

If you find any bugs or code with room for improvement please let me know. C/C++ is not my mother tongue… The best way to tell me about improvments are pull requests (which is a github feature…).

You find the code here:

Update: The WeatherStation Kit!

Order all components needed for the WeatherStation in one Kit. The WeatherStation Kit is available now at the shop:
Buy the WeatherStation Kit!
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?

Leave a Reply