Arduino PM sensor system 2/3: sensor data on an SD card

In a series of three posts, I share my road towards a PM sensor system with help of Arduino and the SPS30 Sensirion PM sensor. This second post: storing the data on an SD card.

In the previous post I described how I got the sensor data on my computer. Preferably, measurements are done without continuously having a computer around. I wanted to add local data storage to the sensor system with a memory (micro SD) card.

1 Materials

Next to the setup part 1 materials, I bought the following materials:

I found out that for a memory card, it was better to have a relatively small card (< 1GB). Furthermore, after running into battery failure of the real-time clock multiple times, I learned that the DS3231 charging system could destroy non-rechargeable batteries. To resolve this, the charging circuit had to be disabled (for example by removing resistor 201 from the DS3231 shield).

2 Software

Both the real-time clock and the SD card work with libraries that by default are included in the Arduino IDE installation. Additional software was not needed.

3 Connections

I made the following connections between the Aduino Mega and the SD and real-time clock modules:

SD module...Mega
GND.........GND
VCC.........5V
MISO........50
MOSI........51
SCK.........52
CS..........53

DS3231......Mega
GND.........GND
VCC.........5V
SDA.........SDA
SCL.........SCL

I also put the micro SD card in the SD module.

4 Sketch

I used the following sketches for the components:

In the below sketch, these are combined.

See sketch

5 Operation and next

After uploading the sketch to the Arduino board, it started to collect data and store it on the SD card. I could get the data from the SD card. This is already sufficient for many measurement projects, but online real-time data would be even nicer. Post three: adding LoRa functionality to the sensor system.