# Digital Sandbox Experiment Guide

Pages
Contributors: jimblom, bri_huang

"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:

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.

### 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):

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.

In 2003, CU student Nate Seidle fried a power supply in his dorm room and, in lieu of a way to order easy replacements, decided to start his own company. Since then, SparkFun has been committed to sustainably helping our world achieve electronics literacy from our headquarters in Boulder, Colorado.

No matter your vision, SparkFun's products and resources are designed to make the world of electronics more accessible. In addition to over 2,000 open source components and widgets, SparkFun offers curriculum, training and online tutorials designed to help demystify the wonderful world of embedded electronics. We're here to help you start something.