BeagleBone Black with HX711

24 views
Skip to first unread message

Jelle

unread,
Aug 24, 2017, 8:41:18 AM8/24/17
to BeagleBoard
Hi All,

I tried to manage to get the code below started but it's doesn't work. I'm using the adafruit libary for using the GPIO functions off the beagle bord. Any one any idea wy the code isn't working?? I try to reach a HX711 adc chip over the SPI bus.

import Adafruit_BBIO.GPIO as GPIO
import time

DAT = "P9_20"
CLK = "P9_21"
GPIO.setwarnings(False)
GPIO.setup(CLK, GPIO.OUT)

def test():
    i=0
    GPIO.setup(DAT, GPIO.OUT)
    GPIO.output(DAT,1)
    GPIO.output(CLK,0)
    GPIO.setup(DAT, GPIO.IN)

    while GPIO.input(DAT) == 1:
        num=0
        i=0
        for i in range(24):
            GPIO.output(CLK,1)
            num=num<<1

            GPIO.output(CLK,0)

            if GPIO.input(DAT) == 0:
                num=num+1

        GPIO.output(CLK,1)
        num=num^0x800000
        GPIO.output(CLK,0)
        print("test :", num)
while True:
    test()

Regards,

Jelle
Reply all
Reply to author
Forward
0 new messages