Closed loewexy closed 7 years ago
My first impression is the following: According to the datasheet, the HTU21 has a fixed i2c address of 0x40: "... I²C header consist of a 7-bit I²C device address 0x40 ..." You can also find it in the adafruit library.
But you are trying to talk to a slave at address 0x80 in brzo_i2c_start_transaction(0x80, 100)
. You should use brzo_i2c_start_transaction(0x40, 100)
instead. Note that brzo_i2c_start_transaction takes the 7-bit slave address, you don't have to shift left the address by yourself, the library takes care of that.
Please let me know, if you were able to read out the User register of your HTU21. paško
I should have mentioned that I tried both adresses 0x40 and 0x80 in fact I also built a loop cycling through all integers from 0 to 255 with no success.
I assume your hardware setup (pullups etc) is fine and the HTU21 works with the adafruit (wire) library, right? Currently I don't have an HTU21, so I cannot check. And I will be away from tomorrow on (holidays without IoT ;) but when I return, I will check.
The hardwaresetup should be correct. The Wire Libary did not work correct for me. I viewed the Signals on a scope and there were only two pulses. On on SDA one on SDL but it was no valid I2C. This is the reason I searched for another libary.
brzo i2c is working with HTU21:
I've added an HTU21 example. It outputs the temperature (without CRC checking) every 5 seconds. I had a couple of issues with adafruit's breakout board, please read the readme.
Please note that the current version 1.00 of brzo i2c supports only clock stretching up to 5 msec. I will enhance this to support longer timouts, see issue..
Therefore, get_temp_hold_master(float *t)
will lead to brzo error 8, since HTU21 needs up to 50 msec.
But I've already changed this in my local version, and I can confirm it is working.
EDIT: Version 1.01 released, supports longer timeouts now.
I am failing to get your lib to work with the HTU21 Temperature/Humidity sensor. I am not quite shure if this is a problem with the lib or with my code. I always get a return code of 2 when finishing the transaction.