Closed thymjan closed 9 years ago
Hi Stefan, Thanks for using my code! It sounds like your problem is pretty straight forward; you need to change part of the code. Since you have a RaspberryPi A+ the i2c bus is numbered differently than on my RaspberryPi B. Go to line 37 in HTU21DF.py and change "bus = 1" to "bus = 0” Your wiring sounds perfect. Here’s a fresh copy of the library as well as a little python script to test it. Just put them in the same folder and run "sudo python HTU21DF_test.py" Remember to change line 37 in HTU21DF.py
Also, do you have the PIGPIO library installed? It’s the library the driver uses for i2c read/writes. You can get it at http://abyz.co.uk/rpi/pigpio/index.html http://abyz.co.uk/rpi/pigpio/index.html
Dana Alexander Gray +1 (530) 746-8467 dalexgray@mac.com dalexgray.com
On Aug 10, 2015, at 13:09 , Stefan Theurer notifications@github.com wrote:
Hi! I hooked up a HTU21D-F Humidity Sensor (adafru.it/1899) to my raspberry pi A+. Was very lucky to find your code. I've installed it and received errors: opening /dev/i2c-1 htu21df_init:htu21df I2C_RDWR failed -1/5 i2c_init failed -1
Now I'm stuck. Can you give me a hint? "sudo i2cdetect -y 1" shows there must be something at dress 0x40. So I think I've wired it right (VIN=Pin1 3.3VDC, GND=Pin9 Ground, SDA=Pin3 SDA1, SCL=Pin5 SLC1). Stefan
— Reply to this email directly or view it on GitHub https://github.com/bbx10/htu21dflib/issues/2.
@dalexgray you must be talking about a different driver. htu21dflib is written in C, not python.
@thymjan Try running with sudo. I am not sure what else could go wrong. /dev/i2c-1 is the correct port. The wiring is correct.
Thanks for your answer. I tried sudo ./htu21dflib
but received same error-message.
The error occurs at the first call of ioctl
in function htu21df_init
.
Maybe there is something going wrong with the user rights?
Answer from ls -l /dev/i2c*
is
crw-rw---T 1 root i2c 89, 1 Aug 10 20:25 /dev/i2c-1
I see the same user rights on my B+. sudo should work any way.
Does the htu21df board work on an Arduino using the Adafruit drivers? If not, there could be soldering problems or other problem with the breakout board.
Tested it a minute ago on my arduino micro, works fine!
htu21df_init:step 1: htu21df I2C_RDWR failed -1/5
Do you know what the 5 means? Is this error Nr. 5?
ERRORS
EBADF fd is not a valid descriptor.
EFAULT argp references an inaccessible memory area.
EINVAL request or argp is not valid.
ENOTTY fd is not associated with a character special device.
ENOTTY The specified request does not apply to the kind of object that the descriptor fd references.
(from man-page ioctl)
Ohhh. I'm stupid. Attached the ground to the wrong pin. Now it works. Sorry about that. Thanks for your help.
Hi! I hooked up a HTU21D-F Humidity Sensor (adafru.it/1899) to my raspberry pi A+. Was very lucky to find your code. I've installed it and received errors: opening /dev/i2c-1 htu21df_init:htu21df I2C_RDWR failed -1/5 i2c_init failed -1
Now I'm stuck. Can you give me a hint? "sudo i2cdetect -y 1" shows there must be something at dress 0x40. So I think I've wired it right (VIN=Pin1 3.3VDC, GND=Pin9 Ground, SDA=Pin3 SDA1, SCL=Pin5 SLC1). Stefan