Ich bin recht neu in dem Thema.
Aktuell nutze ich dieses py skript für meine Waage.
Ich benötige eine weitere ausgabe weiß aber leider nicht wie ich das Umsetze.
Benötigt wird Folgendes.
Am LCD die Augabe wie lange die Wage belastet wird.
dies Soll bei Tag 1 beginnen wenn sie bereits 2 Std. durchgehend mit mehr als 500g belastet wird.
Timer soll zurück gesetzt werden wenn sie 2 Std. lang nicht belastet wird.
Code: Alles auswählen
#! /usr/bin/python2 import time
import sys
import lcddriver
import RPi.GPIO as GPIO
import math
lcd = lcddriver.lcd()
EMULATE_HX711=False
referenceUnit = 1
if not EMULATE_HX711:
import RPi.GPIO as GPIO
from hx711 import HX711
else:
from emulated_hx711 import HX711
def cleanAndExit():
print("Cleaning...")
if not EMULATE_HX711:
GPIO.cleanup()
print("Bye!")
sys.exit()
hx = HX711(5, 6)
hx.set_reading_format("MSB", "MSB")
hx.set_reference_unit(339)
hx.reset()
hx.tare()
print("Tare done! Add weight now...")
while True:
try:
val = max(0, int(hx.get_weight(5)))
print(val)
hx.power_down()
hx.power_up()
time.sleep(0.1)
except (KeyboardInterrupt, SystemExit):
cleanAndExit()
#LCD Bereinigung
lcd.lcd_clear()
#Messwerte auf LCD schreiben
lcd.lcd_display_string(str(val), 1)
lcd.lcd_display_string(time.strftime("%d.%m.%Y %H:%M:%S"), 2)