officeAir - A temperature and Humidity Meter and Google Sheet Logger with Raspberry Pi / ESP32 and I2C sensors
This project lets you log temperature and humidity data via Raspberry Pi and a sensor easily and automated way into you google sheet, collecting the raw data and automatically drawing a nice chart as data coming in. (The name and use case comes from life: initially we set this up to monitor DecentLabs office climate in a hot summer period, when air conditioning had some weakness.)
Code by: RΓ³bert SzalΓ³ki, Hardware configuration and manual by: Zoltan DΓ³czi (RFsparkling), Licensed by DecentLabs
First lets see the Google sheet and its script side to prepare that before Raspberry pi configurations.
Here are two charts for temperature and humidity for several days:
And this is how the raw data looks like:
Let's see how to configure RPi and google sheet scripts and web app deploy to enable this "data flow gateway".
or you can download the script code file too from the repo here
3. copy that link (the most important thinkg) which needs to be paste in the future steps into the Rapsberry Pi code (see below in step 8). This key makes a "link" between the RPi and the Google web app server, thus the data will be uploded into the right place: your google sheet.
After the google sheet configuration now see what configuration we need to do under the hood of Raspberry Pi:
sudo raspi-config
sudo apt update
sudo apt upgrade
sudo apt install i2c-tools
sudo i2cdump -y 1 64
#should look like somthing like this:

sudo mkdir /usr/local/bin/log
cd /usr/local/bin/log
sudo nano log
#/bins/sh
DATA=`sht21.py`
curl -L "https://script.google.com/macros/s/**copy your Google script deployed web app key here**/exec?$DATA"
sudo chmod +x log
cd /usr/local/bin/
sudo wget https://raw.githubusercontent.com/DecentLabs/officeAir/master/sht21.py
sudo chmod +x sht21.py
sudo nano /etc/crontab
* * * * * root /usr/local/bin/log/log #log air quality
Finally reboot the RPi, once it comes back it should report temperature and humidity values every minute to the google sheet
sudo reboot
This subdirectory contains a complete C++ (Arduino framework) port of the original Raspberry Pi Python project. It migrates the climate logging system to an ESP32 microcontroller (specifically optimized for the Heltec WiFi LoRa 32 V3 board), maintaining 100% backward compatibility with the existing Google Apps Script and Google Sheets backend.
| Feature | Original Version (Raspberry Pi) | Upgraded Version (ESP32) |
|---|---|---|
| Hardware | Raspberry Pi (Single Board Computer) | ESP32-S3 (Heltec WiFi LoRa 32 V3) |
| Language | Python (sht21.py) + Bash script |
C++ (Arduino / PlatformIO) |
| Power Consumption | High (~2W to 5W), always-on | Ultra-low (Micro-amps) via Deep Sleep |
| I2C Protocol | Linux /dev/i2c-1 system calls |
Hardware I2C via Wire library |
| HTTP Requests | Native curl -L CLI command |
HTTPClient with strict redirect following |
| Form Factor | Large, requires robust 5V power supply | Compact, battery/solar friendly, runs on Micro-USB/Type-C |
-
Power Management & Deep Sleep: Unlike the Raspberry Pi which must run 24/7, the ESP32 wakes up, connects to Wi-Fi, reads the sensor, pushes the data to Google Sheets, and immediately enters Deep Sleep for 10 minutes. Additionally, it utilizes the Heltec V3's onboard
Vextpower switch (GPIO 36) to completely cut off power to the external I2C sensor rail during sleep, minimizing standby current draw. -
Custom I2C Pinout: The SHT21 sensor has been mapped to custom I2C pins appropriate for clean prototyping on the Heltec V3 board:
- SDA: GPIO 41
- SCL: GPIO 42
-
Google Web App Redirection Handling: Google Apps Script URLs automatically trigger a HTTP 302 Redirect. The ESP32 code is explicitly configured with
http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);to natively handle this behavior, ensuring successful payload delivery (returningHTTP 200 Ok).
esp32_version/
βββ platformio.ini # Project configuration, dependencies, and board definitions
βββ src/
βββ main.cpp # Main C++ source code (Wi-Fi, SHT21 driver, HTTP client, Deep Sleep)













