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.
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
Wiring reference table
| Component | Component Pin | Arduino Pin |
|---|---|---|
| MQ-135 Gas Sensor | Signal (AO) | A0 |
| DHT11 Sensor | Signal | D2 |
| Push Button | Signal | D3 (internal pull-up) |
| Green LED (Fresh) | Anode | D5 |
| Yellow LED (Check Soon) | Anode | D6 |
| Red LED (Spoiled) | Anode | D7 |
| Buzzer | Signal | D8 |
| 16x2 LCD (I2C) | SDA / SCL | A4 / A5 |
| All components | GND | Common 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.
-
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.
-
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.
-
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.
-
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.
-
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.
-
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.
-
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.
-
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.

Comments
Post a Comment