Build a Smart Cafeteria Tray!
A tray that quietly weighs every food section, notices exactly what you take, and shows a live nutrition score on a little screen — a fun, hands-on way to make healthy eating visible.
📋 What's inside this project
🧰 What You'll Need
This tray uses four food sections as an example — adjust the number to fit your own design.
Arduino Uno (1x)
Reads every section's weight and works out the score.
Small load cells (4x)
One under each food section, sensing weight changes.
HX711 amplifier modules (4x)
Turn each load cell's tiny signal into readable data.
0.96" I2C OLED display (1x)
Shows the live nutrition score.
Green, yellow, and red LEDs
Give an at-a-glance rating for the current score.
Push button (1x)
Resets the tray for the next tray-holder.
Tray with 4 compartments
Wood, plastic, or 3D printed, sized to rest on the load cells.
Breadboard & jumper wires
Connects everything to the Arduino.
USB power or battery pack
Powers the whole tray.
⚙️ How Does It Work?
Weighing what's on the tray — and what's missing — tells the whole nutrition story.
1. Tray starts full
Each section's starting weight is recorded.
2. Food is taken
Sections lose weight as their food is eaten.
3. Score updates live
Points from every section add up on the display.
Underneath each of the tray's four sections sits a small load cell — the same kind of sensor used in kitchen scales. When the tray is first loaded, the Arduino records each section's starting weight.
As food is taken from a section, that section gets lighter. The Arduino keeps comparing the current weight to the starting weight, and the difference tells it exactly how many grams were taken from each food group.
Every food group is worth a different number of points per gram — vegetables and fruit score higher than less balanced choices — so as grams disappear from each section, the total nutrition score climbs, live, right on the display.
🔌 The Circuit Diagram
Each load cell has its own HX711 amplifier, and all four report their readings back to one Arduino.
| Arduino Pin | Connects To | Notes |
|---|---|---|
| Pins 2 & 3 | HX711 #1 — DT & SCK (Protein) | First food section |
| Pins 4 & 5 | HX711 #2 — DT & SCK (Veggies) | Second food section |
| Pins 6 & 7 | HX711 #3 — DT & SCK (Fruit) | Third food section |
| Pins 8 & 9 | HX711 #4 — DT & SCK (Grains) | Fourth food section |
| A4 / A5 | OLED SDA / SCL | Displays the live score |
| Pins 11, 12, 13 | Green, yellow, red LEDs | Quick score rating |
| Pin 10 | Push button | Use `INPUT_PULLUP` to reset for a new tray |
🛠️ Let's Build It — Step by Step
Prepare the tray
Divide a tray or flat board into four sections, each one designed to sit directly on top of a load cell.
Mount the load cells
Fix each load cell securely underneath its section so the section's full weight presses on the sensor.
Wire the HX711 modules
Connect each load cell to its own HX711 amplifier, then wire each HX711's DT and SCK pins to the Arduino.
Add the OLED and LEDs
Wire the OLED display over I2C, and connect the green, yellow, and red LEDs to their digital pins.
Add the reset button
Wire a push button so the tray can be reset and re-weighed for the next person.
Upload the code
Flash the sketch from the next section using the Arduino IDE, after installing the required libraries.
Calibrate each load cell
With each section empty, tare the sensor to zero, then adjust the calibration factor using a known test weight.
Load up and test
Fill each section with sample food, press the button to start, then take some away and watch the score climb!
💻 Time to Code!
This sketch reads all four load cells, works out how much was taken from each section, and displays a running nutrition score.
Install the HX711, Adafruit GFX, and Adafruit SSD1306 libraries from the Library Manager, then upload this sketch to your Arduino Uno.
// Smart Cafeteria Tray // Weighs 4 food sections and calculates a live nutrition score #include <HX711.h> #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define NUM_SECTIONS 4 const int dtPins[NUM_SECTIONS] = {2, 4, 6, 8}; const int sckPins[NUM_SECTIONS] = {3, 5, 7, 9}; const char* sectionNames[NUM_SECTIONS] = {"Protein", "Veggies", "Fruit", "Grains"}; const float pointsPerGram[NUM_SECTIONS] = {0.05, 0.15, 0.15, 0.08}; // veggies & fruit score highest HX711 scale[NUM_SECTIONS]; float startWeight[NUM_SECTIONS]; const float calibration_factor = 420.0; // adjust this for your own load cells #define BUTTON_PIN 10 #define GREEN_LED 11 #define YELLOW_LED 12 #define RED_LED 13 Adafruit_SSD1306 display(128, 64, &Wire, -1); void setup() { for (int i = 0; i < NUM_SECTIONS; i++) { scale[i].begin(dtPins[i], sckPins[i]); scale[i].set_scale(calibration_factor); scale[i].tare(); // zero out each sensor while empty } pinMode(BUTTON_PIN, INPUT_PULLUP); pinMode(GREEN_LED, OUTPUT); pinMode(YELLOW_LED, OUTPUT); pinMode(RED_LED, OUTPUT); display.begin(SSD1306_SWITCHCAPVCC, 0x3C); display.clearDisplay(); startTray(); } void startTray() { display.clearDisplay(); display.setCursor(0, 0); display.print("Load your tray..."); display.display(); delay(2000); for (int i = 0; i < NUM_SECTIONS; i++) { startWeight[i] = scale[i].get_units(5); // average of 5 readings } } void loop() { float totalScore = 0; for (int i = 0; i < NUM_SECTIONS; i++) { float currentWeight = scale[i].get_units(3); float eaten = startWeight[i] - currentWeight; if (eaten < 0) eaten = 0; totalScore += eaten * pointsPerGram[i]; } updateDashboard(totalScore); updateLEDs(totalScore); if (digitalRead(BUTTON_PIN) == LOW) { startTray(); delay(300); } delay(500); } void updateDashboard(float score) { display.clearDisplay(); display.setTextSize(1); display.setCursor(0, 0); display.print("Nutrition Score:"); display.setTextSize(2); display.setCursor(0, 20); display.print(score, 1); display.display(); } void updateLEDs(float score) { digitalWrite(GREEN_LED, LOW); digitalWrite(YELLOW_LED, LOW); digitalWrite(RED_LED, LOW); if (score >= 15) digitalWrite(GREEN_LED, HIGH); else if (score >= 7) digitalWrite(YELLOW_LED, HIGH); else digitalWrite(RED_LED, HIGH); }
calibration_factor is different for every load cell — place a known weight on the sensor and adjust the number until the reading matches.pointsPerGram to match whatever food groups your own tray design uses.🛡️ Safety First
Keep it safe and hygienic while you build and test:
- Ask an adult to help with wiring the load cells and HX711 modules.
- Keep all electronics underneath the tray, sealed away from direct contact with food.
- Use only low-voltage USB or battery power — never mains electricity near the tray.
- Test with sample or toy food first, and clean the tray surface before using real food.
- Disconnect the power before adjusting any wiring.
✨ Fun Nutrition Facts
A little food science to share while your tray tallies up the score.
Filling half your plate with fruits and vegetables is a common guideline for a balanced meal.
Load cells work by measuring how much a tiny strip of metal bends under weight.
Eating a rainbow of different colored foods usually means getting a wider variety of nutrients.
Some real school cafeterias already use smart scales to study food waste and eating habits.
❓ Frequently Asked Questions
How does the smart tray know what food was taken?
Each food section rests on its own load cell. When food is removed from a section, its weight drops, and the Arduino calculates how many grams were taken.
How is the nutrition score calculated?
Every food group is worth a different number of points per gram, with fruits and vegetables scoring highest. The Arduino totals these points as food is taken to build a live score.
What parts do I need to build a smart cafeteria tray?
An Arduino Uno, four small load cells with HX711 amplifiers, an OLED display, a few LEDs, a push button, and a tray divided into four sections.
Is this project safe for kids to build?
Yes, with adult supervision for wiring. Keep the electronics sealed underneath the tray, away from direct food contact, and use only low-voltage power.

Comments
Post a Comment