Skip to content

TMP112 Module

The TMP112 is device is a digital temperature sensor with high accuracy from Texas Instrument (datasheet).

The default communication protocol is I2C. To use this module create a TMP112 instance by passing the I2C peripheral name to which it is connected to. Using the module is simple:

from texas.tmp112 import tmp112
import streams
streams.serial()
tmp = tmp112.TMP112(I2C0)
while True:
    print("Temperature:",tmp.temperature())
    sleep(1000)
class TMP112

class TMP112(drvname, clock=100000, addr=0x49)

Creates a TMP112 instance using the MCU I2C circuitry drvname (one of I2C0, I2C1, … check pinmap for details). The created instance is configured and ready to communicate. clock is configured by default in slow mode.

TMP112 inherits from i2c.I2C, therefore the method start() must be called to setup the I2C channel before any temperature can be read.

The TMP112 can have 4 different I2C addresses determined by the wiring:

  • A0 connected to GND: 0x48
  • A0 connected to Vdd: 0x49
  • A0 connected to SDA: 0x4A
  • A0 connected to SCL: 0x4B
TMP112.temperature

temperature()

Returns the object temperature in Celsius.