Skip to content

Temperature Sensor 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

    TinyDuino 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

    To interface with any TinyCircuits Arduino board, you will need the Arduino IDE and a Micro USB Cable

    There are multiple processor/adapter combinations that can be used with Wirelings. Use the following table to find the combination that works for you.

    Processor Adapter
    *TinyDuino and USB TinyShield Wireling Adapter TinyShield
    *TinyZero Wireling Adapter TinyShield
    *TinyScreen+ Wireling Adapter TinyShield
    WirelingZero N/A
    *RobotZero N/A
    Arduino Wireling Arduino Shield
    Raspberry Pi Wireling Pi Hat

    * These processors have a 32-pin connector and can have multiple Wireling Adapter TinyShields stacked to increase the number of Wireling ports up to a maximum of 32 total Wireling ports.

    In order to interface with Wirelings, you'll need the appropriate number of Wireling Cables and the Wireling.h Library (You can download this from GitHub as linked, or from the Library Manager in the Arduino IDE).

    You will also need the Accelerometer Wireling and the included example Arduino sketch.

    Wireling Code
    Port 0 Temperature Sensor Example Sketch

    Hardware Assembly

    Depending on the development system you choose, you will need to put together a TinyDuino stack using the 32-pin tan connectors, or you will just need to plug in your Wireling to Port 0 using a Wireling Cable. (You can change this port in the included Arduino Sketch using the selectPort() function)

    NOTE: Be mindful when inserting Wireling Cables - the connector pins inside the 5-pin connectors on Wirelings can be bent when cables are inserted at an angle.


    Software Setup

    For this Wireling, you will need to download the TinyCircuits PCT2075 Arduino library:

    Download PCT2075 Arduino Library

    To install an Arduino library, check out our Library Installation Help Page.

    If you have not already, download the example sketch included above under the Materials section and open it in the Arduino IDE.

    Make the correct Tools selections for your development board. If unsure, you can double check the Help page that mentions the Tools selections needed for any TinyCircuits processor.


    Upload Program

    Code
    /*************************************************************************
     * PCT2075 Temperature Sensor Wireling Example 
     * Reads and outputs PCT2075 values to the Serial Monitor when uploaded, 
     * including Temperature in degrees Celsius/Fahrenheit, Thyst - hysteresis, 
     * Tos - threshold, and the configuration register.
     * 
     * Initiated: 8-10-2017 by Brandon Farmer for TinyCircuits
     * Updated: 8-8-2019 by Laveréna Wienclaw for TinyCircuits
     *************************************************************************/
    
    #include <Wire.h>
    #include <TinyCircuits_PCT2075.h>
    #include <Wireling.h>
    
    TinyCircuits_PCT2075 tempSensor = TinyCircuits_PCT2075();
    
    #if defined (ARDUINO_ARCH_AVR)
    #define SerialMonitorInterface Serial
    #elif defined(ARDUINO_ARCH_SAMD)
    #define SerialMonitorInterface SerialUSB
    #endif
    
    void setup() {
      SerialMonitorInterface.begin(9600);
      while(!SerialMonitorInterface);  // Blocks sensor printing data until Serial Monitor is opened
    
      // Enable and Power wirelings
      Wireling.begin();
    
      Wire.begin(); // begin I2C communication
      Wireling.selectPort(0);
    //  const int tempPin = 0;       //IO Pin D2 = Interrupt Pin 0 
    
      //Initialize the sensor with config settings
      tempSensor.begin(PCT2075_ACTIVE_LOW, PCT2075_COMPARATOR, PCT2075_NORMAL, PCT2075_FAULT_6X);
    
    //  pinMode(tempPin, INPUT_PULLUP);
    //  attachInterrupt(digitalPinToInterrupt(tempPin), interruptServiceRoutine, FALLING);
    
      tempSensor.wake(); // Wake up the module
    }
    
    void loop() {
      setup();
      float rawTemp = tempSensor.readTemp() / 32.0; // Divide by 32 to get rid of empty 5 LSB
      float tempC = (rawTemp * 0.125); // Conversion to degreesC noted on page 11 of datasheet
      float tempF = (tempC * 1.8 + 32); // Conversion from degreeC to degreeF
    
      if (tempSensor.checkMode() == 0) {
        tempSensor.writeOvertemp(30);
        tempSensor.writeHyst(29);
    
        SerialMonitorInterface.print("Temp.C = ");
        SerialMonitorInterface.print(tempC);
        SerialMonitorInterface.print(" C");
        SerialMonitorInterface.print("\t");
        SerialMonitorInterface.print("Temp.F = ");
        SerialMonitorInterface.print(tempF);
        SerialMonitorInterface.print(" F");
        SerialMonitorInterface.print("\t");
        SerialMonitorInterface.print("Thyst = "); // Hysteresis 
        SerialMonitorInterface.print(tempSensor.readHyst()); 
        SerialMonitorInterface.print("C");
        SerialMonitorInterface.print("\t");
        SerialMonitorInterface.print("Tos = "); // Threshold
        SerialMonitorInterface.print(tempSensor.readTos()); 
        SerialMonitorInterface.print("C");
        SerialMonitorInterface.print("\t");
        SerialMonitorInterface.print("Config: ");
        SerialMonitorInterface.print("0b");
        SerialMonitorInterface.print(tempSensor.readConfig(), BIN);
        SerialMonitorInterface.print("\t");
        SerialMonitorInterface.print("Mode = ");
        SerialMonitorInterface.println(tempSensor.checkMode()); 
        SerialMonitorInterface.println("---------------------------------------------------------------------------------------------------------------------------");
    
        delay(250);
    //    tempSensor.sleep();
      }
      else {
        SerialMonitorInterface.println("SENSOR IN SLEEP MODE!"); 
        SerialMonitorInterface.println(tempSensor.readConfig(), BIN);
        tempSensor.wake(); 
        delay(250);  
      }
    }
    

    To test the sensor, open the Serial Monitor and expose it to a change in temperature. This can be observed by covering the sensor with a finger, or applying cool/warm air.


    Projects

    You can make a weather station with this Wireling and a few others:

    Weather Station Project


    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!