Files
QT-CART/QT-Server/hx711_read.py
T
2026-02-24 18:30:51 +09:00

24 lines
392 B
Python

from hx711 import HX711
import json, time
DT_PIN = 5
SCK_PIN = 6
with open("hx711_calib.json") as f:
calib = json.load(f)
OFFSET = calib["offset"]
SCALE = calib["scale"]
hx = HX711(DT_PIN, SCK_PIN)
hx.set_offset(OFFSET)
hx.set_reference_unit(SCALE)
print(" 무게 측정 시작")
while True:
weight = hx.get_weight(10)
print(f"무게: {weight:.1f} g")
time.sleep(0.5)