DigitalSandbox PicoBoard

Pages
Contributors: bri_huang
Favorited Favorite 1

Reporting Temperature

Using the temperature scale on the Digital Sandbox is pretty simple - it does require a little math, though. Looking at the datasheet on the temperature sensor on this board TMP36 can be daunting, but what we care about is this:


"The TMP36 is specified from −40°C to +125°C, provides a 750 mV output at 25°C, and operates to 125°C from a single 2.7 V supply." and "Both the TMP35 and TMP36 have an output scale factor of 10 mV/°C."


Translation

The TMP36 outputs a voltage that varies linearly with the temperature. Because it is linear, we can start with our favorite equation from Algebra I -- the general equation for a line:

y = mx + b

Temp = (slope) * (voltage) + b

The proportionality (ratio) between voltage and temperature is 10 mV/°C, but we want our slope in units of °C/mV. So, if we take the reciprocal of 10 mV/°C, this is 0.1 °C/mV. It's the same proportion, and it has the correct units. That's our slope!

The intercept point requires a little math. Using the information that says "provides a 750 mV output at 25°C," we can find the intercept point.

25 °C = (0.1 °C/mV)(750 mV) + b

25 °C = 75 °C + b

-50 °C = b

Final Equation

Temp (°C) = (0.1 °C/mV) * (voltage in mV) - 50 °C

In Scratch

In Scratch, the voltage is scaled from 0 to 100. So -- let's see how this works:

Temp = (0.1 °C/mV) * (voltage in Scratch/100)*(5000 mV) - 50 °C

Looking at this, I see a lot of decimals, multiplication by 1000's and divide by 100s. It seems like we should be able to simplify this. First, let's simplify the divide by 100 and multiply by 5000.

Temp = (0.1 °C/mV) * (voltage in Scratch*(50 mV) - 50 °C

Next, multiply the 0.1 by the 50 and simplify to:

Temp = (voltage in Scratch*(5 °C) - 50 °C

And, in Scratch -- this looks like:

alt text