Skip to content

Temperature Sensor Python Wireling

TinyCircuits Accelerometer Wireling product photo

This Wireling features the PCT2075 Temperature Sensor. This sensor has a range of -55°C up to 125°C and communicates over the I²C bus.

Technical Details
  • Temperature range from -55°C up to +125°C
  • 11 bit ADC that offers a temperature resolution of 0.125°C
  • Temperature accuracy of:
    • ±1 °C (max.) from -25 °C to + 100 °C
    • ±2 °C (max.) from -55 °C to + 125 °C
  • Programmable temperature threshold and hysteresis set points during operation
  • Supply current of <1.0 µA in shut-down mode for power conservation
  • Stand-alone operation as thermostat at power-up

    Power Requirements

    • Voltage: 3.0V - 5.5V 
    • Current: 70.0 µA (Normal Mode).  Due to the low current, this board can be run using the TinyDuino coin cell option
    • Current: <1.0 µA (Shut-Down Mode)

    Pins Used

    • A5/SCL - I²C Serial Clock line
    • A4/SDA - I²C Serial Data line

    Dimensions

    • 10mm x 10mm (.393 inches x .393 inches)
    • Max Height (from the lower bottom of Wireling to upper top Wireling Connector): 3.70mm (0.15 inches)
    • Weight: 1 gram (.04 ounces)

    Materials

    Hardware

    Required Software


    Hardware Assembly

    Plug your Wireling into the port you plan on using! The default in the included program is port 0.

    If you want to use a different port, you just need to change the port value in the program mentioned later.

    Note: Essential Modification

    Due to the peripherals included on the Pi Hat, an addressing resistor must be removed from the Wireling to be compatible. For this tutorial, we removed resistor A0 to set an address of 0x2C. This is different from the 0x48 address used by default. If the Wireling is modified by removing the A0 resistor, there will be no conflicts with any other Wirelings.

    Be mindful of this address change if trying to use this Wireling with our sample Arduino code!


    Programming

    Install the necessary Python package:

    pip3 install adafruit-circuitpython-pct2075
    

    Then you can download (above under Software) the Ambient Light Sensor Wireling example:

    AST1021-Temperature-Sensor-Wireling.py
    # TinyCircuits Temperature Sensor Wireling Example
    # Prints temperature value every 2 seconds.
    # Initialized: 01-24-2020
    # Last Updated: 01-24-2020
    
    import time
    import board
    import busio
    import tinycircuits_wireling
    import adafruit_pct2075
    
    # Initialize and enable power to Wireling Pi Hat
    wireling = tinycircuits_wireling.Wireling()
    
    # Toggle this variable to use the Light Sensor Wireling on a different port (0-3)
    port = 0
    wireling.selectPort(port)
    
    i2c = busio.I2C(board.SCL, board.SDA)
    pct = adafruit_pct2075.PCT2075(i2c, address=0x2c)
    
    pct.high_temperature_threshold = 35.5
    pct.temperature_hysteresis = 30.0
    pct.high_temp_active_high = False
    print("High temp alert active high? %s"%pct.high_temp_active_high)
    
    # Attach an LED with the Cathode to the INT pin and Anode to 3.3V with a current limiting resistor
    
    while True:
        print("Temperature: %.2f C"%pct.temperature)
        time.sleep(2)
    

    The program by default is written to work with Port 0 on the Wireling Pi Hat.


    Run Program

    Navigate in the terminal to the directory where you downloaded or saved the python example and run:

    python3 AST1021-Temperature-Sensor-Wireling.py
    

    Be sure pigpiod is running before you attempt to run the python program. This is done by running the following command:

    sudo pigpiod
    

    The program will print the temperature reading from the sensor every 2 seconds.


    Downloads


    Contact Us

    If you have any questions or feedback, feel free to email us or make a post on our forum. Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it.

    Thanks for making with us!