Community Forums

DIY IoT Weather Station using ESP32 and BME280

Posted by ElectronicsEnthusiast on October 26, 2023
Hello fellow makers! I've been working on a personal project to build a comprehensive IoT weather station, and I wanted to share my progress and get some feedback from the community. The core of the project uses an ESP32 microcontroller, which is fantastic for its Wi-Fi capabilities and low power consumption. For sensing, I'm using the popular BME280 sensor to measure temperature, humidity, and atmospheric pressure. So far, I've successfully:
  • Connected the BME280 sensor via I2C and read sensor data accurately.
  • Configured the ESP32 to connect to my home Wi-Fi network.
  • Published sensor readings to a MQTT broker (Mosquitto).
My next steps involve:
  1. Setting up a dashboard (likely using Node-RED or Grafana) to visualize the data.
  2. Adding more sensors (e.g., an anemometer for wind speed, a rain gauge).
  3. Exploring power-saving techniques for long-term deployment.
  4. Potentially adding a small display to the unit for local readings.
I'm facing a small challenge with reliably publishing data every minute without causing the ESP32 to miss other tasks. I'm currently using `delay()` after each reading, which I suspect is not the most efficient approach. Has anyone else built a similar weather station? What libraries or frameworks did you use for data publishing and visualization? Any tips on managing tasks and power on the ESP32 for sensor polling? Looking forward to your thoughts and suggestions!
Like (5) Reply Quote
That sounds like a really cool project! I've built a few ESP32 projects myself. For managing tasks and avoiding blocking with `delay()`, I highly recommend looking into FreeRTOS tasks or using the ESP-IDF framework's event handling mechanisms. You can often set up timers that trigger readings without freezing the main loop. For visualization, Node-RED is incredibly powerful and integrates seamlessly with MQTT. I've used it for a home automation dashboard and it works great. Grafana is also excellent for more complex time-series data.
Like (2) Reply Quote
Great work on the weather station! The BME280 is a solid choice. I used the Adafruit BME280 library which is pretty straightforward. Regarding your publishing issue, have you considered using `millis()` for non-blocking delays? You can check the elapsed time since the last reading/publishing and perform the action if enough time has passed, without halting execution. This is a fundamental technique for many Arduino/ESP projects. For additional sensors, I've had good experiences with the DHT22 (though less accurate than BME280) and the MAX44009 for ambient light.
Like (3) Reply Quote

Reply to this topic