Temperature

Find the temperature where you are. The temperature is measured in Celsius (metric) or Fahrenheit (imperial). The Adafruit Circuit Playground Express can find the temperature nearby by checking how hot its computer chips are.

input.temperature(TemperatureUnit.Celsius);

Parameters

  • unit: the unit of temperature, either Celsius or Fahrenheit.

Returns

  • a number that means the temperature in degrees of Celsius or Fahrenheit.

How does it work?

The Adafruit Circuit Playground Express checks how hot its CPU (main computer chip) is. Because the Adafruit Circuit Playground Express does not usually get very hot, the temperature of the CPU is usually close to the temperature of wherever you are. The Adafruit Circuit Playground Express might warm up a little if you make it work hard, though!

Examples

Adafruit Circuit Playground Express thermometer

Use temperature and set all to vary the brightness of the pixels depending on the temperature in the room.

let pixels = light.createStrip();

forever(() => {
    pixels.setBrightness(Math.map(
        input.temperature(TemperatureUnit.Celsius),
        0,
        50,
        0,
        255
    ));
    pixels.setAll(0xff0000);
});

Fahrenheit thermometer

Measure the temperature using degrees in Fahrenheit.

let pixels = light.createStrip()

forever(() => {
    pixels.setBrightness(Math.map(
        input.temperature(TemperatureUnit.Fahrenheit),
        30,
        100,
        0,
        255
    ));
    pixels.setAll(0xff0000);
})

Try this

Try comparing the temperature your Adafruit Circuit Playground Express shows to a real thermometer in the same place. You might be able to figure out how much to subtract from the number the Adafruit Circuit Playground Express shows to get the real temperature. Then you can change your program so the Adafruit Circuit Playground Express is a better thermometer.

See also

on temperature condition changed