Digital Sandbox Experiment Guide

Contributors: Jimb0, bri_huang
Favorited Favorite 2

12: Thermal Alert!

“Is it hot in here, or is it just me?” Using a temperature sensor, which is able to precisely measure the room temperature, we can answer that question once and for all!

Background Information

Temperature sensors are a critical component in many circuits, whether you’re controlling an A/C system or creating a safety mechanism for gas-powered appliances. Electronic temperature sensors come in many form-factors, from big thermocouples that can measure up to 1000 °C to that little black rectangle on the Digital Sandbox.

The temperature sensor on the Sandbox produces an analog voltage that represents the temperature around it. The voltage is actually linearly proportional to the Celsius temperature. If you know the output voltage of the sensor, you can calculate the temperature with this equation:

temperature = (voltage - 0.5) \times 100

We can have the microcontroller do all of that math for us as long as we find the right algorithm - an equation or set of instructions that accomplish a specified task.

Active Parts

alt text

Code Components

We warned you there’d be a lot of math on this one; here’s the setup (click the image to see it bigger):

alt text

There aren’t any new blocks here but, as you can see, we do get to use a wide variety of mathematical operators. Pay close attention to the order of operations. When you have a series of nested mathematical operators, the innermost operation is calculated first.

Do This

Construct the drawing as shown above. Make sure the mathematical operations are in the right order! Also important is the decimal part (e.g. “.0”, “.5”, “.01”) on most of the numbers in these equations. Those tell the microprocessor that you want it to use extra precision when calculating.

After you’ve completed the drawing, upload the sketch and check out the RGB LED. Is it red or green? If it’s red, you’re probably plenty toasty, as your room temperature is above 78 °F. If it’s green, try warming up the sensor by blowing on it. Can you get it to turn red?

To find the exact temperature reading, open up the serial monitor. After viewing the values here, you may want to alter the value of the 78 in the if/else test.

Further Explorations

  • Can you add a third check to alert when it’s too cold by turning on the blue LED? The real trick here is cooling the Sandbox off. One option is to power the board with a battery and stick it in the fridge.
  • Celsius and Fahrenheit are two of the most common temperature scales, but they’re not the only ones. Can you print the temperature in units of Kelvin or Rankine? You’ll need to find an algorithm to convert to them from Celsius.