Projects / Offline sensor recorder

Offline sensor recorder

Intermediate50 minGuided buildReviewed
ESP32 DevKitGPIO21GPIO22GPIO5GPIO18GPIO23GPIO19BME280min,temp,hum,hPa41,26,50,1008log.csv
Serial at 115200 baud

Tap a part to see what it does.

Tap the parts to see what each one does. A teaching simulation, not a circuit simulator.

Build it step by step

0 of 4 done
  1. ESP32BME28029.9°C

    Wire the BME280

    SDA 21, SCL 22, 3V3, GND.

  2. ESP32

    Wire the SD module

    CS 5, SCK 18, MOSI 23, MISO 19.

  3. ESP32MICROS

    Prepare the card

    Format FAT32 and insert.

  4. ESP32

    Run and collect

    Leave it for a day, then open log.csv on a computer.

In short

How do you build an offline sensor recorder?

An ESP32 logs temperature, humidity and pressure from a BME280 to a microSD card every minute, with no Wi-Fi needed, ready to open in a spreadsheet. You need ESP32 DevKit V1, BME280 Environmental Sensor, MicroSD Card Module and Breadboard 830 Tie Points. It takes 4 steps and about 50 minutes.

Level
Intermediate
Time
About 50 min
Parts
4

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
BME280 SDA / SCLGPIO21 / GPIO22I2C
BME280 VIN / GND3V3 / GNDPower
SD CS / SCK / MOSI / MISOGPIO5 / 18 / 23 / 19SPI
SD VCC / GND5V (VIN) / GNDPower

Code

Libraries: Adafruit BME280 and the built-in SD. The first column counts minutes since power-on; add a DS3231 clock module if you need real dates.

Runs on a virtual ESP32 Dev Module in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <Adafruit_BME280.h>
#include <SD.h>
Adafruit_BME280 bme;
const int CS = 5;
unsigned long n = 0;

void setup() {
  Serial.begin(115200);
  if (!bme.begin(0x76)) Serial.println("BME280 not found");
  if (!SD.begin(CS)) { Serial.println("SD card not found"); return; }
  if (!SD.exists("/log.csv")) { File f = SD.open("/log.csv", FILE_WRITE); f.println("minutes,temp_c,humidity,pressure_hpa"); f.close(); }
}

void loop() {
  File f = SD.open("/log.csv", FILE_APPEND);
  if (f) {
    f.printf("%lu,%.2f,%.1f,%.1f\n", n, bme.readTemperature(), bme.readHumidity(), bme.readPressure() / 100.0);
    f.close();          // closing flushes to the card, so a power cut loses at most one line
    Serial.println("logged");
  } else Serial.println("write failed");
  n++;
  delay(60000);
}

What the serial monitor should show

Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual ESP32 Dev Module with its sensors at their default values. Your numbers will follow your real readings, but the format should match.

logged

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
After 5 minuteslog.csv has a header and 5 lines
Pull power mid-runFile still opens; at most the last line is missing
Breathe on the sensorHumidity jumps in the next line

If it does not work

"SD card not found"

Card not FAT32, wrong CS, or a 3.3 V-only module on 5 V.

Temperature a few degrees high

Sensor too close to the ESP32: move it away on wires.

Lines missing

Long delays while writing are normal; check the card is not full.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the offline sensor recorder?

ESP32 DevKit V1, BME280 Environmental Sensor, MicroSD Card Module and Breadboard 830 Tie Points.

How long does the offline sensor recorder take to build?

About 50 minutes for a intermediate maker, in 4 steps.

How do I know the offline sensor recorder works?

After 5 minutes: log.csv has a header and 5 lines. Pull power mid-run: File still opens; at most the last line is missing. Breathe on the sensor: Humidity jumps in the next line.

SD card not found: what should I check?

Card not FAT32, wrong CS, or a 3.3 V-only module on 5 V.

Temperature a few degrees high: what should I check?

Sensor too close to the ESP32: move it away on wires.

Lines missing: what should I check?

Long delays while writing are normal; check the card is not full.