I use a temperature and humidity sensor sht20. According to this link: http://www.sensirion.com/en/products/humidity-temperature/humidity-temperature-sensor-sht2x/ It is compatible with sht21, which has a linux kernel module driver in drivers/hwmon/sht21.c
For my raspberry Pi B+, I recompiled the kernel of 3.18.1+ to enable HWMON and SHT21 module. I successfully update the kernel image and modules to my Pi. And I refer to this link: http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=7086
Do below (as root):
root@raspberrypi:/home/pi# i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
And then,
echo sht21 0x40 > /sys/class/i2c-adapter/i2c-1/new_device
Do again,
root@raspberrypi:/home/pi# i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
I installed latest version lm_sensors by make && make install from the source code. Then I typed
root@raspberrypi:/home/pi# sensors
bcm2835_thermal-virtual-0
Adapter: Virtual device
temp1: +36.9掳C
sht21-i2c-1-40
Adapter: bcm2708_i2c.1
ERROR: Can't get value of subfeature temp1_input: I/O error
temp1: N/A
root@raspberrypi:/home/pi# sensors-detect
...
Sorry, no sensors were detected.
...
Why?
Thanks!
i2cdetect
? It should still show up, and checking that might demonstrate that it is the driver that is the problem.UU
indicates "Probing was skipped, because this address is currently in use by a driver." (man i2cdetect
)? But just because someone wrote a driver for it doesn't mean it works (and it appears that it does not). Do you have a datasheet and documentation for the device? If you are decent with C, you could try going through that and using the smbus API to create a userspace driver. Probably not that much code...I have a C++ example of this for a temp/pressure sensor here.