Environmental Content Server

Air Quality & Noise Analysis

  • Reports
  • Blog
  • About
  1. Home
  2. Blogs
  3. Writing to the same place ain't good .

Writing to the same place ain't good .

May 25, 2026 blog Environmental Monitor

So after my old weather sensor stopped working , i built a new one which has now evolved over time . I’ll cover that evolution in further blogs . I am now using an old raspberry pi zero mk 1 with the Enviro+ board from Pimironi , it includes the PM2.5 sensor and allows me to capture all standard weather details , plus sound etc .

CA4EFBDF-CF8C-4241-80A4-45FA7C9B22A7_1_105_c.jpeg

I used a simple enclosure and put it in the same location . Sadly no wind direction or speed but still this has worked for over a year and pants it gave up the ghost . To be more specific it was the SD card that due to writing in the same location has worn out . The solution still uses sqlite and a combination of python processes , the device records on a regular basis , but over 12+ months the SD card struggles so the code has been changed .

IMG_1583.jpeg

The logger reads sensors every second and writes each reading immediately to a SQLite database. In the default SQLite configuration, every single INSERT triggers a full fsync() — a call that forces the operating system to flush all pending writes from RAM to the physical SD card. This isn’t just one write per reading; SQLite’s default journal mode creates, writes and deletes a temporary journal file alongside every transaction, multiplying the actual number of write operations significantly.

SD cards have a finite number of write cycles per memory cell (typically 3,000–10,000 for consumer cards). With one fsync per second, 24 hours a day, the math was brutal. The cells in the most-written sectors — the SQLite journal area — simply ran out of write cycles in under a year. So i addressed this using SQLite WAL Mode. I switched from SQLite’s default journal mode to Write-Ahead Logging (WAL) . Rather than committing each sensor reading to disk individually, it accumulates rows in memory and flush in batches of 10 . This alone eliminates a significant background write load that most people don’t think about.Benchmarking before and after showed approximately 165x fewer fsyncs with all three changes in place. A workload that previously generated ~86,400 fsyncs per day now generates around 500. The SD card will last years instead of months.

However my new device did capture a neighbours bonfire which exceeded acceptable air limits , more in the next blog.

2321FBA5-FFBA-4A2D-925A-855C13169036_1_105_c 1.jpeg

Table of Contents

Recent Posts

  • Environmental Analysis — Sample — 20 May 2026, 18:21–21:20 May 20, 2026
  • Environmental Analysis — Sample — 15 Apr 2026, 06:36–07:02 Apr 15, 2026
  • Environmental Analysis — Sample — 71d887a3 Apr 3, 2026
  • Environmental Analysis — Sample — 22 Feb 2026, 14:24–15:18 Feb 22, 2026
  • Environmental Analysis — Sample — 12 Feb 2026, 01:46–23:50 Feb 12, 2026

Categories

  • Environmental Analysis13
  • Blog3

Tags

  • Air-Quality
  • Ammonia
  • Environmental-Analysis
  • Location-Mapping
  • Noise
  • Particulate-Matter
← 10 Year of Weather Readings Bonfires →

Related Posts

  • Bonfires May 30, 2026
  • 10 Year of Weather Readings May 21, 2026
Powered by Hugo & Explore Theme.