Skip to main content
Reading a TMP102 temperature sensor over I2C with the Binho Nova and Python, supported in India by GSAS

Tutorial: Reading a TMP102 Temperature Sensor with Binho Nova and Python

GSAS Engineering · · 5 min read

Tutorial: Reading a TMP102 Temperature Sensor with Binho Nova and Python

This tutorial walks through a complete I2C sensor read workflow using the Binho Nova and Python. We will connect to a TI TMP102 digital temperature sensor, scan the I2C bus to find it, read the temperature register, convert the raw data to degrees Celsius, and build a simple temperature logging script.

The TMP102 is a common I2C temperature sensor used in industrial monitoring, server thermal management, and battery pack temperature sensing. Its I2C interface and straightforward register map make it a good starting point for learning Binho Nova’s I2C capabilities.

What You Need

  • Binho Nova multi-protocol USB adapter
  • TMP102 breakout board (available from Adafruit, SparkFun, or equivalent suppliers)
  • 4 jumper wires
  • USB cable (included with Nova)
  • Python 3.7+ installed on your computer
  • Binho Python package (pip install binho)

Wiring

The TMP102 uses a standard I2C connection plus power and ground. Connect the Nova to the TMP102 breakout as follows:

Nova PinTMP102 PinFunction
IO0 (SCL)SCLI2C clock
IO1 (SDA)SDAI2C data
3V3VCCPower (3.3 V)
GNDGNDGround

The Nova provides a 3.3 V output on its power pin that can supply the TMP102 (which draws under 10 uA in continuous conversion mode). The I2C bus has internal pull-up resistors on most TMP102 breakout boards. If using a bare TMP102 chip, add 4.7 kOhm pull-up resistors on SDA and SCL to 3.3 V.

The TMP102’s I2C address depends on the ADD0 pin configuration:

  • ADD0 to GND: address 0x48
  • ADD0 to VCC: address 0x49
  • ADD0 to SDA: address 0x4A
  • ADD0 to SCL: address 0x4B

Most breakout boards default to 0x48 (ADD0 tied to GND).

Step 1: Install the Binho Python Package

pip install binho

This installs the Binho host adapter library, which provides Python classes for interacting with the Nova’s I2C, SPI, UART, and GPIO interfaces.

Step 2: Scan the I2C Bus

Before reading temperature data, confirm that the TMP102 is present and responding at the expected address. The following script scans all valid I2C addresses:

from binho import binhoHostAdapter

## Connect to Nova (auto-detects the first connected device)
binho = binhoHostAdapter.binhoHostAdapter()
binho.setOperationMode(0, 'I2C')
binho.setI2CFrequency(0, 400000)  # 400 kHz (Fast Mode)

print("Scanning I2C bus...")
for addr in range(0x08, 0x78):
    try:
        result = binho.readFromAddress(0, addr, 1)
        if result is not None:
            print(f"  Device found at 0x{addr:02X}")
    except:
        pass

print("Scan complete.")

If wiring is correct, you should see:

  Device found at 0x48

Step 3: Read the Temperature Register

The TMP102’s temperature register is at address 0x00. It contains a 12-bit (or 13-bit in extended mode) two’s complement value representing the temperature. The default resolution is 0.0625 degrees Celsius per LSB.

## Read 2 bytes from the temperature register (register 0x00)
## First, write the register pointer
binho.writeToAddress(0, 0x48, [0x00])

## Then read 2 bytes
temp_bytes = binho.readFromAddress(0, 0x48, 2)

## Convert to temperature
raw = (temp_bytes[0] << 4) | (temp_bytes[1] >> 4)

## Handle negative temperatures (two's complement, 12-bit)
if raw > 2047:
    raw -= 4096

temperature_c = raw * 0.0625
print(f"Temperature: {temperature_c:.2f} C")

At room temperature (approximately 25 degrees Celsius), you should see a value between 20 and 30 degrees. If you see 0.00 or an implausible value, check the wiring and verify the device address with the bus scan.

Step 4: Read the Configuration Register

The TMP102’s configuration register (0x01) controls conversion rate, alert functionality, and extended mode. Reading it confirms the sensor is in its default state:

## Read configuration register
binho.writeToAddress(0, 0x48, [0x01])
config = binho.readFromAddress(0, 0x48, 2)
print(f"Config register: 0x{config[0]:02X}{config[1]:02X}")

The default value is typically 0x60A0, indicating 4 Hz conversion rate, comparator mode, and 12-bit resolution.

Step 5: Build a Temperature Logger

Combining the above into a continuous temperature logging script:

from binho import binhoHostAdapter
import time
import csv
from datetime import datetime

binho = binhoHostAdapter.binhoHostAdapter()
binho.setOperationMode(0, 'I2C')
binho.setI2CFrequency(0, 400000)

TMP102_ADDR = 0x48

def read_temperature():
    binho.writeToAddress(0, TMP102_ADDR, [0x00])
    data = binho.readFromAddress(0, TMP102_ADDR, 2)
    raw = (data[0] << 4) | (data[1] >> 4)
    if raw > 2047:
        raw -= 4096
    return raw * 0.0625

## Log to CSV
with open('temperature_log.csv', 'w', newline='') as f:
    writer = csv.writer(f)
    writer.writerow(['timestamp', 'temperature_c'])

    print("Logging temperature. Press Ctrl+C to stop.")
    try:
        while True:
            temp = read_temperature()
            now = datetime.now().isoformat()
            writer.writerow([now, f"{temp:.2f}"])
            print(f"{now}: {temp:.2f} C")
            time.sleep(1.0)
    except KeyboardInterrupt:
        print("Logging stopped.")

binho.close()

This script reads the temperature every second and writes timestamped readings to a CSV file, useful for thermal characterization during board bring-up, environmental testing, or validating enclosure thermal design.

Next Steps

With basic I2C communication working, you can extend this approach to any I2C device: IMUs, pressure sensors, EEPROMs, PMICs, display controllers, and more. The Binho Nova’s support for I2C speeds up to 3.4 MHz covers the full range of I2C devices, from legacy 100 kHz standard mode sensors to high-speed 3.4 MHz high-bandwidth peripherals.

For teams in Bengaluru, Hyderabad, Chennai, and Pune working on multi-sensor IoT boards, the same Nova and Python approach scales to reading multiple I2C sensors in a single script, building a complete board-level diagnostic tool that exercises all I2C devices on the bus.

Why Buy from GSAS

GSAS Micro Systems is an authorized Binho engineering partner in India. We provide the Nova, Supernova, and Pulsar with INR invoicing and hands-on technical support. Our applications engineers in Bengaluru, Hyderabad, Chennai, Pune, Mumbai, and Delhi NCR help teams get started with Binho tools and develop scripted workflows for sensor validation, board bring-up, and production test. Contact us for evaluation units or a demo.

Interested in Binho tools?

Talk to our application engineers for personalized tool recommendations.

Frequently asked questions

Does I2C need pull-up resistors?
Yes. I2C is an open-drain bus: devices can only pull SDA and SCL low, so pull-up resistors are what return the lines high. Without them the bus never releases and no transaction completes. Most sensor breakout boards fit them already, which is why a bare chip on a breadboard often fails where the same part on a breakout works. A typical value at 3.3 V is 4.7 kOhm.
How are I2C addresses assigned?
They are fixed by the device, not negotiated. Each part has a 7-bit address set by its datasheet, usually with one to three address pins selecting between a small set of alternatives. The TMP102, for example, answers at 0x48, 0x49, 0x4A or 0x4B depending on whether its ADD0 pin is tied to GND, VCC, SDA or SCL.
Can two identical I2C sensors share one bus?
Only if their address pins are strapped differently, and only up to the number of alternatives the part offers. Beyond that you need an I2C multiplexer or a different bus. This constraint is one of the specific problems MIPI I3C's dynamic address assignment was designed to remove.
How do I convert a TMP102 reading to degrees Celsius?
Read two bytes from register 0x00, combine them as (first byte shifted left 4) OR (second byte shifted right 4) to recover the 12-bit value, treat it as two's complement by subtracting 4096 if it exceeds 2047, then multiply by 0.0625 degrees Celsius per LSB.
Which Binho adapter is right for I2C sensor work?
The Binho Nova covers it: Binho lists I2C up to 3.4 MHz, high-speed I2C, with 3.3 V logic and USB bus power. Step up to the Binho Pulsar if you also need RS-485 or a 50 MHz SPI controller, or to the Binho Supernova if MIPI I3C is on your roadmap.

Stay in the Loop

Get monthly compliance updates, product insights, and engineering best practices delivered to your inbox.

Related Articles

FPGA in the loop verification workflow between Simulink and a Zynq-7000 development board
Technical Guides Digilent

ZedBoard FPGA-in-the-Loop: HDL Verifier vs HDL Coder

Teams asking for FPGA-in-the-Loop on a ZedBoard usually name HDL Coder and SoC Blockset. FIL is actually HDL Verifier. Here is the correct product split, the JTAG versus Ethernet decision, and the 2015-era advice that is still sending Indian teams down the wrong path.

5 Aug 2026 · 9 min read
FADOS MUX test station on an Indian EMS line generating a board test report, GSAS FADOS reporting workflow
FADOS CBT Electronic

FADOS Test Reports and GSAS Agent: Turning Board Test Results into an Auditable Record

A pass or fail on the FADOS screen is not a record. This guide covers what the FADOS test report contains, what GSAS Agent does with it, and how offline, Google Drive and LAN modes put a QR-linked report on the job card for repair shops and EMS lines in India.

4 Aug 2026 · 8 min read
Classification tree and combination table used to design embedded unit test cases in Razorcat's Classification Tree Editor for TESSY, available in India from GSAS Micro Systems
Compliance & Safety Razorcat Automotive & Mobility

Test Case Design with the Classification Tree Method: Deriving Unit Tests You Can Defend in an Audit

Ad-hoc test cases can be perfectly good tests and still fail an audit, because nothing on file records why that particular set was sufficient. The Classification Tree Method derives test cases from the input space instead: identify the test-relevant aspects as classifications, partition each into equivalence classes, then combine leaf classes in a combination table. Razorcat implements CTM in the Classification Tree Editor, available integrated into TESSY or standalone. GSAS Micro Systems is the authorized Razorcat engineering partner for India, the UAE and Sri Lanka.

1 Aug 2026 · 10 min read