confusing return values
Posted: Tue Feb 23, 2021 5:02 pm
Hello,
after several attempts I finally managed to get my MLX90615 sensor working. But I noticed a strange behavior with the return values. The code lines look like this:
This works because a and b are of type integer in this case (I also checked with print(type(a))). According to the I2C documentation they should be byte objects. And if I do this:
then a is also of type bytes.
My question now is: Why does the first call result in two integer objects? I know, it is more a Python basic problem but I can“t find an answer for such a specific issue anywhere.
Thank you very much and best regards,
cyr
after several attempts I finally managed to get my MLX90615 sensor working. But I noticed a strange behavior with the return values. The code lines look like this:
Code: Select all
a, b = i2c.readfrom_mem(0x5B, 0x27, 2)
temp = int(hex(b)) + hex(a)[2:], 16)
Code: Select all
a = i2c.readfrom_mem(0x5B, 0x27, 1)
My question now is: Why does the first call result in two integer objects? I know, it is more a Python basic problem but I can“t find an answer for such a specific issue anywhere.
Thank you very much and best regards,
cyr