PiicoDev Precision Temperature Sensor TMP117 - Raspberry Pi Pico Guide

Here’s a new guide for PiicoDev Precision Temperature Sensor TMP117 - Raspberry Pi Pico Guide

You can find the full write-up here.

3 Likes

Looks awesome and super cheap!
Definitely going in my next project :smiley:

Liam.

1 Like

Very nicely presented tutorial! I’d like to use a different Pico I2C address, ie GP0 for SDA and GP1 for SCL. How do I change your code to do this, please?

Hey @Randy219721, welcome to the forums :smiley:

You can find additional documentation on the MicroPython repo.

To initialise on another pin or bus use the following initialisation. When deviating from the defaults you need to be explicit and provide the bus number, pin numbers and bus frequency. It’s not enough to just supply pins, for example.

For your project, to use Bus0 running at 100kHz, SDA=GP0 & SCL=GP1 you would use the following

from machine import Pin
sda = Pin(0)
scl = Pin(1)
tempSensor = PiicoDev_TMP117(bus=0, freq=100_000, sda=sda, scl=scl)

Happy Making :smiley:

1 Like

Thanks very much, Michael. That works fine!

Happy New Year from San Diego, CA.

Randy Houk

1 Like

Hi again, Michael.

I was able to see readings from the tmp117 the first time I tried the code after adding the 4 lines you sent me.

However, after I stopped then restarted the code it’s back to showing me these error messages:

Using supplied freq, sda and scl to create machine I2C
PiicoDev could not communicate with module at address 0x48, check wiring
PiicoDev could not communicate with module at address 0x48, check wiring
PiicoDev could not communicate with module at address 0x48, check wiring
nan °C

Here is my main.py

# PiicoDev TMP117 minimal example code
# This program reads the temperature from the PiicoDev TMP117 precision temperature sensor
# and displays the result in Degrees Celsius, Farenheit and Kelvin

from PiicoDev_TMP117 import PiicoDev_TMP117
from PiicoDev_Unified import sleep_ms # cross-platform compatible sleep function

from machine import Pin
sda= Pin(0)
scl=Pin(1)
PiicoDev_TMP117(bus=0, freq=100_000, sda=sda, scl=scl)

tempSensor = PiicoDev_TMP117() # initialise the sensor

while True:
# Read and print the temperature in various units
tempC = tempSensor.readTempC() # Celsius
tempF = tempSensor.readTempF() # Farenheit
tempK = tempSensor.readTempK() # Kelvin

# Convert temperature into a string and print the data
print(str(tempC) + " °C")

sleep_ms(1000) # delay 1 second

I know the Pico, cable and the TMP117 are good. I used the TMP117 on this Pi400. It’s the Pico-TMP117 interface giving me headaches!

Randy