所以我刚开始使用python并且从连接到树莓派的称重传感器中提炼我的读数。下面是代码:
hx = HX711(5, 6)
hx.set_reading_format("LSB", "MSB")
hx.set_reference_unit(26.978)
hx.reset()
hx.tare()
while True:
for i in range (15):
val = int(hx.get_weight(5))
newval = abs(round((float(val/1000)),1))
X = []
X.append (newval)
print ([X])
hx.power_down()
hx.power_up()
我想我会在那段时间内得到一份读数清单,也许是4?但我总是得到一个。数据肯定足以制作一个列表,但我的列表总是只有一个数据。
我确定我做错了什么,请大家帮忙。
答案 0 :(得分:0)
我注意到的两件事,这是错误的:
例如:
hx = HX711(5, 6)
hx.set_reading_format("LSB", "MSB")
hx.set_reference_unit(26.978)
hx.reset()
hx.tare()
while True:
X = []
for i in range (15):
val = int(hx.get_weight(5))
newval = abs(round((float(val/1000)),1))
X.append (newval)
hx.power_down()
hx.power_up()
print ([X])
将显示一组包含15个值的列表