Lesson goal: Measure the temperature of the room you're in

Previous: Read a voltage | Home | Next: Real time temperature plot

As seen in the last lesson, you can read voltages in from the Arduino. This lesson will show you how to read the real temperature in the room you're in. It uses a device called the LM35DZ. This device outputs a voltage of 0.01 Volts for every $1^\circ$C in temperature of its environment.

Let's use the LM35DZ to read in some temperatures (100 of them), and use the linear mathematical relationship between $^\circ F$ and $^\circ C$ to display the temperature in both Celsius and Farenheight.

As you run through this lesson, try to watch the numbers in both $^\circ C$ and $^\circ F$ carefully. Which scale seems to show more change in response to the local temperature? (This is a key different between the two temperature scales.)

analogread(pin)
Move the mouse over a dotted box for more information.

Now you try. Can you figure out to 1) Make the voltage into the temperature in $^\circ C$, then 2) into $^\circ F$?

Type your code here:


See your results here:

The LM35DZ is a remarkable device. It is essentially an electronic thermometer. If you apply power to it (5V on its leftmost pin, 0V on its rightmost pin), the middle pin$\times 100$ will be the temperature in $^\circ C$.

Here's what your Arduino assembly might look like for this lesson:

Dismiss.
Show a friend, family member, or teacher what you've done!

Here is a share link to your code:

Does your code work? Want to run it on your iPhone?

Here's your code:

  1. Use [Control]-[C] (Windows) or [⌘]-[C] (MacOS) to copy your code.

  2. Paste it using [Control]-[V] (Windows) or [⌘]-[V] (MacOS) into this page

  3. Then click the "Use on iPhone" button that you'll see.