LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsA load cell bends a tiny amount under weight and the HX711 amplifies that into a 24-bit number. MicroPython has no built-in HX711 driver, so this project includes a short one that reads the 24 bits with two pins. The code takes an average for the empty-plate tare, then divides by a calibration factor you find with a known weight. The OLED shows grams.
Do not load the cell above its rating.
Tick anything you already have and the total updates.
5 kg load cell with HX711 module
Follow the colours: red is power, dark grey is ground, blue is a signal.
USB power bank, for steady readings.
main.pyimport time
from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
FACTOR = 1.0 # raw counts per gram: find it with a known weight
class HX711:
def __init__(self, dt, sck):
self.dt = Pin(dt, Pin.IN)
self.sck = Pin(sck, Pin.OUT, value=0)
def read(self):
while self.dt.value(): # wait until the chip is ready
pass
value = 0
for _ in range(24):
self.sck.value(1); self.sck.value(0)
value = (value << 1) | self.dt.value()
self.sck.value(1); self.sck.value(0) # one extra pulse = channel A, gain 128
if value & 0x800000:
value -= 1 << 24
return value
cell = HX711(14, 15)
i2c = I2C(0, sda=Pin(4), scl=Pin(5), freq=400000)
oled = SSD1306_I2C(128, 64, i2c)
def avg(n=10):
return sum(cell.read() for _ in range(n)) / n
tare = avg(20) # empty plate = zero
while True:
raw = avg(5) - tare
grams = raw / FACTOR
print("raw", raw, "grams", grams)
oled.fill(0)
oled.text("%.0f g" % (0 if abs(grams) < 1 else grams), 0, 20)
oled.show()
time.sleep(0.2)
Let the HX711 warm up for a minute and keep the load cell and cable still.
Swap the two signal wires from the load cell or use a negative FACTOR.
The HX711 is not answering. Check DT, SCK and its power.
About 1 to 2 grams after calibration with a good mount.
Use a higher-rated load cell; the code is the same.
It keeps the project to a single file with no downloads.
5 parts: Raspberry Pi Pico, Generic 5kg Load Cell Kit with HX711AD Module, Shell & 4P DuPont Wire, 0.96" OLED Display 128x64, Solderless Breadboard and Dupont Jumper Wires (40 pcs). On this page you can tick the parts you already have and add only the rest to your cart.
It is a intermediate project and takes about 2 hours. The build on this page has 6 steps.
No. This page has the complete, tested code (main.py).
About ₹1,104 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Reading the HX711 with two GPIO pins; Taring and calibrating; Averaging readings to reduce noise.
Do not load the cell above its rating.
Ideas that reuse this build: ESP32 load cell kitchen scale. They are listed under Take it further on this page.
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
See the smoke level live on a crisp screen and get a loud warning when it spikes.
An infrared eye that spots an open flame and raises the alarm.
Walk into the room and it sounds the alarm: the classic first security build.
Learning project. Check every circuit and the datasheet of each part before you power it up.