NAME
Device::Temperature::TMP102 - I2C interface to TMP102 temperature sensor using Device::SMBus
DESCRIPTION
Read temperature for a TMP102 temperature sensor over I2C.
This library correctly handles temperatures below freezing (0°C).
TROUBLESHOOTING
Refer to the documentation on Device::SMBus for information on enabling the i2c driver and finding the addresses of your i2c devices.
In the process of testing this on raspberry pi, I saw this error:
perl: symbol lookup error: .../Device/SMBus/SMBus.so: undefined symbol: i2c_smbus_write_byte
The fix was to install the package libi2c-dev.
SEE ALSO
https://www.sparkfun.com/products/9418
https://www.sparkfun.com/datasheets/Sensors/Temperature/tmp102.pdf
http://donalmorrissey.blogspot.com/2012/09/raspberry-pi-i2c-tutorial.html
SOURCE
With code and comments taken from example code for the ATmega328:
http://www.sparkfun.com/datasheets/Sensors/Temperature/tmp102.zip
/*
TMP Test Code
5-31-10
Copyright Spark Fun Electronics© 2010
Nathan Seidle
Example code for the TMP102 11-bit I2C temperature sensor
You will need to connect the ADR0 pin to one of four places. This
code assumes ADR0 is tied to VCC. This results in an I2C address
of 0x93 for read, and 0x92 for write.
This code assumes regular 12 bit readings. If you want the
extended mode for higher temperatures, the code will have to be
modified slightly.
*/
VERSION
ATTRIBUTES
I2CDeviceAddress
Contains the I2CDevice Address for the bus on which your TMP102 is connected. The default value is 0x48.
METHODS
getTemp()
$self->getTemp()
Returns the current temperature, in degrees Celsius.
convertTemp()
$self->convertTemp( $reading )
Given a value read from the TMP102, convert the value to degrees Celsius.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 93:
Non-ASCII character seen before =encoding in '(0°C).'. Assuming UTF-8