🧊Smart Refrigerator Inventory Tracker
An IoT & Robotics Project for Smart Kids!
💡What Will You Build?
Imagine a refrigerator that remembers what's inside! In this awesome project, you'll create a smart inventory tracking system using Arduino. Your fridge will track food items, show expiry dates, and even alert you when items are running low. It's like giving your fridge a brain! 🧠
⚙️How Your Smart Fridge Will Work:
✨Cool Features of Your Smart Tracker
Know exactly what's in your fridge
Never forget when milk expires
Get alerts when items run out
See all items on an LCD screen
Save all data with SD card module
Instant notifications on changes
🛠️Materials You'll Need
🎛️ Arduino Board
Arduino Mega 2560 (more memory for storage)
📡 RFID Reader
RC522 RFID Module (reads ID tags)
🏷️ RFID Tags
RFID cards/stickers (minimum 10 pieces)
📺 LCD Display
16x2 or 20x4 LCD with I2C module
💾 SD Card Module
MicroSD card reader + microSD card
🔌 Jumper Wires
Male-to-Female (minimum 20 wires)
📦 Breadboard
Large breadboard for easy connections
🔊 Buzzer (Optional)
For audible alerts when items expire
💡 LEDs
Red, Yellow, Green LEDs for status
🪜 Resistors
220Ω resistors for LEDs (10 pieces)
🖥️ Computer
Windows, Mac, or Linux with USB port
🔗 USB Cable
USB-B for Arduino Mega connection
📋Step-by-Step Instructions
Gather All Materials
Lay out everything on a large, clean workspace. Check that all components are present and working. This is a big project, so being organized is super important!
Install Arduino IDE & Libraries
Download Arduino IDE from arduino.cc. Open it and go to Sketch → Include Library → Manage Libraries. Search for and install these libraries:
• MFRC522 (for RFID reader)
• LiquidCrystal_I2C (for LCD display)
• SD (for SD card module)
Connect Arduino to Computer
Plug your Arduino Mega 2560 into your computer using the USB cable. The Arduino should light up! Go to Tools → Board → Arduino Mega 2560 to select the correct board.
Build the RFID Circuit
Follow the circuit diagram carefully. Connect the RC522 RFID reader first. Make sure every wire is in the right place - loose connections are the #1 problem! Double-check ground (GND) connections.
Connect the LCD Display
Add the 16x2 LCD display with I2C backpack. This will show your inventory list. Connect it to the Arduino's I2C pins (SDA and SCL). The I2C module reduces the number of wires needed!
Add SD Card Module
Connect the SD card module for data storage. This lets you save all inventory data even if Arduino loses power. Use SPI pins on the Arduino Mega. Insert a microSD card.
Add Status LEDs (Optional)
Connect 3 LEDs (Red, Yellow, Green) to show status:
• Green = Storage OK
• Yellow = Expiring Soon
• Red = Expired Item
Upload the Code
Copy the Arduino code from below into the IDE. Click Upload (arrow icon). Wait for the "Upload complete" message. This loads your program into the Arduino!
Label Your RFID Tags
Use a pen to label each RFID tag with food items (Milk, Eggs, Cheese, etc.). Keep a notebook of which tag ID number matches which item. Open Serial Monitor to see tag IDs.
Test Your System
Scan RFID tags near the reader. Check if items appear on the LCD screen. Try the Serial Monitor to see detailed information. Celebrate your success! 🎉
⚡Complete Circuit Diagram & Connections
🔌 RC522 RFID Reader to Arduino Mega 2560
RC522 PIN → ARDUINO MEGA PIN ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ VCC (Power) → 3.3V RST (Reset) → Digital Pin 5 GND (Ground) → GND MISO → Digital Pin 50 MOSI → Digital Pin 51 SCK → Digital Pin 52 SDA (Chip Select) → Digital Pin 53
📺 16x2 LCD Display with I2C to Arduino Mega 2560
LCD I2C PIN → ARDUINO MEGA PIN ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ VCC (Power) → 5V GND (Ground) → GND SDA (Data) → Digital Pin 20 (SDA) SCL (Clock) → Digital Pin 21 (SCL)
💾 SD Card Module to Arduino Mega 2560 (SPI)
SD Card Module PIN → ARDUINO MEGA PIN ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ VCC (Power) → 5V GND (Ground) → GND MOSI → Digital Pin 51 MISO → Digital Pin 50 SCK → Digital Pin 52 CS (Chip Select) → Digital Pin 4
💡 Status LEDs to Arduino Mega 2560
LED Circuit → ARDUINO MEGA PIN ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Green LED (+) → Digital Pin 8 (with 220Ω) Yellow LED (+) → Digital Pin 9 (with 220Ω) Red LED (+) → Digital Pin 10 (with 220Ω) All LED (-) → GND (Ground)
💡Connection Tips:
✓ I2C is special: Multiple devices can use the same SDA/SCL pins
✓ SPI is different: Each device needs its own CS (Chip Select) pin
✓ Power matters: RFID reader needs 3.3V, not 5V!
✓ Ground is critical: Never forget to connect GND
✓ Color code: Use red for power, black for ground, other colors for data
✓ Take photos: Picture your circuit before testing!
💻Complete Arduino Code
// Smart Refrigerator Inventory Tracker // Arduino Mega 2560 with RFID, LCD, and SD Card // A fun project for kids! #include#include #include #include #include // Pin Definitions #define RST_PIN 5 // RFID Reset Pin #define SS_PIN 53 // RFID Chip Select Pin #define SD_CS_PIN 4 // SD Card Chip Select #define GREEN_LED 8 // Status LEDs #define YELLOW_LED 9 #define RED_LED 10 #define BUZZER_PIN 11 // Create Objects MFRC522 rfid(SS_PIN, RST_PIN); LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27 File dataFile; // Data Structure for Items struct FoodItem { String tagID; String name; int quantity; int expiryDays; long dateAdded; }; FoodItem inventory[20]; // Store up to 20 items int itemCount = 0; void setup() { // Initialize Serial for debugging Serial.begin(9600); // Initialize Pin Modes pinMode(GREEN_LED, OUTPUT); pinMode(YELLOW_LED, OUTPUT); pinMode(RED_LED, OUTPUT); pinMode(BUZZER_PIN, OUTPUT); // Initialize SPI and RFID SPI.begin(); rfid.PCD_Init(); // Initialize LCD lcd.init(); lcd.backlight(); lcd.setCursor(0, 0); lcd.print("Smart Fridge"); lcd.setCursor(0, 1); lcd.print("Starting..."); delay(2000); // Initialize SD Card if (!SD.begin(SD_CS_PIN)) { Serial.println("SD Card Failed!"); displayError("SD Card Error!"); } else { Serial.println("SD Card Ready!"); loadInventoryFromSD(); } Serial.println("Smart Refrigerator Ready!"); Serial.println("Scan RFID tags to add items..."); displayMainMenu(); } void loop() { // Check for RFID tag scan if (rfid.PICC_IsNewCardPresent() && rfid.PICC_ReadCardSerial()) { // Get tag ID String tagID = ""; for (byte i = 0; i < rfid.uid.size; i++) { tagID += String(rfid.uid.uidByte[i] < 0x10 ? "0" : ""); tagID += String(rfid.uid.uidByte[i], HEX); } tagID.toUpperCase(); Serial.print("Tag Detected: "); Serial.println(tagID); // Check if item already exists int existingIndex = findItemByTag(tagID); if (existingIndex != -1) { // Item exists - increase quantity inventory[existingIndex].quantity++; digitalWrite(GREEN_LED, HIGH); tone(BUZZER_PIN, 1000, 200); // Beep lcd.clear(); lcd.setCursor(0, 0); lcd.print("Item Added!"); lcd.setCursor(0, 1); lcd.print(inventory[existingIndex].name); Serial.print("Increased: "); Serial.println(inventory[existingIndex].name); } else { // New item - prompt for details promptNewItem(tagID); } // Update SD Card saveInventoryToSD(); // Check expiry status checkExpiryStatus(); rfid.PICC_HaltA(); delay(1500); displayMainMenu(); } } // Find item by RFID tag int findItemByTag(String tagID) { for (int i = 0; i < itemCount; i++) { if (inventory[i].tagID == tagID) { return i; } } return -1; } // Prompt for new item details void promptNewItem(String tagID) { lcd.clear(); lcd.setCursor(0, 0); lcd.print("New Item!"); lcd.setCursor(0, 1); lcd.print("Check Serial"); Serial.println("\n=== NEW ITEM ==="); Serial.println("Enter item name:"); // Simulated - in real app, use Bluetooth or web interface // Default example inventory[itemCount].tagID = tagID; inventory[itemCount].name = "Food Item " + String(itemCount + 1); inventory[itemCount].quantity = 1; inventory[itemCount].expiryDays = 7; inventory[itemCount].dateAdded = millis(); itemCount++; digitalWrite(GREEN_LED, HIGH); delay(500); digitalWrite(GREEN_LED, LOW); Serial.println("Item added to inventory!"); } // Check expiry status void checkExpiryStatus() { digitalWrite(RED_LED, LOW); digitalWrite(YELLOW_LED, LOW); digitalWrite(GREEN_LED, LOW); int expiringCount = 0; int expiredCount = 0; long currentTime = millis(); for (int i = 0; i < itemCount; i++) { long ageInDays = (currentTime - inventory[i].dateAdded) / (1000 * 60 * 60 * 24); if (ageInDays >= inventory[i].expiryDays) { expiredCount++; digitalWrite(RED_LED, HIGH); } else if (ageInDays >= inventory[i].expiryDays - 2) { expiringCount++; digitalWrite(YELLOW_LED, HIGH); } } if (expiredCount == 0 && expiringCount == 0) { digitalWrite(GREEN_LED, HIGH); } if (expiredCount > 0) { tone(BUZZER_PIN, 1500, 300); delay(200); tone(BUZZER_PIN, 1500, 300); } } // Display main menu on LCD void displayMainMenu() { lcd.clear(); lcd.setCursor(0, 0); lcd.print("Items: "); lcd.print(itemCount); lcd.setCursor(0, 1); if (itemCount > 0) { lcd.print(inventory[0].name); } else { lcd.print("Scan a tag!"); } } // Save inventory to SD Card void saveInventoryToSD() { if (SD.exists("inventory.txt")) { SD.remove("inventory.txt"); } dataFile = SD.open("inventory.txt", FILE_WRITE); if (dataFile) { dataFile.print(itemCount); dataFile.println(); for (int i = 0; i < itemCount; i++) { dataFile.print(inventory[i].tagID); dataFile.print(","); dataFile.print(inventory[i].name); dataFile.print(","); dataFile.print(inventory[i].quantity); dataFile.print(","); dataFile.print(inventory[i].expiryDays); dataFile.println(); } dataFile.close(); Serial.println("Inventory saved to SD card!"); } } // Load inventory from SD Card void loadInventoryFromSD() { if (SD.exists("inventory.txt")) { dataFile = SD.open("inventory.txt"); if (dataFile) { itemCount = dataFile.parseInt(); dataFile.read(); // Read newline for (int i = 0; i < itemCount; i++) { String line = ""; while (dataFile.available()) { char c = dataFile.read(); if (c == '\n') break; line += c; } // Parse comma-separated values int commaIndex = line.indexOf(','); inventory[i].tagID = line.substring(0, commaIndex); int nextComma = line.indexOf(',', commaIndex + 1); inventory[i].name = line.substring(commaIndex + 1, nextComma); commaIndex = nextComma; nextComma = line.indexOf(',', commaIndex + 1); inventory[i].quantity = line.substring(commaIndex + 1, nextComma).toInt(); inventory[i].expiryDays = line.substring(nextComma + 1).toInt(); } dataFile.close(); Serial.println("Inventory loaded from SD card!"); } } } // Display error message void displayError(String error) { lcd.clear(); lcd.setCursor(0, 0); lcd.print("ERROR!"); lcd.setCursor(0, 1); lcd.print(error); digitalWrite(RED_LED, HIGH); tone(BUZZER_PIN, 2000, 500); }
📝Understanding the Code:
setup(): Starts all sensors and systems
loop(): Constantly listens for RFID scans
findItemByTag(): Searches if item already in fridge
promptNewItem(): Adds new food items
checkExpiryStatus(): Warns about old food
saveInventoryToSD(): Keeps data safe even without power
loadInventoryFromSD(): Remembers items after restart
📊Different Ways to Build This Project
| Method | Pros | Cons | Best For |
|---|---|---|---|
| RFID Tags (Our Project) | Works great, cheap, fun to scan | Need to tag each item | Learning robotics basics |
| Weight Sensors | Automatic, no tagging needed | Complex to calibrate | Advanced projects |
| Barcode Scanner | Reads existing barcodes | Expensive, needs internet | Professional systems |
| Camera + AI | Super smart, very cool | Difficult programming, needs powerful computer | Advanced AI projects |
🧪Testing Your Smart Fridge
Test 1: RFID Reading
Scan a tag near the reader. Check Serial Monitor - you should see the tag ID appear. If it doesn't, check connections!
Test 2: LCD Display
The LCD should light up and show "Smart Fridge Starting...". If blank, check I2C connections and address.
Test 3: Adding Items
Scan different tags and check if items are added to inventory. Each scan should increase quantity or add new item.
Test 4: SD Card Saving
Unplug Arduino, replug it. Your inventory should still be there! This proves SD card is saving data.
Test 5: Expiry Alerts
LEDs should light: Green (OK), Yellow (Expiring Soon), Red (Expired). Buzzer should beep for expired items.
🔧Troubleshooting Guide
When Things Don't Work...
✓ Check power - RFID needs 3.3V, not 5V!
✓ Verify SPI pins (MOSI, MISO, SCK) are correct
✓ Make sure antenna is facing the tag
✓ Try a different RFID tag - some don't work
✓ Check I2C address (usually 0x27, scan to find yours)
✓ Verify SDA/SCL wires on correct pins
✓ Make sure I2C backpack is installed on LCD
✓ Try adjusting contrast with potentiometer
✓ Format microSD card as FAT32
✓ Check CS pin connection (should be pin 4)
✓ Make sure SD card is inserted properly
✓ Try a different microSD card
✓ Select correct board: Arduino Mega 2560
✓ Check USB cable is fully plugged in
✓ Try different USB port on computer
✓ Make sure libraries are installed
✓ Check LED polarity (longer leg = positive)
✓ Verify 220Ω resistor is in series
✓ Make sure pins 8, 9, 10 are not damaged
✓ Test LED with simple blink code first
🚀Level Up Your Project!
Advanced Features to Add
Add Bluetooth HC-05 module to control fridge from phone
Use ESP32 instead to send alerts to your phone online
Get email when milk is about to expire
Add camera to take photos of items added
Check if fridge is cold enough with temp sensor
Auto-generate shopping list of low items
Suggest recipes based on what's in fridge
Weigh items to track quantity automatically
⚠️Safety & Best Practices:
✓ Always ask an adult for help
✓ Disconnect power before making changes
✓ Don't force components into breadboard
✓ Keep liquids away from electronics
✓ Don't connect 5V to 3.3V devices (like RFID reader)
✓ Wash hands after handling electronics
✓ Never leave project unattended while powered
🎓Amazing Skills You've Learned!
✅ How to use RFID technology for identification
✅ How to read and store data with SD cards
✅ How to display information on LCD screens
✅ How to use I2C and SPI communication protocols
✅ How to structure complex Arduino projects
✅ How to debug code using Serial Monitor
✅ How IoT (Internet of Things) works in real life
✅ Data management and file handling
✅ Project planning and troubleshooting skills
✅ Real-world robotics applications!

Comments
Post a Comment