Cooking Gas Refill Predictor with Arduino and Load Cell

Cooking Gas Refill Predictor with Arduino and Load Cell – Kids Robotics Project | MakeMindz
Arduino NanoAges 9–14About 2 hoursIntermediate

Cooking Gas Refill Predictor with Arduino

Have you ever seen a cooking gas cylinder run out in the middle of dinner? This project weighs a demonstration cylinder with a load cell, works out how much is left, guesses how many days remain and reminds you to book a refill. Slide the gas level below to see how it will behave!

How does it work?

⚖️

Weigh

A load cell bends a tiny bit when weight sits on it. The HX711 module turns that bend into numbers.

➖

Subtract

The Arduino takes away the empty cylinder weight. What is left is the gas weight.

📉

Predict

It watches how fast the weight falls, then guesses how many hours remain.

🔔

Remind

Green means plenty, yellow means low and red with a buzzer means refill now!

What you need

🔲

Arduino Nano ×1

The brain of the project.

⚖️

Load cell 10 kg ×1

Bar type with four wires.

📟

HX711 module ×1

Amplifies the load cell signal.

🖥️

16×2 I2C LCD ×1

Shows percent and days left.

💡

LEDs ×3

Green, yellow, red, plus three 220 Ω resistors.

🔔

Active buzzer ×1

Beeps when gas is low.

🔘

Push button ×1

Resets the zero point.

🪣

Demo cylinder ×1

A small plastic bottle or can with a flat bottom, filled with sand.

🧰

Extras

Two wooden boards, four screws, spacers, breadboard, jumper wires.

Safety first: Never put a real gas cylinder on this build. Use only a demonstration cylinder filled with sand or dry rice, and keep the circuit away from any real flame or gas. Ask an adult to help with the wooden platform.

Circuit diagram

PartConnects toNotes
Load cell red / blackHX711 E+ / E−Power wires of the load cell
Load cell white / greenHX711 A− / A+Swap them if the weight shows negative
HX711 DT, SCKNano D3, D2VCC to 5V, GND to GND
LCD SDA, SCLNano A4, A5VCC to 5V, GND to GND, address 0x27
Green, yellow, red LEDNano D5, D6, D7Long leg through 220 Ω, short leg to GND
Buzzer (+)Nano D8Buzzer (−) to GND
Zero buttonNano D4Other leg to GND
Remember: The load cell is fixed at one end to the base and holds the platform at the other end. If both ends touch the base, it cannot bend and the reading will not change.

Step-by-step instructions

  1. Build the weighing platform

    Screw one end of the load cell to the base board using spacers. Screw the top board to the other end. The arrow on the cell must point down. Leave a small gap so the boards never touch.
  2. Wire the HX711 and load cell

    Connect the four load cell wires to the HX711 as in the table. Then wire DT to D3 and SCK to D2.
  3. Add the LCD, LEDs and buzzer

    Connect the LCD to A4 and A5, the LEDs to D5, D6 and D7 through resistors, the buzzer to D8 and the button to D4.
  4. Install the libraries

    In Arduino IDE open Library Manager and install HX711 by Bogdan Necula and LiquidCrystal I2C.
  5. Calibrate with a known weight

    Upload the calibration sketch below with an empty platform. Place a known weight, like a 500 g pack of sugar, on top and note the number. Divide it by the real weight to get your CAL_FACTOR.
  6. Set your cylinder numbers

    Weigh your empty demo cylinder and your full one. Put them in EMPTY_KG and FULL_KG in the main code.
  7. Upload and test

    Upload the predictor sketch, place the cylinder on the platform and press the button once. Pour out some sand and watch the percentage, LEDs and days left change.

Arduino code

1. Calibration sketch

#include <HX711.h>
HX711 scale;

void setup() {
  Serial.begin(9600);
  scale.begin(3, 2);          // DT = D3, SCK = D2
  scale.set_scale();          // no calibration yet
  scale.tare();               // empty platform = zero
  Serial.println("Place a known weight now...");
}

void loop() {
  Serial.print("Raw reading: ");
  Serial.println(scale.get_units(10));
  delay(1000);
}

2. Refill predictor sketch

// Cooking Gas Refill Predictor - MakeMindz
#include <HX711.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

HX711 scale;
LiquidCrystal_I2C lcd(0x27, 16, 2);

const int greenLed = 5, yellowLed = 6, redLed = 7;
const int buzzer = 8, zeroBtn = 4;

const float CAL_FACTOR = 420.0;   // from calibration step
const float EMPTY_KG = 1.0;       // demo cylinder when empty
const float FULL_KG  = 5.0;       // demo cylinder when full
const int LOW_PERCENT = 25;       // yellow warning
const int REFILL_PERCENT = 10;    // red and buzzer

const unsigned long SAMPLE_MS = 60000;  // check use every minute
float lastGas = -1;
float usePerHour = 0;             // smoothed kg used per hour
unsigned long lastSample = 0;

float readGasKg() {
  float total = scale.get_units(10) / 1000.0;  // grams to kg
  float gas = total - EMPTY_KG;
  return gas < 0 ? 0 : gas;
}

void setup() {
  pinMode(greenLed, OUTPUT); pinMode(yellowLed, OUTPUT);
  pinMode(redLed, OUTPUT);   pinMode(buzzer, OUTPUT);
  pinMode(zeroBtn, INPUT_PULLUP);
  lcd.init(); lcd.backlight();
  scale.begin(3, 2);
  scale.set_scale(CAL_FACTOR);
  lcd.print("Place cylinder");
  delay(3000);
  lastGas = readGasKg();
  lcd.clear();
}

void loop() {
  float gas = readGasKg();
  float capacity = FULL_KG - EMPTY_KG;
  int percent = constrain((int)(gas / capacity * 100), 0, 100);

  // learn how fast the gas is being used
  if (millis() - lastSample >= SAMPLE_MS) {
    float used = lastGas - gas;                 // kg lost this minute
    if (used > 0) {
      float perHour = used * 60.0;
      usePerHour = (usePerHour == 0) ? perHour : 0.8 * usePerHour + 0.2 * perHour;
    }
    lastGas = gas;
    lastSample = millis();
  }

  // show results
  lcd.setCursor(0, 0);
  lcd.print("Gas left: "); lcd.print(percent); lcd.print("%   ");
  lcd.setCursor(0, 1);
  if (usePerHour > 0.001) {
    lcd.print("Empty in "); lcd.print(gas / usePerHour, 1); lcd.print(" h  ");
  } else {
    lcd.print("Learning use... ");
  }

  // LEDs and reminder
  digitalWrite(greenLed,  percent > LOW_PERCENT);
  digitalWrite(yellowLed, percent <= LOW_PERCENT && percent > REFILL_PERCENT);
  digitalWrite(redLed,    percent <= REFILL_PERCENT);
  if (percent <= REFILL_PERCENT) {
    digitalWrite(buzzer, HIGH); delay(200);
    digitalWrite(buzzer, LOW);  delay(200);
  }

  // button = set a new zero point (use with the EMPTY platform)
  if (digitalRead(zeroBtn) == LOW) {
    scale.tare();
    lcd.clear(); lcd.print("Zero set!");
    delay(1000); lcd.clear();
  }
  delay(500);
}
Tip: To see predictions quickly, change SAMPLE_MS to 5000 and pour sand out slowly while you watch the screen.

Fix it: troubleshooting

🔢 Weight shows negative

Swap the white and green load cell wires on the HX711.

🎢 Numbers keep jumping

Keep the platform still, use short wires and put the project on a hard table.

😴 Reading never changes

Make sure the top board does not touch the base board.

🖥️ LCD is blank

Turn the contrast screw behind the LCD, or try address 0x3F.

Upgrade ideas

📱 Phone alert

Swap the Nano for an ESP32 and send a refill message by Wi-Fi.

💾 Remember use

Save daily use in EEPROM so predictions survive power cuts.

📊 Weekly graph

Log weights to an SD card and draw a chart.

🔋 Battery power

Add a power bank so it works during outages.

Frequently asked questions

How does a load cell measure the gas left?

It measures total weight. Subtract the empty cylinder weight and what remains is the contents.

Can I use this on a real cooking gas cylinder?

No. Use only a demonstration cylinder with sand. Real cylinders are heavy and need professional, certified equipment.

How does it predict the refill date?

It tracks how quickly the weight drops, then divides the contents left by that speed to find the hours remaining.

What will I learn?

Load cells, the HX711 amplifier, calibration, percentages, averaging and smart reminders.

Made with 💙 by MakeMindz – robotics and maker projects for kids.

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