I am currently trying to communicate with the Honeywell HAFUHT0300L4AXT over I2C. Datasheet can be found here:
https://www.mouser.com/datasheet/2/187/honeywell-sensing-zephyr-digital-...
My wiring is as follows:
Pin1(NC) - NC
Pin2(SCL) - FIO6
Pin3(VDD) - VS
Pin4(GND) - GND
Pin5(SDA) - FIO7
Pin6(NC) - NC
There are no pullup resistors in circuit (do I need some? VS is 5V).
My code is as follows:
def main():
"""Demo"""
while True:
response = d.i2c(
Address=0x49,
I2CBytes=[0x01],
NumI2CBytesToReceive=2,
SCLPinNum=6,
SDAPinNum=7,
)
print(response)
bytes = response['I2CBytes']
hex_form = [hex(x) for x in bytes]
# it is now time to convert the response into a more readable number
print(hex_form)
time.sleep(1)
My output is as follows:
{'AckArray': [0, 0, 0, 0]}
{'AckArray': [0, 0, 0, 0]}
{'AckArray': [2, 0, 0, 0], 'I2CBytes': [255, 127]}
['0xff', '0x7f']
{'AckArray': [2, 0, 0, 0], 'I2CBytes': [255, 127]}
['0xff', '0x7f']
{'AckArray': [2, 0, 0, 0], 'I2CBytes': [255, 255]}
['0xff', '0xff']
{'AckArray': [2, 0, 0, 0], 'I2CBytes': [255, 255]}
['0xff', '0xff']
{'AckArray': [2, 0, 0, 0], 'I2CBytes': [255, 127]}
['0xff', '0x7f']
Ack array value of 2 does not match up to bytes sent of 1 based on documentation here:
https://labjack.com/support/datasheets/u6/low-level-function-reference/i2c
n = 1
(2^(n+1))-1 = 3
What am I doing wrong? Is it a pullup resistor, or something in the code?
You should have pull-ups to the supply voltage installed on the SDA and SCL lines. This may be the issue. The datasheet recommends 4.7kΩ with a minimum value of around 3kΩ (should not exceed 2mA on the lines).
You should have an ack for every data byte sent, so that would be one for the address byte (write command), one for the command byte, and one for the address byte (read command). The correct AckArray value should be 7.
Great thank you, I am now receiving the serial number of the sensor.