QWIIC Scale + RPI

Hello all,

I bought QWIIC Scale together with Qwiic HAT and 1kg load cell . I am using RPI4. I wrote some python code to read the values based on the Arduino platform. The problem is that the values (read from register 12/13/14) varies from 0 to 16777215. The connections I think that are good. I initialized the chip writing 0x6 in register 0x0 .

def Scale_getValue():
    status = 0
    myDeviceAddress = qwiic.scan()[0]
    if qwiic_i2c.isDeviceConnected(myDeviceAddress):
        with qwiic_i2c.getI2CDriver() as i2c:
            status = i2c.readWord(myDeviceAddress,0x0)
            if (status & (1<<3)):
                status=1
            else:
                status=0
    if (status == 0):
        i2c.writeWord(myDeviceAddress,0x0,0x6)
        Scale_getValue()
    else:
        raw= i2c.readBlock(myDeviceAddress,0x12,3)
    value = raw[0]<<16
    value = value | raw[1]<<8
    value = value | raw[2]
     
    return value

What do you think that the problem is?

Hi sandu_marius,

I am afraid SparkFun Tech Support cannot help troubleshoot and debug custom code but I think you are just getting the raw reading data here which looks reasonable. You need to convert the raw values to actual units and probably will also need to account for the [zero offset. I would recommend taking another look at the source files for the [Qwiic Scale Arduino Library.](GitHub - sparkfun/SparkFun_Qwiic_Scale_NAU7802_Arduino_Library: An Arduino library to interface with load cells using the Qwiic interface and the NAU7802.)](Qwiic Scale Hookup Guide - SparkFun Learn)