Advertisement
Guest User

Waage

a guest
Aug 27th, 2018
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.49 KB | None | 0 0
  1. # -*-coding: utf-8 -*-
  2. import lcddriver
  3. import RPi.GPIO as GPIO
  4. import time
  5. import sys
  6. import math
  7. from hx711 import HX711
  8. from time import *
  9.  
  10. # Script Unterbrechung / Schleifenbeendigung per STRG + C
  11. #def cleanAndExit():
  12.     #print "Aufräumen"
  13.     #GPIO.cleanup()
  14.     #print "Tschüß!"
  15.     #sys.exit()
  16.  
  17. # Messwandler Anschlüsse
  18. hx = HX711 (5, 6)
  19.  
  20. # Waagenparameter
  21. capacity = 80000
  22. unit = 'g'
  23. division = 1.000
  24.  
  25. # Kalibrierparameter
  26. hx.set_reference_unit(131)
  27.  
  28. # Nullsetzparameter
  29. hx.reset()
  30. hx.tare()
  31.  
  32. # Schnittsetllenbeschreibung
  33. lcd = lcddriver.lcd()               #LCD
  34.  
  35. # Schleifenbeginn RV=Raw Value / WV=Weight Value
  36. while True:
  37.     try:
  38.         RV = max(0, int(hx.get_weight(5)))      # Rohwert ohne Einheit
  39.         WV = RV/division                        # Rohwert / Teilung
  40.         weight = WV; unit                       # Gewicht mit Einheit
  41.  
  42.         print weight
  43.         #print hx.get_weight(5)/100             # Messwert ohne Einheit
  44.  
  45.         # Messwandlersteuerung
  46.         hx.power_down()
  47.         hx.power_up()
  48.  
  49.         # LCD Bereinigung
  50.         lcd.lcd_clear()
  51.  
  52.         # Messwerte auf LCD schreiben
  53.         lcd.lcd_display_string(str(weight), 2)  # Gewichtsanzeige mit Einheit
  54.  
  55.         hx.time_sleep
  56.  
  57.         #lcd.lcd_display_string(str(val), 2)    # Rohwert auf LCD
  58.         #if Capacity < weight:
  59.             #print ("überlast")
  60.         #else:
  61.            # print weight
  62.  
  63.     except (KeyboardInterrupt, SystemExit):
  64.         cleanAntExit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement