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 .

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 .

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.
