resistance progressively drops as more light is added (the
hand is raised), bringing it down to about 2900 Ω when
the light sensor is uncovered. This doesn’t really tell us
anything about the absolute value of that light as
measured in some accepted dimension such as lux, but it
does tell us that we are able to get a relative change in
voltage as a function of changes in light level due to
moving our hand. We will use these facts in our labs.
Sensing Temperature With
a Thermistor IC
A thermistor is a resistor whose resistance varies with
temperature. This is similar to the light
sensor that varies resistance with light
levels. The Arduino 101 Projects Kit
has a MCP9700A thermistor IC
(Integrated Circuit) that contains
signal-conditioning circuitry that
outputs a voltage proportional to the
change in temperature. This circuitry
simplifies our task since we can use
the Arduino ADC to measure the
voltage and directly translate the
reading to a temperature.
The IC uses a T0-92 package as
shown in Figure 4. Figure 5 shows
a drawing from the datasheet that
illustrates the pin locations. Figure 6
has the breadboard and schematic
symbols we will use. This device
measures in Celsius, and its accuracy is ± 2°C from - 40°C
to 125°C. For those of us in America, we translate Celsius
to Fahrenheit in our lab software using the following
formula: °F = °C x 9/5 + 32.
The MCP9700A outputs 10.0 mV/°C ( 10.0 millivolts
[.01 volts] per degree Celsius) scaled for 500 mV output at
0°C. Thus, if we measure 500 mV (0.5V) on the ADC, we
know the sensor is detecting 0°C. We can use this base
point (500 mV for 0°C) to calculate the voltage for the
maximum accurate temperature of 125°C, and the
minimum accurate temperature of - 40°C.
Stop for a moment and think about how you would
do this. First, look at the maximum accurate temperature:
125°C. We know that we have 500 mV for 0°C and that
the sensor outputs 10 mV per °C. This means we have
10 mV per °C for 125°C, so we will see an additional
10*125 = 1250 mV above the mV level for 0°C.
We add the mV at 0°C/500 mV to the 1,250 mV for
125°C, and calculate that we would read 1,750 mV as the
voltage for our maximum accurate temperature reading. If
this isn’t clear, then please write it out and do the
calculations by hand so you understand how to convert
from volts to temperature.
Let’s repeat this process to determine the voltage for
the minimum accurate temperature,
which is - 40°C. See if you can do this
before reading further. We have a total of
- 40°C, which would equal a -400 mV
change. Since we know that we would read 500 mV for
0°C, then we can subtract the 400 mV to get a - 40°C
reading of 500 - 400 = 100 mV. We now know that if we
read 100 mV, we have - 40°C; if we read 500 mV, we have
0°C; and if we read 1750 mV, we have 125°C. Got it?
We saw in Chapters 6 and 7 that our ADC looks at
voltages from zero to five volts, and divides that into
1024 steps with 0 being zero volts and 1023 being five
volts. We further saw that each ADC step represents
5/1024 = 0.00488 volts ( 4.88 mV). We know that the
sensor outputs 10 mV per °C, so how many steps in the
ADC output would indicate 10 mV?
We see that the 10 mV divided by 4.88 mV gives us
2.04918 steps, but the ADC steps are integers so we are
going to have to do some math here. Two steps of the
ADC ( 2 4.88 mV) equal 9. 77 mV, so two steps are pretty
close to a single °C change in temperature ( 10 mV).
Notice that the error between 10 and 9. 77 is just under
1%, and since the error for the sensor itself is 2% we
might be safe ignoring it and saying that two steps in the
ADC output is equal to exactly 1°C.
Doing that would allow us to use integers rather than
floating point data (a data type that has integer and
fractional parts divided by a decimal point), which uses a
November 2014 61
■ FIGURE 4:
■ FIGURE 6:
Temperature sensor breadboard
and schematic symbols.
■ FIGURE 5: