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.
Circuit diagram
| Part | Connects to | Notes |
|---|---|---|
| Load cell red / black | HX711 E+ / E− | Power wires of the load cell |
| Load cell white / green | HX711 A− / A+ | Swap them if the weight shows negative |
| HX711 DT, SCK | Nano D3, D2 | VCC to 5V, GND to GND |
| LCD SDA, SCL | Nano A4, A5 | VCC to 5V, GND to GND, address 0x27 |
| Green, yellow, red LED | Nano D5, D6, D7 | Long leg through 220 Ω, short leg to GND |
| Buzzer (+) | Nano D8 | Buzzer (−) to GND |
| Zero button | Nano D4 | Other leg to GND |
Step-by-step instructions
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.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.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.Install the libraries
In Arduino IDE open Library Manager and install HX711 by Bogdan Necula and LiquidCrystal I2C.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 yourCAL_FACTOR.Set your cylinder numbers
Weigh your empty demo cylinder and your full one. Put them inEMPTY_KGandFULL_KGin the main code.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);
}
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.

Comments
Post a Comment