ESP32 Web Server with BME280 – Mini Weather Station

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video you're going to learn how to create a simple web server with the ESP 32 to display readings from the BMA TWiT 0 sensor module this sensor measures temperature humidity pressure and estimates altitude there are several versions of the sensor module but we're using this one with this sensor you can easily build the mini and compact weather station and monitor the results using your ESP 32 webserver that's exactly what we're going to do in this project this sensor can communicate using SPI alright to see communication protocols to use SPI communication protocol you use these pins and to use I to see communication protocol the sensor uses these two pins we're going to use I to see communication with the VM eat with 0 sensor module for that wire the sensor to the ESP 32 SDA and SCL pins as shown in the schematic diagram to read from the BMI sensor you need to install two libraries in your arduino ide the other fruit BM eat with zero library and yeah the fruit sensor library after installing both libraries open the arduino ide and go to file examples Adafruit be a meat with zero library and open the BM eat with zero test sketch the code starts by including the needed libraries as we're going to use I to see communication you can comment these next lines however if you're using SPI communication with the ESP 32 you need to change the pin definition to use its SPI pins you can either use the HSP eye or the VSP IG pios getting back to the cove here a variable called sea level pressure HPA is defined this saves the pressure at the sea level in Ekta Pascal this variable is used to estimate altitude for a given pressure by comparing it with a sea level pressure this example uses the default value but for more accurate results replace the value with a current sea level pressure at your location this example uses I to see communication by default as you can see you just need to create another fruit underscore BM e 280 object called BM e if you would like to use SPI you need to comment this line and uncomment one of these lines depending on whether you are using hardware or software SPI in the setup you start the serial communication and the sensor is initialized in the loop the print values function reads the values from the BME to it zero and prints the results in the serial monitor reading the sensor values is as simple as using these methods read temperature to read temperature in Celsius read humidity to read absolute immunity in percentage read pressure to read the pressure in Ekta Pascal and read altitude to estimate altitude a plotter code to RESP 32 and open the serial monitor at the body rate of 9600 it should see the readings displayed on the serial monitor as you've seen in the beginning of the video we're displaying the readings in a web page with the table served by the ESP 32 so we need to write HTML text to build a table an HTML table is defined with table tags each table row is defined with the TR tags for our table we need six rows so let's copy this tag six times a tipple layer is defined with the teach tax so we can write our errors like this inside each row we create two cells one with the name of the measurement and another told the measurement value add two cells to each row using the TB tags here's the table example after adding some sample values to the other and cells these three slashes should then be replaced with actual measurements from the BMI sensor save this file as they will dot HTML and drag the file into your browser you should see a table like this the table doesn't have any Styles applied you can use CSS to style the table with different colors defined borders font types etc but we won't discuss up style table in this video you can go to this web page and find useful examples now that you know how to take readings from the sensor and now to build a table to display the results it's time to build a web server copy that code provided your arduino ide don't upload it yet first you need to include your SSID and password here then check that you have the right part and comm parts like a protocol to your ESP 32 after uploading it open the serial monitor at the body 8 of 11 5200 and copy the ESP 32 IP address open your browser past the IP address and you should see the latest sensor readings to plate the readings you just need to refresh the webpage now let's take a closer look at the code to see how it works first you include the Wi-Fi library and the needed libraries to read from the BMA tweet zero sensor the next line defines a variable to save the pressure at the sea level for more accurate altitude estimation replace the value with the current sea-level pressure at your location you recreate another fruit BM eat with zero object called BMI that by default xtablet is a communication with a sensor using i2c as mentioned previously you need to add your SSID and password to the following variables in the setup we start the serial communication at the word rate of 11 5200 for debugging purposes you initialize the BMI sensor and check if it started successfully then you initialize the Wi-Fi connection with a Wi-Fi dot begin function wait for a successful connection and print the ESP IP address in the serial monitor in the loop we program what happens when a new client acts tablished is a connection with a web server the ESP is always listening for incoming clients with this line when a request is received from a client will save the incoming data the while loop that follows will be running as long as the client stays connect we don't recommend changing this part of the code and unless you know exactly what you're doing next you use the client dot println function to send HTML text to build a web page finally to display the actual sensor readings in the table you just need to send them to the client between the corresponding TV tags as we're doing here if you are using another sensor you could replace the BMI readings with your own sensor readings by default the table is displaying the temperature readings in both Celsius degrees and Fahrenheit you can comment these three lines if you only want to display the temperature in Fahrenheit degrees when the response ends we clear the other variable and stop the connection with a client in summary in this project you've learned how to read temperature humidity pressure and estimate altitude using the BM II tweet zero sensor module you also learn how to build a web server that displays a table with sensor readings you can easily modify this project to display data from any other sensor click the first link in the video description to download the code and find all the resources needed to complete this project thanks for watching and don't forget subscribe
Info
Channel: Rui Santos
Views: 42,504
Rating: undefined out of 5
Keywords: rui santos, randomnerdtutorials, random nerd tutorials, bme280 web server esp32, bme280 with esp32 code and schematics, bme280 web server esp32 code, weather station esp32 bme280, how to use bme280 with esp32, ESP32 Web Server with BME280 – Mini Weather Station
Id: 6LjbTgX046w
Channel Id: undefined
Length: 8min 50sec (530 seconds)
Published: Sat Aug 18 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.