Home CodeCircuitpython Raspberry Pi Pico and PCT2075 temperature-to-digital converter circuitpython example

Raspberry Pi Pico and PCT2075 temperature-to-digital converter circuitpython example

by rp2040guy71

In this article we connect a PCT2075 temperature-to-digital converter to a Raspberry Pi Pico running Circuitpython

Sensor Information

The PCT2075 is a temperature-to-digital converter featuring ±1 °C accuracy over ‑25 °C to +100 °C range. It uses an on-chip band gap temperature sensor and Sigma-Delta A‑to‑D conversion technique with an overtemperature detection output that is a drop-in replacement for other LM75 series thermal sensors.

The device contains a number of data registers: Configuration register (Conf) to store the device settings such as device operation mode, OS operation mode, OS polarity and OS fault queue; temperature register (Temp) to store the digital temp reading, set-point registers (Tos and Thyst) to store programmable overtemperature shutdown and hysteresis limits, and programmable temperature sensor sampling time Tidle, that can be communicated by a controller via the 2-wire serial I²C-bus Fast-mode Plus interface.

The PCT2075 also includes an open-drain output (OS) which becomes active when the temperature exceeds the programmed limits. The OS output operates in either of two selectable modes: OS comparator mode or OS interrupt mode. Its active state can be selected as either HIGH or LOW. The fault queue that defines the number of consecutive faults in order to activate the OS output is programmable as well as the set-point limits.

The PCT2075 can be configured for different operation conditions. It can be set in normal mode to periodically monitor the ambient temperature, or in shut-down mode to minimize power consumption.

The temperature register always stores an 11-bit two’s complement data, giving a temperature resolution of 0.125 °C. This high temperature resolution is particularly useful in applications of measuring precisely the thermal drift or runaway. When the device is accessed the conversion in process is not interrupted (that is, the I²C-bus section is totally independent of the Sigma-Delta converter section) and accessing the device continuously without waiting at least one conversion time between communications will not prevent the device from updating the Temp register with a new conversion result. The new conversion result will be available immediately after the Temp register is updated. It is also possible to read just one of the temperature register bytes without lock-up.

The PCT2075 powers up in the normal operation mode with the OS in comparator mode, temperature threshold of 80 °C and hysteresis of 75 °C, so that it can be used as a stand-alone thermostat with those pre-defined temperature set points. The default set points can be modified during manufacture and ordered under custom part number.

There are three selectable logic address pins with three logic states so that 27 8-pin devices or three 6-pin devices can be connected on the same bus without address conflict.

This is the sensor that I bought

 

 

Parts Required

The sensor you can pick up in the $6 price range – you can connect to the sensor using a standard header the classic dupont style jumper wire.

I used a Qwiic cable – since a few sensors seem to use these but this is optional

Name Link
Pico Raspberry Pi Pico Development Board
PCT2075 Aliexpress link

Amazon link

Connecting cables Aliexpress product link

Lysee 3D Printer Parts & Accessories – AHT20 Temperature and Humidity Sensor Module DHT11 Upgrade I2C XD Humidity Sensor Probe – (Color: Green)

Ebay link

 

Schematic/Connection

I used the Adafruit PCT2075 sensor and in this case used the Stemma connection

For the STEMMA QT cables, it uses the Qwiic convention:

Black for GND
Red for V+
Blue for SDA
Yellow for SCL

So color coded for ease of use, this layout shows a connection to the module

rp2040 and pct2075

rp2040 and pct2075

Code Example

I used Thonny for development

The following is based on a library , I copied the adafruit_pct2075.mpy library for this device to the lib folder on my Raspberry Pi Pico – https://circuitpython.org/libraries

This is the basic example which comes with the library

[codesyntax lang=”python”]

import time
import board
import adafruit_pct2075
import busio

# Create sensor object, communicating over the board's default I2C bus
i2c = busio.I2C(scl=board.GP1, sda=board.GP0)
pct = adafruit_pct2075.PCT2075(i2c)

while True:
    print("Temperature: %.2f C" % pct.temperature)
    time.sleep(0.5)

[/codesyntax]

Output

Here is what I saw in Thonny REPL window

Temperature: 24.38 C
Temperature: 24.75 C
Temperature: 25.13 C
Temperature: 25.25 C
Temperature: 25.50 C

Links

Datasheet

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More