Projects / Compost pile temperature monitor

Compost pile temperature monitor

Beginner1 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. NANODS18B2023.1°C

    Wire the probe

    DS18B20 on D2 with the 4.7 kΩ pull-up. Extend its cable if needed with the same three wires.

  2. NANOHelloPCF8574

    Wire the display

    LCD on A4 and A5.

  3. NANODS18B2023.2°C

    Test on the bench

    Hold the probe in warm water and watch the reading and the status text.

  4. NANODS18B2023.2°C

    Push the probe in

    Insert it into the middle of the pile, about 30 cm deep.

  5. NANODS18B2023.2°C

    Waterproof the box

    Keep the Nano and display dry under a cover.

  6. NANO

    Read daily

    Note the temperature and status. When it falls below 40 °C, turn the pile.

  7. NANO

    Count hot days

    The second line shows how long the pile has stayed in the hot range.

In short

How do you build a compost pile temperature monitor?

A long probe tracks the inside temperature of a compost pile to show when it is working hot and when it needs turning. You need Arduino Nano, DS18B20 waterproof probe, Resistor 4.7 kΩ, 16x2 LCD with I2C backpack (PCF8574), Battery holder 4 × AA with switch, AA alkaline battery × 4 and Jumper wires male to male (40 pcs, 20 cm). It takes 7 steps and about 60 minutes.

Level
Beginner
Time
About 60 min
Parts
7

Parts list

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

Wiring

FromToWhy
DS18B20 probe red, black, yellowNano 5V, GND, D2, with 4.7 kΩ from D2 to 5VProbe
LCD SDA and SCLNano A4 and A5Display
LCD VCC and GNDNano 5V and GNDSupply
4 AA packNano VIN and GNDBattery power

Code

Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). Install "OneWire", "DallasTemperature" and "LiquidCrystal I2C". The ranges are common compost guidance, where about 55 to 65 °C is good for killing weed seeds, and turning the pile helps when it cools. Totals reset when power is lost.

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).

#include <OneWire.h>
#include <DallasTemperature.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

OneWire oneWire(2);
DallasTemperature sensors(&oneWire);
LiquidCrystal_I2C lcd(0x27, 16, 2);
const unsigned long INTERVAL = 30UL * 60UL * 1000UL;     // every 30 minutes
unsigned long last = 0;
bool first = true;
unsigned int hotReadings = 0;
float peak = 0;

const char *status(float t) {
  if (t >= 65) return "Too hot: turn";
  if (t >= 55) return "Hot: good";
  if (t >= 40) return "Warm";
  return "Cool: turn it";
}

void setup() {
  sensors.begin();
  lcd.init(); lcd.backlight();
}

void loop() {
  if (first || millis() - last >= INTERVAL) {
    first = false; last = millis();
    sensors.requestTemperatures();
    float t = sensors.getTempCByIndex(0);
    lcd.clear();
    if (t == DEVICE_DISCONNECTED_C) { lcd.print("Probe error"); return; }
    if (t > peak) peak = t;
    if (t >= 55 && t < 65) hotReadings++;                  // 48 readings is a day in the hot range
    lcd.setCursor(0, 0); lcd.print(t, 1); lcd.print("C "); lcd.print(status(t));
    lcd.setCursor(0, 1); lcd.print("Hot days "); lcd.print(hotReadings / 48.0, 1); lcd.print(" Pk "); lcd.print(peak, 0);
  }
}

Test checklist

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

CheckExpected
Warm water at 60 °CReads about 60 and says Hot: good
Cool waterSays Cool: turn it
Fresh pileHeats to 50 to 65 °C within a few days
Probe unpluggedProbe error

If it does not work

Probe error

Pull-up missing or wires swapped.

Reading much lower than expected

The probe is near the edge. Push it deeper.

Display shows only the start

It refreshes every 30 minutes. Reduce INTERVAL to test.

Batteries die

The Nano board draws idle current. Use a USB power bank or a larger battery pack.

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

Ask Lark AI

Common questions

What parts do I need for the compost pile temperature monitor?

Arduino Nano, DS18B20 waterproof probe, Resistor 4.7 kΩ, 16x2 LCD with I2C backpack (PCF8574), Battery holder 4 × AA with switch, AA alkaline battery × 4 and Jumper wires male to male (40 pcs, 20 cm).

How long does the compost pile temperature monitor take to build?

About 60 minutes for a beginner maker, in 7 steps.

How do I know the compost pile temperature monitor works?

Warm water at 60 °C: Reads about 60 and says Hot: good. Cool water: Says Cool: turn it. Fresh pile: Heats to 50 to 65 °C within a few days.

Probe error: what should I check?

Pull-up missing or wires swapped.

Reading much lower than expected: what should I check?

The probe is near the edge. Push it deeper.

Display shows only the start: what should I check?

It refreshes every 30 minutes. Reduce INTERVAL to test.

Batteries die: what should I check?

The Nano board draws idle current. Use a USB power bank or a larger battery pack.