Projects / Morning temperature tracker

Morning temperature tracker

Intermediate2 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. NANOTMP11722.0°C

    Test the sensor

    Print the temperature to serial.

  2. NANO

    Add the clock

    Set the date and time.

  3. NANO

    Take a reading

    Average a minute on button press.

  4. NANO

    Store one value a day

    Save to EEPROM.

  5. NANO

    Draw the chart

    Plot the last 40 days.

  6. NANO

    Add the wipe

    Hold for 5 seconds to clear.

  7. NANO

    Build the probe

    Seal the sensor in a cleanable housing.

In short

How do you build a morning temperature tracker?

A precise thermometer logs your waking temperature each morning and charts the trend privately on the device. You need Arduino Nano, TMP117 precision temperature sensor, SSD1306 OLED Display, Tactile push button 6 mm and DS3231 RTC module. It takes 7 steps and about 120 minutes.

Level
Intermediate
Time
About 120 min
Parts
5

Parts list

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

Wiring

FromToWhy
TMP117 VCC and GNDNano 3V3 and GNDPower
TMP117 SDA and SCLNano A4 and A5I2C
OLED VCC, GND, SDA, SCLNano 5V, GND, A4, A5Shares the I2C bus
DS3231 VCC, GND, SDA, SCLNano 5V, GND, A4, A5Shares the I2C bus
ButtonNano D2 and GNDTake a reading (hold 5 seconds to wipe all data)

Code

The TMP117 is accurate to about 0.1 °C, which is what a waking-temperature chart needs. The sketch averages 60 seconds of readings, stores one value a day in the Nano's own memory, and draws the last 40 days on the screen. Nothing is sent anywhere: the data lives only on the device, and holding the button for 5 seconds wipes it. This is a personal tracking tool and not a medical device. It must not be used as contraception or to diagnose anything, and any health concern should be discussed with a doctor. Measure the same way at the same time each morning, and use the sensor in a sealed, cleanable probe made for body contact (an armpit measurement is the safest for a home build); never put a bare circuit board in the mouth. Run it from a USB supply or a small battery pack, not from the mains. Arduino IDE, board "Arduino Nano" (try the Old Bootloader option if the upload fails).

Runs on a virtual Arduino Nano 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).

// Morning temperature log. Libraries: Adafruit TMP117, Adafruit SSD1306, Adafruit GFX, RTClib, EEPROM. Board: Arduino Nano.
#include <Wire.h>
#include <EEPROM.h>
#include <Adafruit_TMP117.h>
#include <Adafruit_SSD1306.h>
#include <RTClib.h>

Adafruit_TMP117 tmp; Adafruit_SSD1306 oled(128, 64, &Wire, -1); RTC_DS3231 rtc;
const int BTN = 2, DAYS = 40;                      // EEPROM layout: byte 0 = next slot, byte 1-2 = last day number, then DAYS x int16 (temperature x 100)
int nextSlot = 0; long lastDay = -1;

long dayNumber(DateTime t) { return t.unixtime() / 86400L; }

void saveValue(float c) {
  int16_t v = (int16_t)(c * 100);
  EEPROM.put(3 + nextSlot * 2, v);
  nextSlot = (nextSlot + 1) % DAYS; EEPROM.update(0, nextSlot);
}

void chart() {
  oled.clearDisplay();
  float lo = 99, hi = 0; int n = 0;
  float vals[DAYS];
  for (int i = 0; i < DAYS; i++) {
    int16_t v; EEPROM.get(3 + ((nextSlot + i) % DAYS) * 2, v);
    if (v > 3000 && v < 4500) { vals[n++] = v / 100.0; }
  }
  for (int i = 0; i < n; i++) { lo = min(lo, vals[i]); hi = max(hi, vals[i]); }
  if (n < 2) { oled.setCursor(0, 20); oled.print("Not enough days yet"); }
  else for (int i = 1; i < n; i++) {
    int x1 = (i - 1) * 127 / (DAYS - 1), x2 = i * 127 / (DAYS - 1);
    int y1 = 54 - (vals[i - 1] - lo) / (hi - lo + 0.05) * 40, y2 = 54 - (vals[i] - lo) / (hi - lo + 0.05) * 40;
    oled.drawLine(x1, y1, x2, y2, SSD1306_WHITE);
  }
  oled.setCursor(0, 56); oled.print(lo, 2); oled.print(" - "); oled.print(hi, 2); oled.print(" C  "); oled.print(n); oled.print("d");
  oled.display();
}

void setup() {
  pinMode(BTN, INPUT_PULLUP);
  tmp.begin(); rtc.begin();
  oled.begin(SSD1306_SWITCHCAPVCC, 0x3C); oled.setTextColor(SSD1306_WHITE);
  nextSlot = EEPROM.read(0); if (nextSlot >= DAYS) nextSlot = 0;
  EEPROM.get(1, lastDay);
  chart();
}

void loop() {
  if (!digitalRead(BTN)) {
    unsigned long t0 = millis();
    while (!digitalRead(BTN) && millis() - t0 < 5000) {}
    if (!digitalRead(BTN)) {                               // held 5 seconds: wipe everything
      for (int i = 0; i < 3 + DAYS * 2; i++) EEPROM.update(i, 0xFF);
      nextSlot = 0; lastDay = -1; chart(); while (!digitalRead(BTN)) {} return;
    }
    oled.clearDisplay(); oled.setCursor(0, 20); oled.print("Measuring, stay still..."); oled.display();
    float sum = 0; int n = 0;
    for (int i = 0; i < 90; i++) { sensors_event_t t; tmp.getEvent(&t); if (i >= 30) { sum += t.temperature; n++; } delay(1000); }   // 90 s, use the last 60
    float c = sum / n;
    long today = dayNumber(rtc.now());
    if (today != lastDay) { saveValue(c); lastDay = today; EEPROM.put(1, lastDay); }
    oled.clearDisplay(); oled.setTextSize(2); oled.setCursor(0, 20); oled.print(c, 2); oled.print(" C"); oled.setTextSize(1); oled.display();
    delay(3000); chart();
  }
}

Test checklist

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

CheckExpected
Press the buttonReading in about 90 seconds
Press again the same dayNot stored twice
After several daysChart appears
Hold 5 secondsAll data wiped

If it does not work

Reading looks low

Wait longer for the sensor to settle, keep it in contact.

Chart is empty

It needs at least two days of data.

Wrong date

Set the RTC and replace its coin cell.

Values jump

Use the same position every morning.

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

Ask Lark AI

Common questions

What parts do I need for the morning temperature tracker?

Arduino Nano, TMP117 precision temperature sensor, SSD1306 OLED Display, Tactile push button 6 mm and DS3231 RTC module.

How long does the morning temperature tracker take to build?

About 120 minutes for a intermediate maker, in 7 steps.

How do I know the morning temperature tracker works?

Press the button: Reading in about 90 seconds. Press again the same day: Not stored twice. After several days: Chart appears.

Reading looks low: what should I check?

Wait longer for the sensor to settle, keep it in contact.

Chart is empty: what should I check?

It needs at least two days of data.

Wrong date: what should I check?

Set the RTC and replace its coin cell.

Values jump: what should I check?

Use the same position every morning.