Smart Tiffin Box: A DIY Food Freshness Alert System with Arduino

Smart Tiffin Box: A DIY Food Freshness Alert System with Arduino | Kids Robotics Project
Robotics Project · Ages 9+

The Smart Tiffin Box: a lunch box that tells you when your food is going bad

Clip a tiny sensor pod onto a lunch box lid, and it constantly sniffs the air inside. As long as the food is fresh, a green light glows. As it starts to turn, the light shifts to yellow. And if it's actually spoiled, a red light flashes and a buzzer sounds — before you ever take a bite.

What you're building

A wearable-for-your-lunch gadget that teaches gas sensing and threshold-based alerts.

The Smart Tiffin Box adds a small sensor pod to the lid of an ordinary lunch box. Inside the pod, a gas sensor constantly checks the air for the kinds of smells food gives off as it starts to spoil, while a second sensor keeps an eye on temperature and humidity. A tiny screen shows the live readings, and three lights tell the whole story at a glance — so you know your food's condition without even opening the lid.

Gas Sensing

A gas sensor picks up the smell of food starting to spoil, before it's obvious to your nose.

Live Display

A small screen shows the current freshness reading, temperature, and humidity in real time.

Freshness Alert

Lights and a buzzer warn you clearly once food crosses from fresh to "check soon" to spoiled.

🟢 FreshLow gas reading — safe to eat
🟠 Check SoonGas level rising — eat soon
🔴 SpoiledHigh gas reading — buzzer sounds

Materials list

Most electronics can be reused from a beginner Arduino sensor kit.

Electronics

  • 1x Arduino Uno or Nano
  • 1x MQ-135 air quality / gas sensor module
  • 1x DHT11 temperature & humidity sensor
  • 1x 16x2 LCD display with I2C backpack
  • 1x small buzzer
  • 3x LEDs (green, yellow, red) + 220-ohm resistors
  • 1x push button (silence / reset)
  • Jumper wires + small perfboard or breadboard
  • Small USB power bank (for portable use)

Build supplies

  • A small tiffin box or lunch container
  • A small plastic pod or box for the sensor pack (lid-mounted)
  • Hot glue gun
  • Craft knife (adult use only)
  • Thin mesh or fabric (to protect the gas sensor from food splashes)
  • Double-sided tape or Velcro

Circuit diagram

Everything connects back to the Arduino, with the LCD sharing the I2C bus.

ARDUINO UNO / NANO USB / 5V power in MQ-135 SENSOR Gas / air quality Signal (AO) → A0 DHT11 SENSOR Temp & humidity Signal → D2 PUSH BUTTON Silence buzzer D3 STATUS LEDs Green/Yellow/Red D5, D6, D7 16x2 LCD (I2C) Status display SDA → A4 SCL → A5 BUZZER Spoiled alert D8 5V POWER USB power bank

Tip: Keep the MQ-135 sensor's metal mesh facing into the tiffin box, but shield it behind a thin fabric layer so food or liquid never touches it directly. Keep all grounds connected together.

Wiring reference table

ComponentComponent PinArduino Pin
MQ-135 Gas SensorSignal (AO)A0
DHT11 SensorSignalD2
Push ButtonSignalD3 (internal pull-up)
Green LED (Fresh)AnodeD5
Yellow LED (Check Soon)AnodeD6
Red LED (Spoiled)AnodeD7
BuzzerSignalD8
16x2 LCD (I2C)SDA / SCLA4 / A5
All componentsGNDCommon GND rail

Step-by-step build instructions

Work through these in order — test the sensors on the bench before mounting them on a lunch box.

  1. Wire the sensors on a breadboard

    Connect the MQ-135 gas sensor to A0 and the DHT11 to D2, then upload a simple test sketch to confirm both are giving readings before building further.

  2. Add the LCD, LEDs, and buzzer

    Wire the LCD to A4/A5, the three status LEDs to D5, D6, and D7, and the buzzer to D8 as shown in the wiring table.

  3. Add the silence button

    Wire a push button to D3 with an internal pull-up, so pressing it can silence the buzzer once you've noticed the alert.

  4. Upload the code and let the sensor warm up

    Upload the sketch below. Gas sensors like the MQ-135 need a couple of minutes to warm up before their readings settle, so don't judge the results in the first few minutes.

  5. Calibrate the freshness thresholds

    Note the sensor's reading over fresh food, then over food you know has gone off (safely, from a distance), and adjust FRESH_LIMIT and SPOILED_LIMIT in the code to match.

  6. Build the sensor pod

    Fit the gas sensor, DHT11, and wiring into a small plastic pod, with a thin fabric layer protecting the gas sensor's mesh from direct contact with food or liquid.

  7. Mount the pod on the lid

    Attach the sensor pod to the inside of the tiffin box lid with Velcro or double-sided tape, positioning it so the sensor faces down into the food compartment.

  8. Mount the display and controls outside

    Fix the LCD, LEDs, and button to the outside of the lid or a small side panel so you can check freshness without opening the box.

Arduino code

Copy this into a new sketch in the Arduino IDE. Install the DHT sensor library and LiquidCrystal_I2C library first from the Library Manager.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>

// ---- Pin setup ----
#define GAS_SENSOR_PIN   A0
#define DHT_PIN          2
#define BUTTON_PIN       3
#define LED_GREEN        5
#define LED_YELLOW       6
#define LED_RED          7
#define BUZZER_PIN       8

#define DHT_TYPE DHT11

LiquidCrystal_I2C lcd(0x27, 16, 2);
DHT dht(DHT_PIN, DHT_TYPE);

int FRESH_LIMIT = 300;     // below this = fresh (calibrate for your sensor)
int SPOILED_LIMIT = 550;   // above this = spoiled (calibrate for your sensor)
bool buzzerSilenced = false;

void setup() {
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  pinMode(LED_GREEN, OUTPUT);
  pinMode(LED_YELLOW, OUTPUT);
  pinMode(LED_RED, OUTPUT);
  pinMode(BUZZER_PIN, OUTPUT);

  dht.begin();
  lcd.init();
  lcd.backlight();

  lcd.setCursor(0, 0);
  lcd.print("Warming up...");
  delay(20000); // let the gas sensor stabilize before first reading
}

void loop() {
  int gasLevel = analogRead(GAS_SENSOR_PIN);
  float temperature = dht.readTemperature();
  float humidity = dht.readHumidity();

  checkButton();
  updateStatus(gasLevel);
  updateDisplay(gasLevel, temperature, humidity);

  delay(500);
}

void checkButton() {
  if (digitalRead(BUTTON_PIN) == LOW) {
    buzzerSilenced = true;
    noTone(BUZZER_PIN);
    delay(300); // debounce
  }
}

void updateStatus(int gasLevel) {
  digitalWrite(LED_GREEN, LOW);
  digitalWrite(LED_YELLOW, LOW);
  digitalWrite(LED_RED, LOW);

  if (gasLevel < FRESH_LIMIT) {
    digitalWrite(LED_GREEN, HIGH);
    buzzerSilenced = false; // reset silence once food is fresh again
    noTone(BUZZER_PIN);
  } else if (gasLevel < SPOILED_LIMIT) {
    digitalWrite(LED_YELLOW, HIGH);
    noTone(BUZZER_PIN);
  } else {
    digitalWrite(LED_RED, HIGH);
    if (!buzzerSilenced) {
      tone(BUZZER_PIN, 1000);
    }
  }
}

void updateDisplay(int gasLevel, float temperature, float humidity) {
  lcd.setCursor(0, 0);
  lcd.print("Gas:");
  lcd.print(gasLevel);
  lcd.print("      ");

  lcd.setCursor(0, 1);
  if (gasLevel < FRESH_LIMIT) {
    lcd.print("Fresh  ");
  } else if (gasLevel < SPOILED_LIMIT) {
    lcd.print("Check soon");
  } else {
    lcd.print("SPOILED!");
  }
}

Beginner tip

Every MQ-135 sensor reads slightly differently out of the box. Watch the raw gasLevel value on the LCD over fresh food first, then use that as your real baseline for FRESH_LIMIT.

Safety notes for young makers

Ask an adult to help with wiring and with testing near actually spoiled food. Keep all electronics sealed away from food and liquid, never let the sensor pod touch food directly, and always wash the tiffin box separately from the electronics. This project is for learning and awareness — always use your own judgment (and a trusted adult's) about whether food is safe to eat.

Why this project works so well for learning

The Smart Tiffin Box is a great first project in analog sensing. Reading a gas sensor's raw value and turning it into a simple "fresh, check soon, spoiled" message teaches how real-world sensors rarely give clean yes/no answers — they give numbers that code has to interpret using thresholds. Calibrating those thresholds against real fresh and spoiled food adds a genuine science-fair-style experiment to the build. And combining a gas reading with temperature and humidity data is a gentle introduction to how real food-safety and cold-chain monitoring systems work.

Frequently asked questions

What age group is this robotics project best suited for?

Ages 9 and up can build this with an adult helping on wiring and calibration. Ages 12+ with some Arduino experience can usually manage most of it independently.

Do I need to know how to code to build this?

No. The code above uploads and runs as-is. The one hands-on coding step is adjusting the two threshold numbers during calibration, which is a great first edit for a beginner.

Why does the sensor need to "warm up"?

Gas sensors like the MQ-135 use a small heating element inside to work properly, and their readings drift for the first minute or two after power-on. The code includes a warm-up pause so early readings don't trigger a false alarm.

Can I build this without the temperature and humidity sensor?

Yes. The gas sensor alone can drive the freshness alert — the DHT11 is there to add extra context on the display, not to trigger the alarm itself.

Is this a substitute for checking if food is actually safe to eat?

No. This project is a fun, hands-on introduction to gas sensing and food safety awareness, not a certified food-safety device. Always use your own senses and judgment — and a trusted adult's — for anything you're about to eat.

Built for curious young engineers. Always build and power on electronics with adult supervision, and keep electronics away from food and liquids.

Comments

Product Cards
Buddy Bot eBook
⭐ New 2026 Release
Build Your
Own Robot!
3D design, wiring &
Arduino coding.
★★★★★ Young inventors love it!
🖨️
3D Print
All parts
⚡
Wire it
Circuit guide
💻
Code it
Arduino IDE
🤖
Watch it
Walk & react
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Website Offer
₹499 ₹300
🌍 International: $5 USD
One-time · Instant digital delivery
🔒 Secured by Razorpay · Your data is safe
📄 Download Free Sample Copy
🔒 Secured by Razorpay · Your data is safe
🍓
Raspberry Pi Pico Mastery
21 Projects
⚡ Launch Price — 80% OFF
Learn Pico
Build 21 Projects!
MicroPython · Wokwi
IoT · Certificate
★★★★★ Perfect for beginners!
🖥️
Wokwi
No hardware
🐍
MicroPy
From zero
🔨
21 Projects
IoT + sensors
📄
Certificate
Verified cert
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Launch Offer
₹999 ₹200 80% OFF
🌍 International: $5 USD
One-time · Lifetime access · No subscription
🔒 Secured by Razorpay · UPI · Cards · NetBanking
🎉

You're in!

Payment successful! Your Buddy Bot eBook is ready. Time to build!

📖 Access Your eBook Now
🎉

Enrolled!

Payment successful! Lifetime access to all 21 Pico Projects is yours!

🍓 Go to My Course