Pocket Meteo Logger

Name: Duca Andrei-Rares
Group: 331CA

Introduction

Pocket Meteo Logger (PML) is a hand-held, battery-powered micro-station that continuously measures local weather and air-quality parameters – temperature, relative humidity, barometric pressure, equivalent VOC / CO₂ level and particulate-matter concentration.

The device offers three core services:

  • Live feedback – numeric values, trend arrows and status icons are displayed on a 0.96″ OLED screen, offering instant readings without needing a phone or laptop.
  • Context-aware alerts – a tiny buzzer and two RGB status LEDs signal critical changes in air quality or environmental conditions.
  • Long-term logging – every minute, fresh samples are time-stamped; the data are either cached to a micro-SD card (offline trips) or, when Wi-Fi is available, pushed to a Google Sheets cloud spreadsheet for later analysis.

The project started from hiking and cycling needs: a reliable field barometer, an AQI indicator and a silent logger that do not depend on a phone’s battery. Because PML is fully open-source, hikers, air-quality hobbyists or students can reuse both hardware and firmware to build their own variants — adding extra sensors, changing alert rules or integrating it into larger IoT systems.

Powered by a single Li-Po cell, PML fits in a shirt pocket, survives multiple days on one charge and re-charges via USB. Three tactile buttons let the user browse current values and the last-hour history directly on the OLED display, without any external device.

General Description

Pocket Meteo Logger is designed as a compact, battery-powered weather station you can carry anywhere. It wakes up every minute, collects environmental data from onboard sensors, displays the results on a tiny OLED screen, stores the readings locally or uploads them online — and then quietly returns to sleep to preserve energy.
The system is built from a clear split of hardware modules (sensors, display, storage, alerts) and software components (data collection, user interface, alerts, power handling), each focused on a specific role. Together, they create a responsive, energy-efficient logger that offers both real-time monitoring and offline browsing, with minimal user interaction.

Hardware modules

Module Role
ESP32 Dev Board Main microcontroller with built-in Wi-Fi; handles all processing, sensor communication, sleep logic, and cloud sync
BME680 combo-sensor All-in-one sensor for temperature, humidity, pressure, and air quality (VOC) via I²C
0.96″ OLED Display Ultra-low-power screen for showing live values and recent history even when asleep
MicroSD Card Slot Used for saving CSV logs when Wi-Fi is unavailable or as offline backup
Buzzer & RGB LED Provide alert sounds and color-coded warnings for high pollution or temperature levels
Tactile Buttons Allow user to navigate data, view logs, or set alert thresholds
Power System Includes Li-Po battery, USB-C charging via MCP73832, and voltage regulators for sensors

Software modules

Module Role
Sensor Drivers Low-level communication with sensors (I²C and UART), returning calibrated readings
Sampling Scheduler Wakes up the device once per minute and starts the data collection sequence
Data Logger Stores samples locally (CSV on SD) or sends them to Google Sheets via HTTPS when Wi-Fi is present
Alert Engine Monitors values and triggers buzzer/LED alerts when readings exceed set thresholds
Display Manager Handles screen updates, rendering current values and past samples efficiently
UI Handler Reads and debounces button presses; manages menu navigation and selection via a state machine
Power Manager Controls sleep/wake transitions, turns off unused peripherals to save battery

How they interact

  • Wake-up tick – The RTC timer inside the ESP32-C3 wakes the system every minute or on button press.
  • Sensor sweep – The sampling scheduler triggers the sensor drivers to collect fresh data from the BME680.
  • Alerts – If any environmental value exceeds a preset threshold, the alert engine activates the buzzer and RGB LED.
  • Display update – The display manager updates the OLED screen with the latest readings and a short historical graph.
  • Log / Upload – The data logger writes the values on the microSD card or uploads them to Google Sheets via Wi-Fi.
  • Back to sleep – After a few seconds of inactivity, the power manager disables all peripherals and puts the ESP32 back into deep-sleep mode.

Block diagram:

Hardware Design

Component List:

Pin Usage

1. Power Supply and Voltage Stabilization

LiPo Battery (3.7V, 500mAh) → 3.3V Voltage Regulator Module

  • LiPo Battery (3.7V)
    • Red Wire (+) → VIN+ (3.3V Voltage Regulator Module)
    • Black Wire (-) → GND- (3.3V Voltage Regulator Module)

3.3V Voltage Regulator Module → ESP32

  • VOUT+ → 3V3 (ESP32)
  • GND- → GND (ESP32)

2. BME680 Sensor

  • VCC → 3V3 (ESP32)
  • GND → GND (ESP32)
  • SCL → D22 (SCL) (ESP32)
  • SDA → D21 (SDA) (ESP32)
  • SDO → GND (to set I2C address to 0x76)
  • CS → 3V3 (to select I2C mode, not SPI)

3. OLED Display

  • VCC → 3V3 (ESP32)
  • GND → GND (ESP32)
  • SCL → D22 (SCL) (ESP32) (shared with BME680 sensor)
  • SDA → D21 (SDA) (ESP32) (shared with BME680 sensor)

4. MicroSD Module

  • VCC → 3V3 (ESP32)
  • GND → GND (ESP32)
  • CS → D5 (ESP32)
  • SCK → D18 (ESP32)
  • MOSI → D23 (ESP32)
  • MISO → D19 (ESP32)

5. Alert LEDs

  • Green LED (Normal Values)
    • Anode (long) → D27 (ESP32)
    • Cathode (short) → GND
  • Red LED (Alert Values)
    • Anode (long) → D26 (ESP32)
    • Cathode (short) → GND

6. Buzzer for Sound Alerts

  • VCC → 3V3 (ESP32)
  • GND → GND (ESP32)
  • I/O → D25 (ESP32)

7. Touch Buttons (for Navigation)

  • Button 1 (Next Value)
    • One Leg → D14 (ESP32)
    • One Leg → GND
  • Button 2 (Previous Value)
    • One Leg → D13 (ESP32)
    • One Leg → GND
  • Button 3 (Enter/Back)
    • One Leg → D12 (ESP32)
    • One Leg → GND

8. TP4056 Charging Module for LiPo Battery

  • B+ → Red Wire (+) from LiPo Battery
  • B- → Black Wire (-) from LiPo Battery
  • OUT+ → VIN+ (3.3V Voltage Regulator Module)
  • OUT- → GND- (3.3V Voltage Regulator Module)

9. 5V Boost Converter (for OLED and Sensor)

  • V0 (Output) → VCC (OLED)
  • GND → GND (shared with the rest of the circuit)
  • V1 (Input) → VOUT+ (3.3V Voltage Regulator Module)

10. Breadboard and Connection Wires

Ensure all components are correctly connected and logically arranged on the breadboard:

  • Power Rails for 3.3V and GND.
  • Direct Connections between modules and ESP32 as per the diagrams above.

Images

Simulation Results

The validation of the Pocket Meteo Logger system was performed using both the Serial Monitor (debug interface) and the physical feedback from the hardware components.

The system was verified successfully in both modes: local display and cloud logging.

Through the Serial Monitor (USB connection to laptop), the following were observed:

  • Real-time readings of temperature, humidity, pressure, gas resistance, and estimated altitude from the BME680 sensor.
  • Wi-Fi connection status and reconnection attempts every 4 minutes if offline.
  • Debug information regarding SD card access and Google Sheets upload confirmation or failure.
  • JSON payload formatting and HTTP response from Google Apps Script.

On the physical device:

  • The 0.96″ OLED display shows live readings every 30 seconds in clear text and switches to stored values in history mode using the three navigation buttons.
  • The microSD module successfully logs timestamped sensor data in CSV format.
  • When sensor values are within safe thresholds, the green LED is activated.
  • If any value exceeds set safety limits, the red LED turns on and the buzzer emits a warning for 4 seconds.
  • Using tactile buttons, the user can:
    • Enter/exit history mode
    • Browse previous logs saved on the SD card
  • If Wi-Fi is available, measurements are automatically uploaded to a linked Google Sheets document for remote viewing.

Software Design

Software Status

  • The firmware for the Pocket Meteo Logger is currently fully implemented and has been tested in both normal and edge-case operating conditions.
  • The code is written in C++ and runs on the ESP32 Dev Board, compiled and uploaded via the Arduino IDE.

Library Choices and Motivation

Library Purpose
Adafruit_BME680 Simplifies interaction with the BME680 sensor via I²C and handles calibration logic internally.
Adafruit_GFX + Adafruit_SSD1306 Used to control the 0.96″ OLED display, providing graphics primitives and text rendering.
WiFi.h Built-in ESP32 library for managing Wi-Fi connections.
HTTPClient.h Enables HTTP POST operations for pushing data to Google Sheets.
FS.h, SD.h Handle SD card file operations (read, write, append) using the SPI interface.
Wire.h, SPI.h Standard I²C and SPI communication support for sensor and storage modules.

Innovation and Novelty

The Pocket Meteo Logger stands out by combining low-power environmental sensing with dual-mode data access — both local and cloud-based — in a fully self-contained, portable system. Unlike typical sensor boards that require tethering to a computer or smartphone, this project offers:

  • Offline autonomy – the user can browse historical measurements directly on the OLED screen using buttons, even in remote areas without internet or mobile devices.
  • Smart cloud syncing – the ESP32 automatically attempts to connect to Wi-Fi in the background and uploads data to a Google Sheet only when the network is reachable.
  • Dynamic alerts – critical readings trigger both LED and buzzer warnings, based on adjustable thresholds, without external supervision.
  • Complete user feedback loop – no external app or debugging cable is needed to confirm system health or data quality.

This design encourages users to rely on the device independently during field trips, while still benefiting from remote data access when returning to Wi-Fi zones. The blend of real-time display, onboard storage, and opportunistic cloud sync makes the project unique and practical.

Project Architecture

The project is structured into distinct software modules, each responsible for a critical task, and they interact based on a precise, low-power runtime cycle. Below is a summary of how these modules cooperate within the firmware:

1. Initialization Phase (“setup()”):

  • Initializes peripherals: BME680 sensor, OLED display, SD card module, Wi-Fi module, buzzer and LEDs.
  • Sets pin modes for the three tactile buttons.
  • Loads existing data from the microSD card into memory.
  • Attempts to connect to Wi-Fi if available, without blocking operation.

2. Main Execution Loop (“loop()”):

  • Checks if the user toggled history mode using the Enter button.
  • If in history mode:
    • Navigates through the data file using the Next and Previous buttons.
    • Displays old readings stored on the SD card without contacting any external server.
  • If in live mode:
    • Waits for a 30-second interval to trigger a new reading.
    • Fetches environmental data from the BME680 sensor.
    • Displays the new reading on the OLED screen.
    • Logs the data on the SD card in CSV format.
    • If Wi-Fi is connected, pushes the reading to a linked Google Sheets document.
    • If any value is outside acceptable thresholds, activates the red LED and buzzer.

3. Module Interaction:

Module Triggered By Output / Action
“tryConnectWiFi()” Called regularly in loop Attempts to connect to Wi-Fi every 4 minutes. Updates connection state.
“performReading()” Timer (every 30s) Collects fresh values from the sensor.
“sendDataToGoogleSheets()” Only if Wi-Fi is active Sends reading to Google Sheets via HTTP POST.
“appendToSD()” After every reading Saves current reading as a new line in data.txt.
“display.printf()” After reading or history nav Displays current or historical reading on the OLED.
Buzzer & LEDs After threshold check Triggers audio/visual alerts if needed.

4. Power and Efficiency:

  • The system avoids Wi-Fi delays when offline by only attempting reconnection at safe intervals.
  • No part of the firmware blocks the main loop or interrupts the user interface.
  • The OLED and buzzer are only active during updates or alerts.

Sensor Calibration

To ensure accurate, stable, and energy-efficient measurements, the firmware performs several calibration-related operations for both sensor input and user interaction:

BME680 Sensor Calibration

The BME680 sensor includes internal calibration for temperature, humidity, and pressure. However, certain steps were taken to further ensure reliable operation:

  • Temperature & Pressure

The sensor uses factory calibration coefficients. No external adjustments were needed.

Oversampling was set to `8x` for temperature and `4x` for pressure to improve accuracy while maintaining power efficiency.

  • Humidity

The sensor was allowed to stabilize for several seconds after boot to avoid inaccurate early readings.

Oversampling set to `2x` provides a good tradeoff between noise reduction and sampling speed.

  • Gas Resistance

A burn-in phase was performed during initial power-on (~5–10 minutes) to let the sensor reach a stable baseline.

Gas heater settings were chosen as `320°C for 150 ms`, a commonly recommended configuration for general air quality monitoring.

  • Altitude

Calculated using the barometric formula and a reference sea-level pressure of `1013.25 hPa`.

For local deployments, this value can be adjusted manually in code.

  • Digital Filtering

The sensor’s internal IIR filter was set to `Size 3` to smooth out short-term fluctuations and reduce noise in the readings.

All readings were validated by comparing output with a trusted online weather API and a commercial indoor weather station.

Button Input Calibration (Debouncing)

To ensure smooth and responsive interaction via physical buttons, software debouncing was implemented:

  • Each button press is followed by a short `delay(200)` to ignore spurious transitions caused by mechanical bouncing.
  • An additional `delay(500)` is added after entering or exiting history mode to prevent accidental mode toggling due to long presses or bounce artifacts.
  • All buttons are configured using `INPUT_PULLUP` to reduce component count and avoid the need for external resistors.

Debouncing is critical to avoid interpreting a single button press as multiple inputs, which could break navigation logic or mode switching.

Display Validation

The OLED display refreshes every 30 seconds in live mode and immediately when browsing the history. To ensure clarity:

  • Text is aligned using fixed-width fonts and consistent cursor positioning.
  • The screen is cleared on each update to avoid overlapping values.
  • Long messages (e.g., “Returning to live mode”) are displayed with brief delays to ensure they are visible before being overwritten.

Optimizations and Lab Feature Justification

Throughout the development of Pocket Meteo Logger, several optimizations were implemented to improve responsiveness, memory usage, and energy efficiency. These were guided by embedded systems best practices and reinforced by concepts learned in lab sessions.

Code-Level Optimizations

  • Modular structure:

The firmware was split into logical modules (WiFi handler, sensor reader, display manager, SD logger), making the code more maintainable and easier to debug or extend.

  • Non-blocking design:

Except for sensor reads and OLED refresh, the code avoids long blocking delays. Delays used for debouncing are minimal and only applied when user input is detected.

  • Efficient data formatting:

Instead of using String concatenation heavily, “String.printf()” and pre-sized buffers were used to format sensor values efficiently for display and storage.

  • Selective updates:

OLED is only refreshed when values change (every 30 seconds in live mode or on navigation input in history mode). This reduces I²C bus traffic and extends display lifespan.

Hardware-Level Optimizations

  • Low-power display and sensors:

The OLED and BME680 were chosen specifically for their ultra-low power consumption in idle/sleep modes.

  • Pull-up input configuration:

Buttons were configured with “INPUT_PULLUP”, reducing the need for external components and avoiding floating states.

  • Sleep-ready architecture (future work):

The codebase is already structured in a way that allows integration of ESP32’s deep sleep, where wake-up would occur either on timer or button press — this was not finalized for Milestone 3, but planned for future work.

Lab Concept Usage Justification

  • I²C Communication:

Used to interface both the BME680 sensor and the OLED display, showcasing mastery of multi-device I²C bus sharing.

  • SPI Communication:

Utilized for microSD storage access, demonstrating correct SPI peripheral configuration and file system interaction using the FS and SD libraries.

  • External Interrupts / GPIO Input:

Buttons were read via GPIO with debouncing logic, inspired by interrupt handling labs.

  • Modular design & FSM concepts:

The user interface (UI handler) is implemented as a state machine with transitions between live mode and history browsing — similar to the FSM examples studied during labs.

These design decisions allowed the device to remain responsive, accurate, and power-aware while maintaining a clean software architecture and lab-aligned implementation.

Demo Video

The video shows:

  • The Pocket Meteo Logger starting up and displaying the welcome message on the OLED screen
  • Live environmental readings being updated every 30 seconds (temperature, pressure, humidity, gas, altitude)
  • Automatic LED and buzzer alerts being triggered when sensor values exceed predefined thresholds
  • Storing readings to the microSD card in CSV format
  • Uploading data to Google Sheets when Wi-Fi is available
  • Switching between live mode and history mode using the tactile buttons
  • Browsing through past logged data directly on the OLED using previous/next buttons
  • Buzzer activation for 4 seconds when alert conditions are detected
  • Debounce logic for clean button input handling

Conclusions

The Pocket Meteo Logger proved to be a successful and rewarding project that combined both hardware and software components into a functional and reliable embedded system. It managed to accurately read environmental data such as temperature, humidity, pressure, and air quality, display live values on the OLED screen, store logs on a microSD card, and upload measurements to Google Sheets when Wi-Fi was available. The logic for alerts and user interaction through buttons worked as intended, making the device easy to use and responsive even in offline mode.

I really enjoyed working on this project, especially solving real-world problems like limited power, network instability, and sensor calibration. It helped me better understand the challenges of embedded system development and gave me confidence to explore more advanced IoT applications in the future.

Download

Bibliography/ Resources

pm/prj2025/eradu/andrei_rares.duca.txt · Last modified: 2025/05/25 13:50 by andrei_rares.duca
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0