An Improved Specific Heat Lab – With Raspberry Pi

I’ve taught chemistry for about 15 years.  In that time, I have used the same experiment to ‘teach’ the heat capacity of a metal.  In short, we heat up metal, dump it in some measured amount of water, and measure the temperature change of the water.  I’ve done it for 15 years because it works, but I’ve been missing something.

So I decided to use the Raspberry Pi to use two DS18B20 waterproof sensors to measure the temperature of both the metal and the water, and plot them both.  This is the plot I got.

Look at that giant drop off in temperature for the Aluminum and the miniscule increase for the water.  The specific heat of Aluminum is about 0.900 J/gC, while water’s is 4.184 J/gC. With those values, I understand that Aluminum should lose heat quickly and water should gain it slowly.  Still, I was surprised by the shape of this graph.


  • Raspberry Pi with Raspian Jessie
  • 2 DS18B20 waterproof temperature probes
  • Metal sample
  • Connectors


  1. I drilled a hole in the Aluminum rod so a probe could be placed inside.
  2. The Aluminum (with the probe) was put into boiling water until its temperature leveled off.
  3. The hot Aluminum was put into 250mL of water with a measured temperature.
  4. A python program captured the temperature from both probes every 10 seconds and stored them in a Google Sheet.


The program used for this is quite simple.  It requires two DS18B20 waterproof probes.  This tutorial gives you the program for getting their temperatures.

The python program for recording the temperatures and storing the data in a Google Sheet are here.  There is a little bit of set-up required with Google, but there are good tutorials for that (GSpread and Datalogging).

The program I used is here.

import gspread
from oauth2client.service_account import ServiceAccountCredentials
from w1thermsensor import W1ThermSensor 
import datetime
import time

#Login information for Google Sheets using gspread 
scope = ['','']
creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json',scope)
client = gspread.authorize(creds)
sheet ="").sheet1 #Name of sheet between the quotes (ie "2Temp")

#Sensors.  You need the serial numbers of the sensors from /sys/bus/w1/devices
#The serial numbers are 28-xxxxxx.  Put the part after the 28- in the quotes in the lines below.
sensor1 = W1ThermSensor(W1ThermSensor.THERM_SENSOR_DS18B20, "") #First sensor
sensor2 = W1ThermSensor(W1ThermSensor.THERM_SENSOR_DS18B20, "") #Second sensor

def elapse_time(): #counts time in seconds
  nowTime =
  seconds = nowTime - startTime
  seconds = int(seconds.total_seconds())
  return seconds

#infinite loop to get elapsed time and temperature and append them to a Google Sheet
while True:
  nowTime =
  T1 = sensor1.get_temperature()
  T2 = sensor2.get_temperature()
  values = [seconds,T1, T2]

Lines 1-5 include the necessary libraries.

Lines 8-11 provide the login information for Google Sheets.

Lines 15-16 define the sensors.

Lines 18-22 provides a method getting the number of seconds since the first reading (time elapsed).

Lines 25-32 reads the sensors, logs in to Google Sheets, and records data.  I have this as an infinite loop, but it could just as easily be a cron job, or an iterative loop.

Leave a Reply

Your email address will not be published. Required fields are marked *