Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*-coding: utf-8 -*-
- import lcddriver
- import RPi.GPIO as GPIO
- import time
- import sys
- import math
- from hx711 import HX711
- from time import *
- # Script Unterbrechung / Schleifenbeendigung per STRG + C
- #def cleanAndExit():
- #print "Aufräumen"
- #GPIO.cleanup()
- #print "Tschüß!"
- #sys.exit()
- # Messwandler Anschlüsse
- hx = HX711 (5, 6)
- # Waagenparameter
- capacity = 80000
- unit = 'g'
- division = 1.000
- # Kalibrierparameter
- hx.set_reference_unit(131)
- # Nullsetzparameter
- hx.reset()
- hx.tare()
- # Schnittsetllenbeschreibung
- lcd = lcddriver.lcd() #LCD
- # Schleifenbeginn RV=Raw Value / WV=Weight Value
- while True:
- try:
- RV = max(0, int(hx.get_weight(5))) # Rohwert ohne Einheit
- WV = RV/division # Rohwert / Teilung
- weight = WV; unit # Gewicht mit Einheit
- print weight
- #print hx.get_weight(5)/100 # Messwert ohne Einheit
- # Messwandlersteuerung
- hx.power_down()
- hx.power_up()
- # LCD Bereinigung
- lcd.lcd_clear()
- # Messwerte auf LCD schreiben
- lcd.lcd_display_string(str(weight), 2) # Gewichtsanzeige mit Einheit
- hx.time_sleep
- #lcd.lcd_display_string(str(val), 2) # Rohwert auf LCD
- #if Capacity < weight:
- #print ("überlast")
- #else:
- # print weight
- except (KeyboardInterrupt, SystemExit):
- cleanAntExit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement