Hello Temperature

Since this project uses the temperature sensor, let's start by exploring how it works and behaves. You can read some technical details in the Lesson #0 Guide. And for reference, here is where the temperature sensor is located on the Circuit Playground.

There is an example sketch included with the Circuit Playground library that we can use to play around with the temperature sensor. It can be found in the following location:

File -> Examples -> Adafruit Circuit Playground -> Hello_CircuitPlayground -> Hello_Temperature

With this sketch loaded and running on the Circuit Playground, open the Serial Monitor.

Tools -> Serial Monitor

The current value from the temperature sensor will be printed once a second.

Try breathing on the temperature sensor. You should see the value increase, and then slowly decrease when you stop. Now try holding your finger on the sensor. Did the temperature go up?

Another way to watch the values of the temperature sensor is to use the Serial Plotter. To do this, let's first modify the code slightly. The code below changes the format of the output to work with the Serial Plotter and increases the rate at which the values are displayed.

#include <Adafruit_CircuitPlayground.h>

float tempC, tempF;

void setup() {
  Serial.begin(9600);
  CircuitPlayground.begin();
}

void loop() {
  tempC = CircuitPlayground.temperature();
  tempF = CircuitPlayground.temperatureF();

  // Uncomment one of the following.
  //Serial.println(tempC);
  Serial.println(tempF);

  delay(100);
}

With this sketch loaded and running on the Circuit Playground, open the Serial Plotter.

Tools -> Serial Plotter

The temperature sensor value will now be plotted like a strip chart as shown below. Again, try breathing on the sensor to watch the value increase and then decrease.

Last updated on 2016-11-01 at 12.39.48 PM Published on 2016-11-01 at 01.39.41 PM