ESP32 WiFi Weather Station Project with a Nextion Display and a BME280 sensor

Dear friends welcome to another video! In this video we are going to build a WiFi
enabled weather station project! We are going to use the new, impressive ESP32
chip for the first time along with a Nextion display. Let’s get started! Hello, guys, I am Nick and welcome to
a channel that is all about DIY electronics projects. In this channel, I share everything about
the projects I build to help you develop similar projects or inspire you to start making things
because it is easy, fun and creative. Subscribe to the channel now if you do not
want to miss any future video. In this video, we are going to make this. It is yet another weather station project
I know, but this time we use the new ESP32 chip! We also use the new BME280 sensor which measures
the temperature, the humidity, and the barometric pressure. When we power up the project, it connects
to the WiFi network, and it is going to retrieve the weather forecast for my location from
the openweathermap website. Then it will display the forecast on this
3.2” Nextion Touch Display along with the readings from the sensor! The readings are updated every two seconds
and the weather forecast every hour! As you can see, in this project we use the
latest technologies available to a maker today! If you are a DIY veteran, you can build this
project in five minutes. If you are a beginner, you have to watch a
couple of videos before attempting this project. You can watch those videos by clicking on
the cards that will appear during the video. Let’s start! In order to build this project we need the
following parts: • An ESP32 board
• A BME280 I2C sensor • A 3.2” Nextion display
• Some wires The cost of the project is around 30$. You can find links to the all the parts I
use in the description of the video below. Instead of the ESP32, we could use the cheaper
ESP8266 chip, but I decided to use the ESP32 to gain some experience with it and see what
works and what not. This is the first project I ever build with
the new ESP32 chip. If you are not familiar with it, the ESP32
chip is the successor of the popular ESP8266 chip we have used many times in the past. The ESP32 is a beast! It offers two 32 processing cores which operate
at 160MHz, a massive amount of memory, WiFi, Bluetooth and many other features with a cost
of around 7$! Amazing stuff! Please watch the detailed review I have prepared
about the chip by clicking on the card here. It will help understand why this chip will
change the way we make things forever! Also, this is the first project I build with
a Nextion touch display. The Nextion displays are new kind of displays. They have their own ARM processor at the back
which is responsible for driving the display and creating the graphical user interface. So, we can use them with any microcontroller
and achieve spectacular results. I have prepared a detailed review of this
Nextion display which explains in depth how they work, how to use them and their drawbacks. You can watch it by clicking on this card. The connection of the parts is straightforward
as you can see from this schematic diagram. You can find a link to the schematic diagram
in the description of the video below. Since the BME280 sensor uses the I2C interface,
we only need to connect two wires to communicate with ESP32. I have attached the sensor to Pins 26 and
27. In theory, every digital pin of the ESP32
board can be used with I2C peripherals. In practice though, I found out that some
pins did not work because they are reserved for other uses. Pins 26 and 27 function great! To send data to the display, we only need
to connect one wire to the TX0 pin of the ESP32. I had to bend the pin like this to connect
the female wire of the display since the ESP32 board is too big for this breadboard. After connecting the parts, we have to load
the code to the ESP32, and we have to load the GUI to the Nextion display. If you have trouble uploading the program
to the ESP32 board, hold down the BOOT button after pressing the upload button on the Arduino
IDE. To load the GUI to the Nextion display, copy
the WeatherStation.tft file I am going to share with you to an empty SD card. Put the SD card into the SD card slot at the
back of the display. Then power up the display, and the GUI will
be loaded. Then remove the SD card and connect the power
again. After successfully loading the code the project
will connect to the WiFi network, it will get the weather forecast from the
website, and it will display the readings from the sensor. Let’s now see the software side of the project. To parse the weather data, we need the excellent
Arduino JSON library. We also need a library for the sensor. You can find links to all the libraries in
the description of the video below. Let’s see the code now. At first, we have to set the SSID and the
password of our WiFi network. Next, we have to enter the free APIKEY from website. To create your own API key, you have to sign
up on 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. Also, enter the altitude of your town in this
variable. This value is needed for accurate barometric
pressure readings from the sensor. Now we are ready to move on. At first, we initialize the sensor, and we
connect to the WiFi Network. Then we request weather data from the server. We get a reply with the weather data in JSON
format. Before sending the data to the JSON library,
I manually delete some characters that were causing me problems. Then the JSON library takes over, and we can
easily save the data that we need in variables. After we have kept the data in variables,
all we have to do, is to display them on the screen and wait an hour before requesting
new data from the server. The only information I present is the weather
forecast, but you can display more information if you wish. It all here saved in variables. Then we read the temperature, the humidity
and the barometric pressure from the sensor and we send the data to the Nextion display. To update the display, we simply send some
commands to the serial port. If you get this compilation error while compiling,
you have to add this -fno-threadsafe-statics at the platform.txt file which is located
here: … Press save, and then the project will compile fine. The software for the ESP32 is not mature,
yet so some things do not work at once yet. The Nextion GUI consists of a background,
some textboxes and a picture that changes depending on the weather forecast. Please watch Nextion display tutorial for
more information. You can quickly design your own GUI if you
wish and display more things on it. As always you can find the code of the project
in a link in the description of the video. As you can see, an experienced maker today
can build exciting projects in just a few hours with a few lines of code and only three
parts! A project like this would have been impossible
to make even two years ago! Of course, this is just the beginning of the
project. I would like to add many features to it, like
graphs, touch functionality that is now missing, maybe a bigger display and of course a beautiful
looking 3D printed enclosure. I will also design a better looking GUI and
icons. I have some very fresh ideas to implement! I would love to hear your opinion about today’s
project. What kind of features do you want me to add
to the project? Do you like how it looks? How do you want to see it evolve? Please post your ideas in the comments section
below; I love reading your thoughts! If this is your first time here, I would love
to have you subscribed. In this channel, I post videos about DIY projects
twice a month. I love making things, and I believe that anyone
can make things, anyone can become a maker. That’s why I created this channel, to share
my knowledge with the community and learn from the community. I hope you will join us. I will see you in the next video! [ Translating these subtitles?Add your name here! ]

100 Replies to “ESP32 WiFi Weather Station Project with a Nextion Display and a BME280 sensor”

  1. Thank you sir. This was educational as usual.

    I know it might not be something you are interested in. Maybe you know where I can start to look for the answers. On modern cars, there is an OBDII port. I have bought a bluetooth ELM327 OBDII adaptor from eBay. This sends all manner ofinformation to my cell phone via Bluetooth. It works very nicely indeed. Iwant totake it a step further. I would like to build a boost indicator or a fuel economy meter from this OBDII port using a Nextion display and an Arduino. Where to begin?

  2. I'm quite sure you have more than 1 breadboard, it's kinda late but next time try using two breadboards and "bridge" the controller over the 2 of them no need to bend your pins, nice channel by the way!

  3. Sir can you make some projects with camera interfacing with NodeMcu to capture images from anywhere with the help of BLYNK application.!

  4. Since the LCD display is driven over a serial connection, you should totally make the communication to the display over Bluetooth. You could have the weather station out side, and then show the display inside the house. Nice video. I am thinking of using this display on some projects of my own.

  5. Hi,
    Thank you for this!
    Could you please upload the font files you have used (.zi files) ?
    This way we can use them for other nextion projects too! Thanks.

  6. I have a project idea for you. I drive my car to garage every day. I cant drive my car forward in, I have to drive it backward. Make an ultrasonic distance sensor that tells how far the car is from the wall (unit positioned at the wall). It has to send the data to another unit /display (in the wall at the front side of the car) that shows the distance. Can you do that ?

  7. Bravo sou palikari mou. Oloi I oikpgenia exei mathei polla apo sena. Ta pedia mou se thaumazoune. O Tropos Pou ta exigis me leptomeries, fotografies ke download links einai thaumasios. Xana synharitiria, kai nase panta kala. Manolis

  8. A really great project. 🙂 Which Nextion Editor version do you use? I can open WeatherStation. hmi, but I get the info that this file was created by an older version. The pictures don't fit, they are smaller… Can you check which NextionEditor you are using? Thanks.

  9. Can you make an ESP32 web server how-to video? By the way, you make the best arduino videos out there. Keep up the great work!

  10. I get a compile error
    C:UsersJimDocumentsArduinolibrariesAdafruit_BME280_Library/Adafruit_BME280.h:170:14: error: 'TwoWire' has not been declared

    bool begin(TwoWire *theWire); I'm sure it just forgetting something. I did add the BME280 lib.

  11. I'll surely order these items; I'll wait for your how to create the UI of the display and I'll like to make something like a monitor of temperature and humidity also be able to access those over url on other computer.
    Hopes that makes sense.
    Sorry for my English.

    Good work brother

  12. Thank you for the video. I would like to build a weather station with a pressure bar graph as pressure rate of change is important. Unfortunately my coding skills are not up to this! Do you have plans to produce one?

  13. I just wanted to say thank you. You are a great educator and helped me when I got started. You're as easy to understand as someone of my accent. I think it's good to listen to other accents, because we should all be speaking the same language anyway. This is product quality gear, and you just give it away. Thanks for bringing the masses such a great and encouraging experience. Whenever someone tries to call you an idiot, tell them you can turn on your coffee maker from 10000 miles away with 4 dollars in parts.

  14. Usually beginners like me are about to consider the power management after one or two projects like this in order to learn more about the sleep functionality provided by the micro controller and utilize other modules such as PIR or RTC, looking forwards to do the power saving videos with ESP32, REALLY!

  15. @4:09 Espressif and other producers claim that their module is breadboard friendly in their false advertisement. Same problem to me and later I find this kind of breakboard may work, , quite expensive from aliexpress .com comparing with the prices on taobao .com

  16. (English Below) Και όχι δεν είσαι Ελληνάρας! 😀 Ευχριστώ πολύ. Θα το φτιάξω αλλά σε έκδοση για το αμάξι. Θα αντικαταστήσω την πρόγνωση με μια formula που θα υπολογίζει το υψόμετρο ανάλογα με την ατμοσφαιρική πίεση. Η formula σε περίπτωση που σε ενδιαφέρει είναι 1013.25 – (τρέχουσα βαρομετρική πίεση) και το αποτέλεσμα το πολλαπλασιάζεις επι 8. Δεν είναι ακριβής ο υπολογισμός λόγω της αυξομείωσης της πίεσης ακόμα και στο ίδιο σημείο αλλά είναι μια αρκετά καλή ένδειξη.
    I will substitute the weather forecast with a formula which calculates the Altimeter and place the device in my car. The formula is not quite accurate because of barometric pressure changes even at the same place but it's a fairly good indication. The formula is 1013.25-(current barometric pressure) and multiply the result by 8. You get your approximate altimeter (in meters)
    For example the current pressure at my location is 998mbar. The formula is 1013.25 – 998 = 15.25. I then multiply by 8 so I get 15.25×8= 122 meters above sea level.

  17. I have a question to ask you how can I adapt the ESP32 to create traffic lights and want to make it performed automatically and controlled by the App inventor or another app (it's required at least 16 output)
    big thanks in advance sir 🙂

  18. Great work Nick, really top stuff!
    I had a lot of work to get readings displayed on Nextion because my board (Adafruit's Huzzah Esp32) has Tx as Serial1, but when I finaly got things right it was a great moment!
    Keep on!

  19. Dude, you just made me buy three variants of ESP32 modules and this display, 40 pounds in total…
    I got:
    – ESP32 with integrated 18650 li-on battery holder, charging and step up converter
    – ESP32 with integrated OLED display
    – ESP32 standard

  20. καλησπερα και μπραβο για τη δουλεια σου πολυ οραια κατασκευη. εχω ενα μικρο προβλημα τον BME280 τον εκανα παραγγελεια απο εκει που εχεις βαλει το link σχεδον απο τοτε που ανεβασες το video και ακομα δεν εχει ερθει και αναγκαστικα συνδεσα εναν αλλο BMP280 αυτον,
    ο οποιος γραφει οτι ειναι ΜΟΝΟ ατμοσφαιρικη πιεση στην περιγραφη αλλα πιο κατω λεει οτι μετραει και θερμοκρασια τον εβαλα πανω και ολα δουλευουν. πως γινετε να εχω και υγρασια ενδειξη αφου δεν εχω αισθητηρα? μηπως ο αιθητηρασ μου δειχνη μονο ατμοσφαιρικη πιεση και τα αλλα 2 τα παιρνει απο το openweathermap? ευχαριστω.

  21. The design of the ESP32 for a breadboard looks like a HUGE FAIL!!! I guess you can make it go over 2 different breadboards to have room to make other connections.

  22. This is a great project which I build as well. Everything works fine for a couple of hours and then the esp looses the connection with the I2C bus. Because the temperature reading of the BME280 is not very precise, I added a DS18b20 on a onewire connection. The reading of the DS18b20 also fails once in a while. When I switch off the WIFI connection the system is very stable. I solved it by resetting the esp in the software when the connection failes. Anybody other ideas?

  23. I have a problem. Always when I try to compile the code I got the following error: "ESP32_Weather_Station:85: error: 'class WiFiClass' has no member named 'enableSTA'"
    What is my mistake?

  24. nice project, i made this but im having a problem with the BME280 randomly going to full value and having to reboot, i have tried several different sensors and ESP32 boards and they all do the same thing, could someone help? thanks

  25. Good video but have question. I have problem with nextion library. How you change NexConfig and NexHardware? Because I have some errors on it.

  26. Not sure what im doing wrong. Have all the parts, code compiles and uploads but nothing ever happends. Serial monitor dont provide any usefull information. Tried other simple code examples and they do work.

  27. Hi, great project, what board is used in the Arduino ide ?, do i have to add a new board for the Node esp32 dev board ?.. thanks

  28. Nick is it simple to 'relocate' the display to a remote location apart from the sensor? Possibly by adding a second esp32 dedicated to the display itself, would we need to use the web server code at the esp32 for the sensor? Have you ever used the Nextion display's as remote viewers?

  29. How about making an application that everyone could access to see the data for the weather in just a click on their phone?

  30. Hi, thank you very much for your tutorial. I find it to be well explained. I have a problem reading the sensor. In my case i have a GY-21P so the library BME280 wont work. Can you please tell me what can i do to make it work? Thank you in advance….

  31. hello, im using Arduino mega and sparkfun Si 7021 Temp sensor and MPL3115A2 Humidity sensors.
    i have code and run perfectly on my PC
    But i want LCD display connect to it. Please help me how to connect my Arduino with Nokia display
    i use some code from internet but its not working

  32. A question
    Can ESP32 be connected to Arduino Mega as module for using just WiFi or Bluetooth and storage the code in Arduino instead of ESP32?

  33. Absolutely superb! Σας ευχαριστώ
    If you added a GPS module, you could adapt it to work wherever it was- I am biased because I will need to connect a GPS to an ESP32 soon and your videos help me a lot. Keep up the good work!

  34. The video is great.
    I am amazed with what you know and how you explain it. Thank you.
    I would like you to tell me where to download the programs that you have used for the esp32 and for the nextion screen to go more directly in the project that I want to do to visualize what happens in my little garden when I'm not there.
    I can not find the link for them on your channel. Or send it to me by [email protected]
    Thanks and support.

  35. Is it possible to create a water level display inside home with sensor mounted on tank(may be 50M away) where ESP32 will send real time info?

  36. Need Help pleaseYour Projects are very helpfull. I download your scetch but by compiling I get the error messageESP32_Weather_Station:159: error: 'StaticJsonBuffer' was not declared in this scope StaticJsonBuffer<1024> json_buf; ^ESP32_Weather_Station:161: error: 'ArduinoJson::JsonObject {aka class ArduinoJson690_000::ObjectRef}' has no member named 'success' if (!root.success())           ^

  37. Issue is  solved . I changed  ARDUINOJSON_VERSION_MAJOR from 6xxx back to 5xx and then it works.However, your Projects are greate and are very helpfull  for me as an beginner.Regards

  38. Πολύ ωραίο βιντεάκι, άλλα από την προφορά κατάλαβα ότι είσαι Έλληνας, όταν είδα και το sparta σιγουρευτηκα :p

  39. What library did you use for the Nextion display? I have basix 3.5" display and tried to use NeoNextion and it was really slow :(.

  40. Do you want to try to speak more calmly. Because of your hasty communication method, it becomes hard to understand. For the rest; Well done!

  41. Upgradr this project with floating cloud table piece like things it will b more realistic to see clouds displaying thanderstrom and dailyweather forcast with RGB lights in between clouds.
    Plz let me if u try my idea
    My watsapp number is 03432119971

  42. Geia sou file, thelo na se rotiso ean boris na me boithisis se ena project . mipos exeis ena email pou boro na sou epikinoniso private.

Leave a Reply

Your email address will not be published. Required fields are marked *