Temperature Data Logger with Raspberry Pi Pico
Objective
- Save the data into the Raspberry Pi Pico
- Plot the saved data using Jupyter Notebook and Matplotlib
Reading the temperature data from the Raspberry Pi Pico is great however in the science world we will require to save the data to analyze it. Imagine you will place a temperature sensor inside a chemical reactor. With this data, you can analyze the behavior of the process and predict what is happening.
Temperature Data Logger for Solar Cell fabrication
There are two interesting places where I can use this data logger
- To know the temperature inside the chemical bath deposition. In the first stage we can track the chemical deposition temperature profile and after the analysis we could start controlling the chemical reaction by programming the temperature profile. Remeber that in some chemical deposition (metal chalcogenides) the reaction start just after passing a critical temperature point.
- Track and controll the crystallation process of the metal chalcogenides. After the chemical deposition of some metal chalcogenides thin films. For example we will require to anneal them in air or nitrogen atmosphere. Here we usually do no track the heating process. Therefore the temperature datalogger will help to get that data. However, in this application we will require additional components because the crystallization required from 300-400 ºC . That means we need a temperature sensor which supports almost 450 ºC. (J or K Thermocouples).
Temperature Data Logger with Raspberry Pi Pico
For this application, we are going to read the internal temperature sensor of our Raspberry Pi Pico and write the information on the same board. This example will show you the power of the Raspberry for measuring external physical properties like temperature (using sensors) and saving it for future analysis. In the following picture, you can see the basic connection.
- This example is based on the following Circuit Python tutorial, Data Logger: https://learn.adafruit.com/getting-started-with-raspberry-pi-pico-circuitpython/data-logger

Materials
- Raspberry Pi Pico
- Breadboard
- Male to male jumper wire
The circuit
- The jumper wire connects the Pin1 to Pin8 in other words we will connect GP0 to GND

The code
With the following codes (files), you will be able to save the temperature in the Pico board when the jumper wire is connected to the ground. If the jumper is not connected the PICO board won’t save the data.
File 01: boot.py
This code tells the Pico Board to look at the star if the GP0 (Pin1) is connected to GND. If it is true boot.py makes the board writeable on its own filesystem.
""" boot.py file for Pico data logging example. If pin GP0 is connected to GND when the pico starts up, make the filesystem writeable by CircuitPython. """ import board import digitalio import storage write_pin = digitalio.DigitalInOut(board.GP0) write_pin.direction = digitalio.Direction.INPUT write_pin.pull = digitalio.Pull.UP """ If write pin is connected to ground on start-up, CircuitPython can write to CIRCUITPY filesystem. """ if not write_pin.value: storage.remount("/", readonly=False)
File 02: code.py
This is the same code found on the page of Adafruit Circuit Python here we are reproducing and testing it. Just copy and paste it into the code.py
- It will only work when you disconnect the Pico Board from your computer, connect GP0 to GND and connect againg the board to 5V (computer or an adaptar).
- Inmediatly you will see a blinking led indicating this program is working, internally you will find a temperature.txt file with the temperature data.
IMPORTANT: You need to disconnect the jumper wire before disconnecting the board from the energy source (USB or battery charger). This way you won’t corrupt the Pico Board system.
""" Data logging example for Pico. Logs the temperature to a file on the Pico. https://learn.adafruit.com/getting-started-with-raspberry-pi-pico-circuitpython/data-logger """ import time import board import digitalio import microcontroller led = digitalio.DigitalInOut(board.LED) led.switch_to_output() try: with open("/temperature.txt", "a") as datalog: while True: # When Datalogger is working This is the working Cycle temp = microcontroller.cpu.temperature datalog.write('{0:f}\n'.format(temp)) datalog.flush() led.value = not led.value time.sleep(1) except OSError as e: # Typically when the filesystem isn't writeable... delay = 0.5 # ...blink the LED every half second. if e.args[0] == 28: # If the filesystem is full... delay = 0.25 # ...blink the LED faster! while True: # When Datalogger is not working This is the working Cycle temp = microcontroller.cpu.temperature temp = round(temp,2) print(f"T = {temp} ºC") led.value = True time.sleep(0.5) led.value = False time.sleep(0.5)
""" Data logging example for Pico. Logs the temperature to a file on the Pico. https://learn.adafruit.com/getting-started-with-raspberry-pi-pico-circuitpython/data-logger """ import time import board import digitalio import microcontroller led = digitalio.DigitalInOut(board.LED) led.switch_to_output() try: with open("/temperature.txt", "a") as datalog: while True: # When Datalogger is working This is the working Cycle temp = microcontroller.cpu.temperature datalog.write('{0:f}\n'.format(temp)) datalog.flush() led.value = not led.value time.sleep(1) except OSError as e: # Typically when the filesystem isn't writeable... delay = 0.5 # ...blink the LED every half second. if e.args[0] == 28: # If the filesystem is full... delay = 0.25 # ...blink the LED faster! while True: # When Datalogger is not working This is the working Cycle temp = microcontroller.cpu.temperature temp = round(temp,2) print(f"T = {temp} ºC") led.value = True time.sleep(0.5) led.value = False time.sleep(0.5)
Real evidence – Video
If you want to see the data logged first click play to the video then in the next section you will be able to download the temperature.txt file.
The logged Data
This time I will provide you with the data I was able to measure with the internal temperature sensor of the Pico Board. If you want to save a day measuring temperature, then just download the following .txt file. This file has a measure of temperature during a whole day starting a 10 PM.