Last week I inquired about guidance in writing real-time data to an OLED and there appeared to be little around. This program successfully does that
It also can record the data in the Serial Monitor
Opening port
Port open
------------------------------------
Temperature
Sensor: DHT22
Driver Ver: 1
Unique ID: -1
Max Value: 125.00°C
Min Value: -40.00°C
Resolution: 0.10°C
------------------------------------
------------------------------------
Humidity
Sensor: DHT22
Driver Ver: 1
Unique ID: -1
Max Value: 100.00%
Min Value: 0.00%
Resolution: 0.10%
------------------------------------
==============================
Running firstWeatherReport.ino
==============================
Current humidity = 888.8%
Current temperature = 88.8°C
Current temperature = 88.8°F
Current humidity = 63.7%
Current temperature = 27.1°C
Current temperature = 80.8°F
Current humidity = 63.7%
Current temperature = 27.1°C
Current temperature = 80.8°F
Current humidity = 63.9%
Current temperature = 27.1°C
Current temperature = 80.8°F
or write it to an Excel Spreadsheet using the PLX-DAQ macro.
If you log to SD it helps to start every line with a time-stamp in ASCII hex which can be read into binary quick (interpreting decimal to binary takes way longer) and always takes 8 chars, the lines left-justify evenly on hex time stamps. With Arduino, the time can be microseconds if desired and you can cover > 1 hour intervals.
Logging milliseconds is great for tracing out system faults, if every action is time-stamp logged.
Log in comma separated text with a newline (decimal 10) at the end of every line. Close the file at the end of every line to update the SD FAT (file allocation table) so that interruption won't lose the data then reopen the file and continue logging.
What spreadsheet won't take CSV text?
The thing to watch out for is verbose logging choking the serial output buffer which does lead to blocking.
Easiest way to forestall and minimize that is by using the highest Serial speed possible to empty the buffer quickest.
I think that the IDE holds versions of the SPI and SD libraries compatible with itself.