Hardware Reference
In-Depth Information
This is a graphical way of telling you that there is a device on I2C bus 1, with the numeric
identifier 48. This is your TMP102 sensor.
Hey, That Didn't Work!
If you try the command to install i2ctools and lm-sensors on a default install
of Raspbian, it will look like this:
$ su -c 'i2cdetect -y 1'
Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file
or directory
Why? Raspbian's kernel has CONFIG_I2C_CHARDEV and CONFIG_I2C_BCM2708
enabled as modules, instead of built in to the kernel like Pidora does (and
like we recommend). If you got this error, it means you didn't build a custom
kernel, as recommended in Hack #22 . Go back and do that now. If you do not
and you just load these modules, you'll run into trouble trying to access the
TMP102, because that driver isn't built at all in Raspbian.
If you did build a custom kernel, but left CONFIG_I2C_BCM2708 as a module
for some reason, you can manually load the i2c-dev module with this com-
mand:
$ su -c 'modprobe i2c-bcm2708'
That will make /dev/i2c-1 appear, and your i2cdetect invocation will suc-
ceed.
You now know that our TMP102 device is device number 48 on I2C bus 1, but you need
to tell the Linux kernel that it exists:
$ su -c 'echo tmp102 0x48 > /sys/class/i2c-adapter/i2c-1/new_device'
At this point, you are ready to start reading temperature data from your TMP102 sen-
sor. The standard tool for doing this in Linux ( lm_sensors ) comes with a library ( lib
sensors ) that lots of tools support, but as a beginning point, you are going to use the
included sensors command:
$ sensors
bcm2835_thermal-virtual-0
Adapter: Virtual device
temp1: +42.8°C
tmp102-i2c-1-48
Adapter: bcm2708_i2c.1
temp1: +24.8°C (high = +160.0°C, hyst = +150.0°C)
 
Search WWH ::




Custom Search