Micro SD Card Module with temperature sensor

Data logging with the Raspberry Pi Pico W

This tutorial extends the tutorial of a temperature sensor with a display, and adds data logging to that. This can be realized by logging to an SD card, to the memory of the Raspberry Pi, or by logging to a website (via Wifi). The first part is logging to an SD card.

Part 1: Data logging to a microSD Card

First, create a temperature sensor with a display. This part of the tutorial adds logging the temperature and humidity to a CSV file on a microSD card to that.

Insert an sdcard in a microSD Card Adapter Module:

Connect the module:

Module pinRaspberry Pi Pico pin
CS (chip select)GPIO 17
SCK (serial clock)GPIO 18
MOSI (master out slave in)GPIO 19
MISO (master in slave out)GPIO 16
VCCVBUS (5V)
GND (ground)GND

Please note that we moved the signal wire of the temperature sensor and connected that to GP15! (it was on GP16 in the temperature sensor tutorial).

If you did not install MicroPython on the Raspberry Pi Pico yet, do so. Also install the Thonny editor (incl. Python). For details see the tutorial of the temperature sensor.

Install the sdcard and ssd1306 libraries (In Thonny, via Tools > Manage Packages):

Next, download and open the example Python file dht11_display_datalogger_sdcard.py in Thonny. Connect the Pico with the USB cable. Run the code.

If all goes well, it should start logging data to the card (check that in the Shell in Thonny).

After a while, unplug the USB cable. Extract the sdcard and plug it in your computer (or use a card reader). Check the file sdtest.csv, open it with a text editor, to view its contents.

More information:

Part 2: Data logging to a website (via Wifi)

[to come]

Part 3: Data logging to memory of Raspberry Pi

[to come]