My first try with an ESP32
Author
Andre
Date Published

One windy day in spring, my outside radio thermometer flew away...
Of course you can get replacements for these, but the one I got had such a week radio circuit in it, that it fails to deliver a strong enough signal for more then 10cm (I tested it with my flipper zero). That day I started thinking on how to make a better thermometer, maybe one, that also delivers a temperature to my smartphone or to a website.
Make or buy?
My first impulse was to look on amazon, but what I found was not satisfying, in my opinion. You could get as an example a wifi thermometer, that sends the current data to a server somewhere in the world. Then you would install an app on your phone that also connects to that server and displays the temperature. On the pro side you have an easy setup process and the whole thing should be good to go in a few minutes. On the other side you are integrating a device with unknown computational capabilities in you network -could be used in a botnet- that connects to a server that doesn't necessarily belong to the selling company/the company that is having their brand on the app and you need to use some app that needs permissions on you device and might show advertisement, that are definitely not part of the product I bought. My guess is actually, that the company, that's running the server and created the app, will shut the services down before the life of the thermometer ends, which would leave me with a basic thermometer and without the functionality I wanted. Either way, in my opinion the risks overweight the benefits and so my thought process continued...
What if I could build the whole damn thing myself? What would I need to do that?
Since I have a couple of Raspberry PIs kicking around, I have some experience on using the GPIO-Pins on them. I made more use if the Raspberry PIs as small, cheap and inexpensive servers (e.g. for my fist webpage with wordpress) but I knew that I could use them for that. When I looked for sensors on Amazon I also found a lot of stuff that said "compatible with Arduino and ESP32". That could be another route. For Servers I worked with Python FastAPI and also Next.JS before. And maybe I could also build a simple Android APP, but a Website, maybe with some authentication, would be enough for me.
I always wanted to try out an ESP32, since I have a couple more Ideas, that could need a small and powerconserving platform, so I got some 3xESP32 Wroom and some environment sensors for Temperature and Humidity. When they arrived I soon found out that the ESP32 doesn't really fit on a breadboard, so I ordered some jumper cables too.
First Steps
The ESP32 came with all pins presoldered, so that's ready to go. The sensor board did come with pins, but they were not soldered, which I quickly managed to do.
Hardware
Then comes the wires. I started with suplying power to the sensor board. I started with the connection to ground, so from a gnd-Pin on the ESP32 to the board. The sensor board takes 3.3V, so the next jumper went from 3.3V-Pin on the ESP32 to the VIN-Pin. Then came the signal jumpers, SDA (data) goes to Pin D21 on the ESP32 and SCL (clock) to Pin D22 on the ESP. Now the hardware is ready to go.
Software
No we need to tell the ESP32 how to communicate with the sensor board an what to do with it. I took a look around on GitHub for some example code and found a Repository that has some library code and an example, that worked out of the box for me.
I just stored both files (.h-library and .ino-example) in the same directory and opend the .ino with Arduino IDE (there is a bit more setup to do on the Arduino IDE, Tutorial here). Then I checked the code, flashed it, opened the Serial Monitor and there were Temperature and Humidity. To see if it actually works, you can e.g. breath on the sensor and see the humidity change or put the sensor next to your computers fan to see the temperature change. I noticed that the temperature is a bit off from other thermometers that I have, so there might be some correction necessary later on.
Next Steps
Next I will learn how to connect the ESP32 to my Wifi, so I can send the data to an API, that I will also have to create, and show a graph and the current data on a website, that's also not existing yet ;)
To be continued...