sgp30-python icon indicating copy to clipboard operation
sgp30-python copied to clipboard

Error in get_unique_id function

Open simon3270 opened this issue 3 years ago • 1 comments

The SGP30 get_unique_id function returns the chip ID. The code at lines 124-126 of https://github.com/pimoroni/sgp30-python/blob/master/library/sgp30/init.py are:

def get_unique_id(self):
    result = self.command('get_serial_id')
    return result[0] << 32 | result[1] << 16 | result[0]

I believe that the third field on the last line should be result[2].

The code as written returned 000001120000 for my device. With my fix, it returned 000001127bf2.

I've done this as an issue rather than a Pull request, as I am not completely sure whether it is the first or the third field which should be result[2]. I realised there was a problem with the code because I've written a C++ Pico library for this device, and the unique IDs from the 2 sets of code differed. When writing the C++ code, I had assumed that the least significant word of the returned value was the third word in the data read from the chip. You may disagree ;-)

simon3270 avatar Mar 17 '21 14:03 simon3270