ESP8266 Weather Station Color code published

If you don’t mind code which is a little bit rough around the edges you can start experimenting with the code for the color weather station. I just published it on Github.

You  can find it here: https://github.com/squix78/esp8266-weather-station-color

Since it was sometimes complicated to find the right parts I created a kit which contains all the parts including the connector PCB:
https://blog.squix.org/product/esp8266-wifi-color-display-kit-2-4
By buying the kit from me you are supporting future development. Thank you!

Posted by Daniel Eichhorn

Daniel Eichhorn is a software engineer and an enthusiastic maker. He loves working on projects related to the Internet of Things, electronics, and embedded software. He owns two 3D printers: a Creality Ender 3 V2 and an Elegoo Mars 3. In 2018, he co-founded ThingPulse along with Marcel Stör. Together, they develop IoT hardware and distribute it to various locations around the world.

83 comments

  1. Observation, you could pull the weather icons from the Weatherunderground server rather than host them yourself. I think they do-not apply any read quotas.

    Did embedding the icons in flash prove to be too great an overhead?

    • Hi David. If I’m not mistaken these icons are from a 3rd party (which reminds me to put their credits up). So I’d have to host it somewhere anyway. I currently also only use uncompressed bmp format and I doubt that any reasonable person still has them around for normal use;-). And then: downloading has the advantage to be easier to change compared to embedding in the firmware… But it was a design decision. Comparing pros and cons…

  2. Hi,

    I have a working esp8266 weather but the small LCD only.
    im trying this one as i have the exact LCD lying around. i saw the “settings.h” where values need to be changed. (i.e. wundeground API, country, city, etc).. the only one that i was not sure and I did not see any explanation was the ThingSpeak value.

    May i ask what is the purpose of the Thingspeak value? i tried to view it but I think its a private channel.

    Anyway, i uploaded it on NodeMCU and when i inspect the Serial monitor, i can get to the part where it downloads the pictures.
    Here is the last bottom lines on the Serial.
    There is a line that says “connection failed.”…. Im guessing it has something to do with the Thingspeak..or maybe something else..

    …….(lots of downloding lines here…………..)
    Downloading http://www.squix.org/blog/moonphase_L19.bmp and saving as /moon19.bmp
    Downloading http://www.squix.org/blog/moonphase_L20.bmp and saving as /moon20.bmp
    Downloading http://www.squix.org/blog/moonphase_L21.bmp and saving as /moon21.bmp
    Downloading http://www.squix.org/blog/moonphase_L22.bmp and saving as /moon22.bmp
    connection failed
    connection failed
    connection failed
    connection failed

    Loading image ‘unknown.bmp’
    File not found
    Loading image ‘/mini/unknown.bmp’
    File not found
    Loading image ‘/mini/unknown.bmp’
    File not found
    Loading image ‘/mini/unknown.bmp’
    File not found
    Loading image ‘/moon0.bmp’
    File not foundconnection failed
    connection failed
    connection failed
    connection failed

    • Hi Glenn,
      The purpose of the Thingspeak channel is to display (say) your own local temperature and humidity. So I have an ESP8266 and BME280 sensor running that reports every 10-mins to thingspeak the current temperature and humidity in my garden. Therefore I provide the keys for my channel and it gets reported on the weather display. Ideally there would be a software (compile time) switch to remove that option.

    • today I received an email about WU stopping their API Service. I am afraid this affects also the weather station colour – are there any plans to keep the gadgets running?

  3. Please ignore the comment below.
    I was able to solve it. Apparently, the wifimanager didn’t connect successfully to my router, so i had to manually connect and put the static SSID and password.

    So its working now, yey! i can see the pictures and the icons properly.

    im still dumbfounded with the Thingspeak channel in the settings.h.
    May i know if that is really needed?

    • Hi Glenn, I’m a program newbie and met same message from serial port, but I struggled for long time but cant overcome this issue, do you mind give me some suggestion?

      Thanks!

  4. Would you mind sharing a picture and details of the hardware setup (e.g. pull-ups/down, capacitors, wiring)

  5. Hi,
    Is there any chance regarding tutorial how to call bitmaps using WiFi connection?
    I want to prepare own set of icons but I don’t know how to use it in your script 🙁
    As well I have a question reagrding screen refreshing, as I see that is the issue when the time is updated and some pixels are not removed?
    Thanks in advance for help.
    Piotr

  6. Very impressive weather station, works great!
    If it could automatically update summer/winter-time, it would be absolutely perfect.
    Have fun with the beer 😉

  7. I was able to get this running, but wanted to mention a small issue I ran into. (Sounds like the same one Mike McRoberts references.) The bitmaps require more than 1M of SPIFFS, so if you were like me and had selected only 1M at compile time, you run out of space to download all of the bitmaps, and many of the moon-phase bitmaps will fail to download, or will be perhaps truncated or corrupted. I went back and changed to 4M (3M SPIFFS) in the IDE and was able to solve this. Still having a bit of overlay issues with the time updates, but as Daniel mentioned, the code may still need a little work.

    Thanks for all the effort on this…now to add some of my own tweaks!

  8. Hi Daniel,
    i tried to flash the script but i will receiving all the time the following error:
    *******************************
    In file included from esp8266-weather-station-color.ino:34:0:
    C:\Users\Jens\Documents\Arduino\libraries\esp8266-weather-station-color-master/WebResource.h:25:31: fatal error: ESP8266HTTPClient.h: No such file or directory
    #include
    ^
    compilation terminated.
    Fehler beim Kompilieren.
    *******************************
    I added the ESP8266HTTPClient-library to the Arduino 1.6.5 but there is still the same error.
    Do you have any idea what i can make that the script will runing?
    Jens

    • Same error here, anybody found a solution for this? I have Arduino 1.6.5, tried ESP core module from v2.0.0 up to v2.3.0. Also the wifi manager did not show a config page, if I use ESP core 2.1.0 or higher…

  9. Unfortunately Banggood.com are no longer stocking the 2.2 Inch Serial TFT SPI Display ILI9341 display! Can it be obtained from another supplier? Or can an alternative be used?

    I would like a bigger screen for my PlaneSpotter project so that I can enclose everything in a case with the lcd screen acting as a box top : )

  10. Dani, excellent! Built this over the weekend (preparing to teach another IoT class this week) and almost worked flawlessly (2.4″ TFT + Wemos D1 Mini). Couldn’t get the WifiManager to connect, tried a few different things then finally went manual mode. The 199: timeClient.updateTime(); would sometimes hang, changed the .h to use “us.pool.ntp.org” instead; didn’t do a lot of troubleshooting, was more in quick-fix mode. Maybe later this month I’ll try incorporating Neptune’s daylight savings code back into this (thanks btw for the link to that). PS will try to get some pictures with the kids doing projects over the session the next two weeks. Regards, Mike

  11. Dani,

    I’ve been adding some of my own enhancements to your original code for several weeks now, and thought I’d share some of my changes in case anyone was interested. I’ve posted these on GitHub if you’re interested…https://github.com/fowlerk/ESP8266-Color-Weather-Station-v8 .
    This version includes many enhancements to the displays (see the README on GitHub), along with Neptune’s enhancements for daylight savings time. The code could stand some clean-up, but otherwise seems to work well.

    Let me know what you think…I’ll post some photos of the displays when I get a chance.

    Keith Fowler

    • Hi Keith

      You put some really nice things into the code! I knew that the WifiManager had this configuration UI feature but never got around to use it in my code. Now with your code I have a very nice example to use it;-). Thank you a lot for sharing! I just posted your fotos on Twitter and linked to your repository, I hope you don’t mind.

      I am working ATM on a 2.4″ display with touch. This would allow to switch screens or similar…

      Dani

      • Dani…I don’t mind at all, in fact I’m honored. One thing to note, which I pointed out in the README on the repo, is that I have added a few fields over the past few months that may (or may not) have made it into the Weather Station library for the Weather Underground functions. Not sure how exactly to go about getting those into the master. (You may even be able to spot these on some of the displays.) I did not put those library changes up on the repo.

        I’d also had my eyes on those touch-screens and had similar thoughts on using them to control the screen displays. I’m anxious to see what you end up doing with it. Your projects always give me more ideas to try ;).

    • keith, can you ples tell me what i need to download in the the IDE program to set this up there are so many files i do not know what one i need ! thansk

      • Andrew…yes, sorry for not making this more clear in the documentation. I’ve (mostly) just used libraries that others have contributed and were already referenced in Dani’s examples, but you’re right that the list has gotten relatively long and may take some digging to find all the sources. Give me some time today and I will add the links to the documentation on my Github repository.

      • I have updated the README on my repository with info on the contributed libraries and links to make it easier to find these. Let me know if you have any other questions.

    • Hi Keith! I have problem with your code!
      The App asks to enter the address 192.168.4.1 in the browser but I can not access that address (“access denied”); the IP of my router is 192.168.1.1; What should I do, please? Thank you

  12. Hey Dani and Keith, I just tried this out a few days ago and love it. Just wanted to confirm that when I tried to use Keiths’ version, it failed to compile due to the changes in the Weather_Station library. I would really like to try out this version if one of you could point me at the correct library.
    This was my first project with an esp8266 and I am really surprised at how powerful and easy it is to use.

    Kevin

    • Kevin…yes, sorry, I knew that would bite someone. I really wanted to get the changes merged into Dani’s master library rather than start off on another branch. In the interim, I have uploaded the two changed library files for the Weather Underground components to a separate folder on the repo if you want to download those to (temporarily) replace the original ones in the Weather Station library. That should allow it to compile. Let me know if that doesn’t work for you. Hopefully I’ll figure out the right (permanent) solution to address the changes soon.

      Keith

      • Thanks for the update Keith,

        I got the new code and everything works great. Now I just have to figure out how to make it work with a bigger screen, maybe 7 inch. My eyes ain’t what they used to be. 🙂

        Kevin

        • Glad you got it working Kevin…and I know what you mean about the old eyes! I’m right there with you. I’m torn between the compact size and being able to read all the data displayed without my glasses ;). Let me know if you find a bigger option that works well for a reasonable cost.

  13. Dani…just made a pull request on your repository to add some of the changes I had made to your Weather Underground library. Let me know if you have questions or issues.

  14. Dani, I just made another pull request for some new updates to the Weather Underground client library. These include changes to support some additional enhancements I have been working on recently that display weather alerts (as per the WU API call “/alerts”), as well as the addition of probability of precipitation (PoP). I have uploaded a new version to my repository on GitHub that shows these additional enhancements (see the README for further details), along with screenshots.

    As always, let me know if you have any questions or issues, and best wishes for the upcoming holidays!

  15. If anyone should want to try out the weather alerts additions prior to the library changes getting merged into the master, I have uploaded the changes to my distro on GitHub here: https://github.com/fowlerk/ESP8266-Color-Weather-Station-v8; take a look at the v9 folder for the enhancements that use the new library changes. I have also updated the README with information on these changes.

  16. Hi Daniel. I don’t like the Ardunid IDE because of the lack of debugging with breakpoints. Therefore, I’ve just started with VisualGDB and JLink debugger and ESP8266. I have quite some difficulties.

    Do you have any experiences with VisualGDB?

    By the way: I am situated near Zurich and I like your projects! Great work!

  17. I have been having a lot of fun working through the examples with your weatherstation library. I bought your kit, which was an easy way to get started with the ESP8266.
    I am working through the WeatherStationDemoExtendedDST, for some reason updateData is not firing every 10 minutes. updateDHT is working fine, fires every minute.
    I think this is where the problem is, it isn’t setting readyForWeatherUpdate to true. However, it looks exactly the same as your other examples.
    if (readyForWeatherUpdate && ui.getUiState()->frameState == FIXED) {
    updateData(&display);
    }
    Thanks for any help.

  18. Figured it out. Apparently you can’t attach two events to a single ticker? I created two tickers, and now it works.
    tickerUpdateData.attach(UPDATE_INTERVAL_SECS, setReadyForWeatherUpdate);
    tickerUpdateSensor.attach(60, setReadyForDHTUpdate);

  19. I have problems getting it to run with Arduino 1.8.1, esp8266 2.3.0 board plugin and an SPI display. I have to slow down SPI to 250 kHz, otherwise I get all but pixel trash. But when I set OLEDDISPLAY_REDUCE_MEMORY I get a blank screen.

    Do you know of any problems with given setup? Can you recommend a good working combination of Arduino IDE, ESP plugin and SPI settings?

    • I am a bit confused: which project are you referring to? The OLED Weather station or the color weather station which uses an TFT? Since you posted this in a Color Weather Station post I assume you are referring to the color code? But why then use the OLEDDISPLAY_REDUCE_MEMORY? Can you share a gist which shows your ino file?

      • I’m sure, I posted that to “ESP8266: SSD1306 Oled Library Release”. 🙂

        Well, I’m just using your examples for the SSD1306 driver. Using a Wemos D1 mini R2 and “SSD1306Spi display(D0, D2, D8);”

        I had it working some weeke before. In the mean time I updated a lot of software, including IDE and board definitions.

        So, there are few choices left: the software combination I have is broken or D1 or display are broken.

        Can you or anyone else report that Wemos D1 mini R2, Arduino 1.8.1 and esp8266 2.3.0 are working with this SSD1306 library (unmodified)?

        Thank you!

        • I’m still not sure, if my hardware or software combination is broken. But I finally got it all working. Key was reducing SPI speed. In SSD1306Spi.h we have a SPI.setClockDivider (SPI_CLOCK_DIV2), which means 8 MHz. It seems, the (just my?) display can’t handle that, I get mostly pixel garbage. If I reduce that to SPI_CLOCK_DIV64 (which means 250 kHz), it all works. I can even skip the yields() in SSD1306Spi.h’s display() routine. And I can get some speed back with replacing the SPI.transfer-loop for non-double-buffer cases with “SPI.writeBytes(buffer, sizeof(uint8_t) * DISPLAY_BUFFER_SIZE);”

  20. Thanks for making this template availble in the public domain. It has proven to be very valuable. As an improvemnet, would it be possible to have the NodeMCU pin assignment names on the PCB board, similar to the arduino one.

  21. I am having problems with the Weather Station. First screen (time) works well. Second screen says “N/A C”, Third scrren shows N/As, Fourth screen (temp, humid) works well. I have tried installing the latest github code and it doesnt solved the problem. Any tips?

  22. I have bought the Weather Station on Amazon. It came with a DHT11 in a board with a pull up resitor. I am following the pdf with instructions. When pluging this board, the figure at the pdf looks like inverted. My litthe dht board is (from left to right): data, vcc, gnd. It took me a while to figure out this. Also, by printing the read temp and humid values, I saw half of them come as nan. Any tip for improving this?

  23. Hi all

    I got the kit for the weather station color a couple of days ago.
    I started looking into the code.
    A few months ago I already built up the weather station based on the tiny OLED display.
    I played a little bit around with the code to display market stock values and also sport results.
    I love the availability to have different frames rotating.
    I’m just wondering if someone implemented also frames for the color display.
    If someone got frames implemented for the color display, would share your solution?

    Regards,
    Marcos

    • Hi Marcos

      Thanks for your question. You are both lucky and a bit too early: I have been working on a new graphic library for the color display in the last couple of weeks. It is not quite ready yet but if you want to play around, here it is: https://github.com/squix78/minigrafx

      There is an sample for how to use the carousel. Please let me know if you are using it and what you think about it. Please also be aware that I might change the API before the official release, it is currently only alpha or beta stadium…

      Kind regards,
      Daniel

  24. One small tweak to “settings.h” in the esp8266-weather-station-color-master code. It asks for a city, but my city has half a dozen ZMX codes at weather underground. Through experimentation, I found that you can just put the ZMX code in place of the city name, and it works.

    BTW, your getting started guide for the old weather station is very nice for arduino and nodemcu beginners. However, the examples there (and also the examples you supply for the arduino IDE) don’t work with a ILI9341 display. For a while I was afraid I had some bad soldering, but when I ran esp8266-weather-station-color-master, the display lit right up as expected/

  25. Good Day all,i am looking for the enclosure to print.Wheir can i find it in STL format..Thank you

  26. I have a couple of 2.8 TFT displays I have been trying to update to the new Color Weatherstation code. They don’t register the touch, and just flip through the screens every 500ms, like they are constantly being touched.

  27. Hi there all, did any one managed to attach and display a DHT22/11 sensor for the indoor temperature? i struggle with it a lot at the moment.

    I added all relevant libraries and codes as best i known in the code from Daniel but when i upload the code, the updating screen freezes after “updating astronomy” – i’m sure i missed something…

    Any ideas?

    I used the original code from Daniel – https://github.com/squix78/esp8266-weather-station-color

    1. I added the Libraries as below:

    //DHT Libraries to include
    #include
    #include
    #include

    2. I defined Type and Pin

    #define DHTPIN D1
    #define DHTTYPE DHT22

    3. then i did following

    DHT_Unified dht(DHTPIN, DHTTYPE);
    float localHum = 0.0;
    float localTemp = 0.0;

    then in the following part (see original code)

    // draws current weather information
    void drawCurrentWeather() {

    I added below the last commands following

    sensors_event_t event;
    gfx.setFont(ArialRoundedMTBold_14);
    gfx.setColor(MINI_WHITE);
    gfx.setTextAlignment(TEXT_ALIGN_RIGHT);
    dht.temperature().getEvent(&event);
    String localtemp = String(event.temperature);
    gfx.drawString(220, 105, localtemp);

    i know that sensor is working then and provide data (i checked with serial.println) but then it freezes… i guess i missing some basic programming here that it works properly but here i’m stuck with my lack of experiences…

    Any ideas?

    Cheers
    Marcel

  28. I just built the color weather station and luckily got it running the first time, it’s very nice. If you touch the screen the time changes back and forth between 24h and 12h display. Nice. But the only issue I’m seeing is the day scrolling shows MON TUE WED, pauses, then shows FRI SAT SUN. Thursday does not show up. Odd. Any ideas?

    Thanks

  29. Hi, I tried buidling this kit and everyting seemed fine until i programmed the Wemos d1. It shows everything on the screen except the weather it shows symbols with ? in it. I have tried everyting switching api, reinstaling libaries and i even tested an example of wunderground but it just doesnt show any data, do you have any idea what could have gone wrong?
    Best regards Kevin

  30. Hi Keith! I would like to use your code, but when I compile it, it appears on the screen asking to enter this IP 192.168.4.1 to make the settings but I can not get into this IP (Server 192.168.4.1 took too long to respond). Note that I live in Brazil and the IP on my computer is in the range of 192.168.1.1; Does that have anything to do with it? Otherwise, how can I access this IP 192.168.4.1? If you can help, I thank you.

  31. Hi, I started trying to build this out only to discover that WeatherUnderground no longer provides (free) API Keys. Any plans to change this to work with another service, or suggestions to work around?

  32. Hello,
    I’m running straight into problems after downloading (even without changing any thing). Quit sad 🙁

    My error message:

    Archiving built core (caching) in: /var/folders/74/5k206y1s32z81gtj5zjbq1lh0000gn/T/arduino_cache_214867/core/core_esp8266_esp8266_d1_mini_CpuFrequency_80,UploadSpeed_115200,FlashSize_4M3M_de75e1f93600d33876e4f457693bf095.a
    sketch/esp8266-weather-station-color.ino.cpp.o: In function `drawAbout()’:
    /Users/Felix/Desktop/esp8266-weather-station-color/esp8266-weather-station-color.ino:610: undefined reference to `gmtime’
    sketch/esp8266-weather-station-color.ino.cpp.o: In function `getTime(long*)’:
    /Users/Felix/Desktop/esp8266-weather-station-color/esp8266-weather-station-color.ino:610: undefined reference to `gmtime’
    libraries/esp8266-weather-station/OpenWeatherMapForecast.cpp.o:(.text._ZN22OpenWeatherMapForecast5valueE6String+0x9e): undefined reference to `gmtime’
    collect2: error: ld returned 1 exit status
    exit status 1
    Fehler beim Kompilieren für das Board WeMos D1 R2 & mini

    But thx for the great work, time and effort in this project!

  33. Hello there, got the Kit and so far everything went very smoothly until the download. Got the following error messages:

    Arduino: 1.8.7 (Windows Store 1.8.15.0) (Windows 10), Board: “LOLIN(WEMOS) D1 mini Pro, 80 MHz, Flash, 16M (15M SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 921600”

    Sketch uses 428756 bytes (41%) of program storage space. Maximum is 1044464 bytes.
    Global variables use 35120 bytes (42%) of dynamic memory, leaving 46800 bytes for local variables. Maximum is 81920 bytes.
    error: failed sending 0xC0
    error: failed sending 8 bytes
    error: failed sending 36 bytes
    error: failed sending 0xC0
    error: failed sending 0xC0
    error: failed sending 8 bytes
    error: failed sending 36 bytes
    error: failed sending 0xC0
    error: failed sending 0xC0
    error: failed sending 8 bytes
    error: failed sending 36 bytes
    error: failed sending 0xC0
    error: failed sending 0xC0
    error: failed sending 8 bytes
    error: failed sending 36 bytes
    error: failed sending 0xC0
    error: failed sending 0xC0
    error: failed sending 8 bytes
    error: failed sending 36 bytes
    error: failed sending 0xC0
    error: failed sending 0xC0
    error: failed sending 8 bytes
    error: failed sending 36 bytes
    error: failed sending 0xC0
    error: failed sending 0xC0
    error: failed sending 8 bytes
    error: failed sending 36 bytes
    error: failed sending 0xC0
    error: failed sending 0xC0
    error: failed sending 8 bytes
    error: failed sending 36 bytes
    error: failed sending 0xC0
    error: failed sending 0xC0
    error: failed sending 8 bytes
    error: failed sending 36 bytes
    error: failed sending 0xC0
    warning: espcomm_sync failed
    error: espcomm_open failed
    error: espcomm_upload_mem failed
    error: espcomm_upload_mem failed

    Any idea on that?
    thanks,
    lukas

  34. today I received an email about WU stopping their API Service. I am afraid this affects also the weather station colour – are there any plans to keep the gadgets running?

  35. I installed everything and it working good BUT I do not know if it is a bug or something that is an error on my part but I get multiple names of days displaying :/ like MON MON TUE or MON TUE TUE. There is ALWAYS a duplicate name of day in the 3 that are displayed. How to fix please?

    TIA!

  36. hello,
    i made the project and looks great.
    my problem is that it connects to my wifi but it doesn’t get any data.
    it shows the correct time but for the weather i get a ? in the cloud icon an 0.0 oC for temperature
    i used different cities but with no luck.

  37. Tried to update the Colour Weather and received the complying errors:

    In file included from /home/mx1/Downloads/esp8266-weather-station-color/esp8266-weather-station-color.ino:25:0:
    settings.h:86: error: ‘D1’ was not declared in this scope
    #define TFT_CS = D1
    ^
    /home/mx1/Downloads/esp8266-weather-station-color/esp8266-weather-station-color.ino:83:31: note: in expansion of macro ‘TFT_CS’
    ILI9341_SPI tft = ILI9341_SPI(TFT_CS, TFT_DC);
    ^
    settings.h:85: error: ‘D2’ was not declared in this scope
    #define TFT_DC = D2

    There are more, but this is a snippet. All seem to have to do with the screen.

    Now, I built this from the Adafruit websiite with a Huzzah.

    • Removed the “D” from the code and a fee other tweaks and the code now compiles. It does not upload giving the error

      warning: espcomm_sync failed
      error: espcomm_open failed
      error: espcomm_upload_mem failed
      error: espcomm_upload_mem failed

      • OK, Update: got by the above error, wrong port, should’ve known..

        No it is stuck on the ThingPulse splash screen saying it is updating time.

  38. My TFT just refreshes. I really don’t know what to do. I bought this kit and assembled it a few years ago and it worked great until WU decided to yank the API for personal use.
    At any rate, I just can’t get the screen from saying, Connected, Connecting, Connected, Connecting, etc. and refresh of the screen.
    If anyone out there in Arduino Land can help I would appreciate it very much. I even built an outdoor weather station that is recharged by a Solar Panel. So I am new but not brand new. Just still learning..
    Thank you,
    Steve

  39. I have the same problem with a refreshing screen when trying to connect to the wifi. Any solution to this?
    Thanks

    • I had this problem. A friend suggested that I ‘roll back’ the ESP8266 board manager to version 2.5.0
      Upon doing this, and reloading the sketch, all works fine now.
      Thanks to my friend Shaun for helping me sort this out.

  40. I just built the color weather station and am having the same connecting problem: continuing refreshing screen showing connecting … but never connects. Changed the setting.h file to “us.pool.ntp.org” and rolled back the ESP8266 board manager to version 2.5.0. No change. Still in endless connecting loop. Any help?

Leave a Reply to williamloringCancel reply