ESP8266 Weather Display

Home/Arduino Projects/ESP8266 Weather Display

ESP8266 Weather Display

ESP8266 Weather Display

In this video we are going to build an ESP8266 Weather display with the impressive Wemos D1 board. The board uses the ESP8266 chip in order to connect to the internet and we are going to program it using the Arduino IDE. The project gets weather data from the openweathermap.org website and displays some of the data on the display. As you are going to find out, you can build this project in less then 10 minutes. Let’s start!

A few weeks ago I published a video about the impressive WeMOS D1 board which is an ESP8266 based board which resembles the Arduino Uno. Today we are going to build our first project with it. An ESP8266 Weather Display, using this old LCD display shield I was using with Arduino Uno a long time ago. As you can see, the display works fine with the WeMOS D1 board! The project, connects to my WiFi network, and then it downloads the weather data for my location from the openweathermap website, and prints some of data in the display! It downloads new data for my location every 10 minutes. It is nice project to start with the ESP8266 chip. Let’s see how to build it.

The parts needed in order to build the ESP8266 Weather Display are these:

——————–
WHERE TO BUY
——————–

Wemos D1 Board: http://bit.ly/WEMOS_D1

Keypad Display: http://bit.ly/ArduinoKeypadDisplay

Xiaomi Powerbank: http://bit.ly/PowerBank_XiaoMi

Full disclosure: All of the links above are affiliate links. I get a small percentage of each sale they generate. Thank you for your support!

That’s all. We only need two parts to build this project. The cost of the project is very low. It’s $10! You can find links for both parts in the description of the video. It’s really impressive that we can now build projects with WiFi capabilities very easily and with such a low cost.

All we have to do is to connect the parts together like this and load the code I provide. After a few seconds, the project will connect to the WiFi network and it will get the weather data from the openweathermap.org website. So, you can build this project in less than a minute. Great! Let’s now see the code of this project, where the magic happens!

The code of the project is really simple for a project like that. It needs less than 150 lines of code. We use 2 familiar libraries in this project, the ESP8266WiFi library and the LiquidCrystal library for the display. We also need the ArduinoJson library which can be downloaded from this website.

——————–

LIBRARIES
——————–

ArduinoJSON Library: https://github.com/bblanchon/ArduinoJson

Here’s why we need the ArduinoJson library. When we request weather data from the openweathermap.org website, it returns back the data in Json format. Json is a new open data format. The ArduinoJson library makes it really easy to extract the data that we need from the reply of the server and save them in our own variables. Let’s now take a look at the code.

At first we have to set the SSID and the password of our WiFi network. Next we have to enter the free APIKEY from operweathermap.org website. In order to create your own API key you have to sign up in the website. Getting current weather data and forecast is free but the website offers more options if you are willing to pay some money. Next we have to find the id of our location. Find your location and copy the ID which can be found in the URL of your location. Then enter your city’s id in the CityID variable. Now we are ready to move on.

——————–

CODE OF THE PROJECT
——————–

Download

 

 

 

SUBSCRIBE ON YOUTUBE

——————–

Never miss a video: Subscribe to educ8s.tv

2017-03-30T12:40:52+00:00

34 Comments

  1. Joel Berman June 13, 2016 at 9:08 pm - Reply

    Hi,
    First, thank you so much for publishing this. I am just starting to learn about Arduino and it is a great getting started project. I ordered the parts, but they have no arrived yet so I am trying to get the program compiled and make some changes. I have run into a problem and it is probably my ignorance. Maybe you could help.

    The problem is that I get an error in the code. The error is

    WiFiWeatherDisplay:25: error: ‘D9’ was not declared in this scope
    LiquidCrystal lcd(D8,D9,D4,D5,D6,D7);

    I have my board set to WeMos R1 D2 & Mini

    I am running the Arduino software 1.6.9

    I believe the call to LiquidCrystal lcd(D8,D9,D4,D5,D6,D7); is to define the pins connected to the LCD Panel. Am I using the wrong library? As I said, I do not have the hardware so cannot check the pin connections.

    Thanks for any answer and thanks for all your hard work.

    ^

    • Nick June 17, 2016 at 9:42 am - Reply

      The problem is the I use the Wemos D1 R1 board and you are using the D1 R2. In the second revision they have removed the D9 pin, I don’t know why, that’s why the code does not compile. Please add this line of code at line 3 of the code and please tell if it works this way.

      #define D9 2 // GPIO2 maps to Ardiuno D9

      Thanks!

      • Joel Berman June 21, 2016 at 5:20 pm - Reply

        Thanks Nick. I understand now and it will work fine.

  2. Nick June 17, 2016 at 9:49 am - Reply

    I have update the code in order to reflect the changes made on the Wemos D1 R2 board. It should work now. Please check it out. Thanks!

  3. Morten M Wiken June 18, 2016 at 2:10 pm - Reply

    The code in the link is not equal to the code in the video. Could you please link to the correct code?

    • Nick June 20, 2016 at 7:23 am - Reply

      Sorry for the mistake. It is now fixed!

  4. peter June 18, 2016 at 6:10 pm - Reply

    hello nick,

    i have downloaded your code, but i is not the same as in the video. I tried to copy the code from your video, but the video stopped at line 111. so i don’t know what the rest of the code is,

    please can you update the code, so i can give it a try,

    thanks,

    Peter

    • Nick June 20, 2016 at 7:23 am - Reply

      Sorry for the mistake. It is now fixed!

  5. Kenjutsu June 19, 2016 at 2:29 pm - Reply

    Hi. The downloaded code does not match that shown in the video. It contains no reference to openweathermap.org or ArduinoJson 🙁

    • Nick June 20, 2016 at 7:23 am - Reply

      Sorry for the mistake. It is now fixed!

      • Kenjutsu June 20, 2016 at 1:13 pm - Reply

        Thank you, and keep up the awesome work 🙂 Any plans on getting a Wemos D1 Mini?

        • Nick June 21, 2016 at 5:12 am - Reply

          Already got one! Review is coming soon!

          • Kenjutsu June 21, 2016 at 12:56 pm

            Cool!

  6. Morten M Wiken June 27, 2016 at 5:31 pm - Reply

    I am thinking about using this code for showing several locations on the display. Would this be difficult?

  7. Yahaya July 2, 2016 at 11:57 am - Reply

    Thanks for this rear opportunity of educating us on the wemos; i’m new to it though i have bought Wemos D1,i have series of problem to resolve:

    1. after the installation of arduino IDE 1.6.9 and update of Wemos to reflect on the tools i discovered that the system did not detect my serial com of the D1 despite installation of CH341SER successful. that is my major problem right now i picked Wemos D1(retired) since there is no Wemos D1 on the tools.

    Many thanks for your great assistant.

  8. Mike August 18, 2016 at 3:26 pm - Reply

    Hi , thank you for sharing this project, I am fairly new to arduino and was looking for a way to send data from the dht22 wirelessly to an arduino uno using nRF24L01+ modules and your code was the closest I could get to the components and the librarys I am using I had to make changes to the code to make it work for me, what I would like to know is how to change from Celcius to Fahrenheit? I would be grateful if you could let me know.

    • Nick August 20, 2016 at 6:30 am - Reply

      Use this command instead float f = dht.readTemperature(true);

  9. Mark September 2, 2016 at 2:48 pm - Reply

    Arduino: 1.6.7 (Windows 10), Board: “WeMos D1 R2 & mini, 80 MHz, 921600, 4M (3M SPIFFS)”

    C:\Users\Mark\Downloads\WiFiWeatherDisplay\WiFiWeatherDisplay.ino: In function ‘void loop()’:

    WiFiWeatherDisplay:66: error: ‘displayGettingData’ was not declared in this scope

    displayGettingData();

    ^

    WiFiWeatherDisplay:68: error: ‘getWeatherData’ was not declared in this scope

    getWeatherData();

    ^

    WiFiWeatherDisplay:72: error: ‘displayWeather’ was not declared in this scope

    displayWeather(weatherLocation,weatherDescription);

    ^

    WiFiWeatherDisplay:74: error: ‘displayConditions’ was not declared in this scope

    displayConditions(Temperature,Humidity,Pressure);

    ^

    Multiple libraries were found for “LiquidCrystal.h”
    Used: C:\Program Files (x86)\Arduino\libraries\LiquidCrystal
    Not used: C:\Users\Mark\Documents\Arduino\libraries\NewliquidCrystal
    exit status 1
    ‘displayGettingData’ was not declared in this scope

    This report would have more information with
    “Show verbose output during compilation”
    enabled in File > Preferences.

    Hi anybody have a clue why I’m getting this?

  10. Mark September 3, 2016 at 10:48 am - Reply

    Hi ok, got it all compiled now. Display says connected then all goes to dots two lines of.

    Help please.

  11. Mark September 12, 2016 at 2:26 pm - Reply

    Now working as it should. Left out part of the ssid Doh!!

  12. Barry September 21, 2016 at 2:58 pm - Reply

    First, may i add my thanks for all your hard work!

    My DFRobot LCD Keypad Shield is a 5V unit and works well with my arduino UNO, but not with the Wemos R1 D1. Your code puts all the weather info on the Serial Monitor beautifully, but not on the LCD. Is this a voltage problem? Thank you again.

    • Nick September 23, 2016 at 6:47 am - Reply

      I will check the code again I will post another message. Stay tuned!

  13. Barry September 24, 2016 at 2:08 am - Reply

    It’s OK, Nick, I got it working on an I2C-driven 20X4 LCD, using a logic level converter. Therefore, I assume the problem was voltage related. Your code is perfect. Cheers … Barry.

  14. khanfr October 13, 2016 at 6:31 pm - Reply

    i got arduino software 1.6.12 and i got the exact things you have but my lcd shows blank after i upload code…. please update 🙁

    • Nick October 14, 2016 at 7:50 am - Reply

      Yes, I will try it soon.

  15. Mark November 13, 2016 at 9:25 pm - Reply

    Thank you for your post. I was looking for the correct lcd pins, and you saved me a lot of time. Thanks 🙂

  16. Javartiste December 8, 2016 at 11:22 pm - Reply

    THANK YOU ! Spend 2 days trying to parse json data with Http request via Thingspeak and didn’t manage to do it. Your code is so clear, just had to replace no more than 3 or 4 things in order to adapt it! Thanks again, made my day, ahah 😀

  17. Cavlin January 16, 2017 at 2:04 am - Reply

    I get the message after uploading and connecting to wifi

    I get the message
    parseObject() failed

    • Nick February 9, 2017 at 1:13 pm - Reply

      Please update the ArduinoJson library to the latest one.

  18. jackson March 1, 2017 at 8:16 pm - Reply

    thank you for this project first of all,

    my problem is that I cannot get the data to display it self onto the LCD, I am using the DFRobot LCD keypad shield and the wemos D1 R1 board. I also get some random characters in the serial monitor with ‘parseObject() failed’ and then the weather data shows in the serial monitor but not on the LCD. Any help would be greatly appreciated.

    Thanks!! 🙂

    • Wilhelm Onken March 8, 2017 at 4:24 pm - Reply

      I have the same problem as you…

  19. Oliver March 11, 2017 at 1:03 am - Reply

    what ssid and password should i use?

  20. basma May 1, 2017 at 11:35 pm - Reply

    I’M new please help
    im having problem too
    can you show us where to add the library
    and which board I select from IDE

    Build options changed, rebuilding all
    error: ESP8266WiFi.h: No such file or directory

    #include

    ^

    compilation terminated.

    exit status 1
    Error compiling for board Arduino Uno WiFi.

    • Nick May 3, 2017 at 10:02 am - Reply

      You need to install the EPS8266 files for the Arduino IDE. You are compiling for the Arduino Uno Wifi and not for an ESP8266 board.

Leave A Comment

Close