示例#1
0
    def __init__(self, dout, pd_sck, gain=128):
        self.PD_SCK = pd_sck

        self.DOUT = dout

        # Mutex for reading from the HX711, in case multiple threads in client
        # software try to access get values from the class at the same time.
        self.readLock = threading.Lock()
        
        GPIO.setmode(GPIO.WIRINGPI)
        GPIO.setup(self.PD_SCK, GPIO.OUT)
        GPIO.setup(self.DOUT, GPIO.IN)

        self.GAIN = 0

        # The value returned by the hx711 that corresponds to your reference
        # unit AFTER dividing by the SCALE.
        self.REFERENCE_UNIT = 1
        self.REFERENCE_UNIT_B = 1

        self.OFFSET = 1
        self.OFFSET_B = 1
        self.lastVal = int(0)

        self.DEBUG_PRINTING = False

        self.byte_format = 'MSB'
        self.bit_format = 'MSB'

        self.set_gain(gain)

        # Think about whether this is necessary.
        time.sleep(1)
示例#2
0
VOLTAGE_REF = 2.497  # value of the excitement voltage reference
THERMI_WIRE = 0.6  # value of the twin wire resistor

# Odroid configuration
GPIO.setmode(GPIO.BOARD)
# pin used
START_BTN_PIN = 15  # pin on which the start button is connected
PAUSE_BTN_PIN = 13  # pin on which the pause button is connected
STOP_BTN_PIN = 33  # pin on which the start button is connected
START_LED_PIN = 16  # pin on which the start led is connected
PAUSE_LED_PIN = 18  # pin on which the pause led is connected
STATE_LED_PIN = 8  # pin on which the state led is connected
BUZZER_PIN = 35  # pin on which the buzzer is connected
# pin configuration
GPIO.setup(START_BTN_PIN, GPIO.IN)
GPIO.setup(PAUSE_BTN_PIN, GPIO.IN)
GPIO.setup(STOP_BTN_PIN, GPIO.IN)
GPIO.pinMode(STOP_BTN_PIN, GPIO.PUD_UP)
GPIO.setup(START_LED_PIN, GPIO.OUT)
GPIO.setup(PAUSE_LED_PIN, GPIO.OUT)
GPIO.setup(STATE_LED_PIN, GPIO.OUT)
GPIO.setup(BUZZER_PIN, GPIO.OUT)

# Registre configuration
# coils
THERMIS_POW_REG = 0x00  # register which stores the thermistor power state
LEVEL1_FLAG_REG = 0x01  # register which stores the flag which enables/disables the level 1 sensor management
LEVEL2_FLAG_REG = 0x02  # register which stores the flag which enables/disables the level 2 sensor management
PRESS_FLAG_REG = 0x03  # register which stores the flag which enables/disables the pressure sensor management
PUMP_DIR_REG = 0x10  # register which stores the pump direction