#8 — The ESP32 Weather Station
It’s gettin’ hot in here!
*SpongeBob French narrator voice* Ah, the summer. We’re so close to the end of the semester and I can smell freedom from here. Although with the thing going on around in the world today, I doubt that I can have a nice summer holiday by the sea. To be honest, it’s kind of depressing to think about it, but hey who knows what’s waiting in the future ‘right? Let us all do our best and things will fall into place!
To get keep those summery vibes going, I’m going to make something pretty cool with the ESP32 today. Last time, I had a web server that can control LED lights using an independent web server via the WiFi. Guess what I’m gonna make today.
Weather Station
Did you miss our little friend the BMP180 sensor? Good, cause he’s back again in this project! I’m gonna create a weather station based on the tutorial from our beloved website which never let us down: the randomnerdtutorials.com. Basically, we’re going to get readings from the BMP180 sensor and display it on a web server. Oh, and did I say “lots of coding will be involved” in my last project? Turns out, there’s not much coding work here (heheh 😁) which means it’s gonna be super easy (yaaay)! Let’s jump right in then!
1. The ingredients and the wiring
I’ll be using my laptop, a 38 pins ESP32 board, a few male-to-male jumper cables, a MicroUSB to USB cable, a breadboard, and the BMP180 sensor. And surely, there must be an active WiFi connection that my laptop and the ESP32 board can connect to.
The wiring is pretty much the same as the first BMP180 project that I did before (read here). You should follow the steps until the “wiring it up” part and that should get you a neat looking circuit just like this.
I’m never gonna be tired to remind you not to forget double-checking your wirings before connecting the ESP32 to the laptop :D
2. The code
The code is pretty much a copy-paste, except the BMP180 part. We changed the library to be imported and the function to read the temperature, pressure and altitude, plus the value of the ssid
and the password
constants to my dormitory’s WiFi SSID and password.
The rest of the steps is pretty much the same as the web server project. I uploaded the code to the ESP32, opened the serial monitor at baud rate 115200, pressed the enable button on the ESP32, and the IP address of the newly created web server will appear on the serial monitor.
Copy and paste the IP address on a web browser and we can see that it displays the BMP180 readings on a neat table. The HTTP request header will also appear on the serial monitor every time we refreshed the window.
Seems to be working pretty nice ‘eh? To make sure that it’s really working, I tried to cup the sensor with my hand and see if the readings changed.
And the temperature goes up :) Easy peasy ‘right?
3. Afterword
To quote on Kevin Cahyadi Giri’s medium post:
“Kerjasama ini berjalan sangat lancar, benar kan Caca?” (Roughly translates to: “This teamwork runs very smoothly, ‘right Caca?)
I would have to say yes, yes, and yes! (Caca is my nickname by the way, and it reads like Chacha and most definitely isn’t this: 💩). We voice called each other to discuss the project and divide the tasks to be done: Kevin handles the code and I handle the circuit and the documentation. He’s right about the problem with the WiFi though: my dorm’s connection got pretty bad at that time and it took a long time for the ESP32 to be able to properly connect. But we’re able to finish the project within an hour and that sure is a pretty effective teamwork 💯💯.