Projects / Newton cooling curve lab

Newton cooling curve lab

Log a cup of warm water as it cools and fit a cooling curve.

Beginner2.5 hGuided buildReviewed

Build it step by step

0 of 8 done
  1. UNODS18B2028.9°C

    Wire the probe

    Red to 5V, black to GND, yellow to D2 with a 4.7 kilohm pull-up.

  2. UNO

    Wire the display and button

    I2C on A4 and A5, button on D3 to GND.

  3. UNO

    Upload the sketch

    The display reads the room temperature in air.

  4. UNO

    Warm some water

    Around 55 degrees, not boiling.

  5. UNODS18B2029.0°C

    Put the probe in the cup

    Then press the button.

  6. UNO

    Leave it for 20 minutes

    The display shows the temperature and the fitted k.

  7. UNO

    Copy the CSV from the serial monitor

    Plot temperature against time.

  8. UNO

    Repeat with a lid

    Compare the value of k.

In short

How do you build a newton cooling curve lab?

Log a cup of warm water as it cools and fit a cooling curve. You need Arduino Uno R3, DS18B20 waterproof probe, Resistor 4.7 kΩ, SSD1306 OLED Display, Tactile push button 6 mm and Breadboard 830 Tie Points. It takes 8 steps and about 150 minutes.

Level
Beginner
Time
About 150 min
Parts
6

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Probe red wireUno 5VPower
Probe black wireUno GNDGround
Probe yellow wireUno D2Data line
4.7 kilohmBetween D2 and 5VPull-up for the data line
OLED SDA and SCLUno A4 and A5I2C, address 0x3C
ButtonUno D3 to GNDStart logging

Code

Newton's law of cooling says a warm object loses heat at a rate proportional to how much warmer it is than the room, so its temperature difference falls off exponentially: T minus room equals A times e to the power of minus k t. Taking the natural logarithm of the difference turns that curve into a straight line whose slope is minus k, so the sketch fits a straight line to the logged values and shows k, the cooling rate per minute. First it measures the room temperature with the probe in air, then you put the probe in a cup of warm water and press the button. Use water around 50 to 60 degrees, not boiling, and handle the cup with care; get an adult to help with hot water. The sensor logs one reading every 30 seconds for up to half an hour. Compare k for an open cup, a cup with a lid and a cup wrapped in a towel, which should show a smaller k. The waterproof probe is accurate to about half a degree, so use the same probe for every run.

Runs on a virtual Arduino Uno in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <OneWire.h>
#include <DallasTemperature.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

OneWire bus(2);
DallasTemperature probe(&bus);
Adafruit_SSD1306 oled(128, 64, &Wire, -1);

const int START_BTN = 3;
const unsigned long INTERVAL_MS = 30000;      // one reading every 30 seconds
const int MAXN = 60;                          // up to 30 minutes

float roomC = 0;
float tMin[MAXN], tC[MAXN];
int n = 0;
bool logging = false;
unsigned long lastSample = 0, t0 = 0;

float readC() { probe.requestTemperatures(); return probe.getTempCByIndex(0); }

void show(const char* a, const char* b = "") {
  oled.clearDisplay(); oled.setCursor(0, 0);
  oled.println(a); oled.println(b); oled.display();
}

// Fit ln(T - room) = ln(A) - k t by least squares, k in 1/minute
float fitK() {
  float sx = 0, sy = 0, sxx = 0, sxy = 0; int m = 0;
  for (int i = 0; i < n; i++) {
    float d = tC[i] - roomC;
    if (d < 1.0) continue;
    float x = tMin[i], y = log(d);
    sx += x; sy += y; sxx += x * x; sxy += x * y; m++;
  }
  if (m < 4) return 0;
  return -((m * sxy - sx * sy) / (m * sxx - sx * sx));
}

void setup() {
  Serial.begin(9600);
  pinMode(START_BTN, INPUT_PULLUP);
  probe.begin();
  oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  oled.setTextColor(SSD1306_WHITE); oled.setTextSize(1);

  show("Probe in air...", "reading room temp");
  float sum = 0;
  for (int i = 0; i < 5; i++) { sum += readC(); delay(1000); }
  roomC = sum / 5;
  char buf[24]; dtostrf(roomC, 4, 1, buf);
  show("Room temp C", buf);
  Serial.print("# room C "); Serial.println(roomC, 2);
  delay(2000);
  show("Put probe in warm", "water, press button");
  Serial.println("minutes,celsius");
}

void loop() {
  if (!logging && digitalRead(START_BTN) == LOW) {
    logging = true; t0 = millis(); lastSample = 0; n = 0; delay(300);
  }
  if (logging && (n == 0 || millis() - lastSample >= INTERVAL_MS) && n < MAXN) {
    lastSample = millis();
    float c = readC();
    float minutes = (millis() - t0) / 60000.0;
    tMin[n] = minutes; tC[n] = c; n++;
    Serial.print(minutes, 2); Serial.print(','); Serial.println(c, 2);
    char line1[24], line2[24];
    dtostrf(c, 4, 1, line1);
    float k = fitK();
    dtostrf(k, 5, 3, line2);
    oled.clearDisplay(); oled.setCursor(0, 0);
    oled.print("T "); oled.print(line1); oled.println(" C");
    oled.print("k "); oled.print(line2); oled.println(" /min");
    oled.print("n "); oled.println(n);
    oled.display();
  }
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Probe in airRoom temperature near 20 to 30 C
Probe in warm waterStarts near 55 C
After 10 minutesSeveral degrees lower
Lidded cupSmaller k than an open cup
Fit with fewer than 4 pointsk shows zero

If it does not work

Reads -127

The probe is not wired or the pull-up is missing.

Reads 85

A power-on default, check the 5V wire and the pull-up.

k looks negative

Room temperature was wrong, restart in air.

Display blank

Check I2C address 0x3C.

Curve is noisy

Keep the probe still and out of draughts.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the newton cooling curve lab?

Arduino Uno R3, DS18B20 waterproof probe, Resistor 4.7 kΩ, SSD1306 OLED Display, Tactile push button 6 mm and Breadboard 830 Tie Points.

How long does the newton cooling curve lab take to build?

About 150 minutes for a beginner maker, in 8 steps.

How do I know the newton cooling curve lab works?

Probe in air: Room temperature near 20 to 30 C. Probe in warm water: Starts near 55 C. After 10 minutes: Several degrees lower.

Reads -127: what should I check?

The probe is not wired or the pull-up is missing.

Reads 85: what should I check?

A power-on default, check the 5V wire and the pull-up.

k looks negative: what should I check?

Room temperature was wrong, restart in air.

Display blank: what should I check?

Check I2C address 0x3C.