Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I've always wondered this, how exactly are sensors interpreted by/for the microcontroller? Like lets use an example of a Heat Sensor...how exactly is something like say.....an Arduino interpreting the data? I mean using a LM35 Precision Centigrade Temperature Sensor which is pretty common but small at the same time.

share|improve this question
add comment

3 Answers

up vote 10 down vote accepted

I'm not familiar with the Arduino, but in general microcontrollers interface with a sensor in one of two ways -- either as a voltage (using the ADC for input) or via a serial bus such as I2C or SPI.

The LM35 outputs a voltage proportional to the temperature in degrees Centigrade, so you would interface its output to the ADC input of the Arduino.

The raw output of the LM35 is 10 mv/degree C, so 2 degrees C would be 20 mv, 100 degrees C would be 1 volt, and room temperature (22 deg C) would be 0.22 volts. Assuming a 10-bit ADC with a reference voltage of 3.3 volts, 0.22 v would be represented as 0.22/3.3*1024 or a count of 68.

Note that you are not using very much of the range of the ADC, even at 100 deg C. You could increase the voltage of the LM35 by adding a rail-to-rail op-amp with a gain of 5 which would allow you to measure 0 to 65 deg C and use the full range of the ADC. 0 deg would still be 0, 65 deg C would be 0.65*5/3.3*1024 or a count of 1008, and 22 deg C would be 0.22*5/3.3*1024 or a count of 341.

enter image description here

In order to measure temperatures below 0 deg C with the LM35, it would be necessary to provide a negative bias to the output (see the LM35 datasheet for details).

share|improve this answer
    
Wow nice explanation! I wonder if most temp. sensors try to stick to the same...voltage to degrees ratio? –  Mercfh Oct 13 '11 at 13:38
1  
@Sauron, all temperature to voltage converters that I am aware of are linear, but they may have different ratios. For example, the Microchip TC1046 formula is 6.25mV/degC + 424mV, and has a range of -40 degC to 125 deg C, or a voltage range of 0.174 volts to 1.205 volts. 0 deg C is 0.424 volts. So you can use it to measure freezing temperatures without any negative biasing tricks required by the LM35. –  tcrosley Oct 13 '11 at 17:49
1  
(continued) Devices like LM35 and TC1046 typically use the principles of the silicon bandgap equation but they are limited in range up to a few hundred degrees C. Above that, devices like thermistors and thermocouples are used, the latter can measure up to several thousand deg C but they require slightly more complicated interfaces and are not linear. –  tcrosley Oct 13 '11 at 18:08
    
Ok that makes sense, thanks for the explanatioN! –  Mercfh Oct 14 '11 at 17:53
add comment

For a microcontroller to act on a signal, it has to be turned into a sequence of numbers that represent the signal. Most commonly, the signal is a voltage and it is periodically sampled with a A/D (analog to digital converter). That produces a number proportional to the voltage every time it does a conversion. Most microcontrollers have A/Ds built in.

Small cheap micros may have 8 bit A/Ds, 10 bits is quite common, but 12 bits isn't too unusual either. After that, it gets difficult to construct the A/D accurately enough with the same process used to make the digital microcontroller. Past 12 bits therefore usually requires external A/Ds that interface digitally to the micro, such as via SPI or IIC, or less commonly today a bunch of parallel bits.

Once you have the analog signal represented as a sequence of numbers, you can apply all sorts of techniques to it. In fact, this is specifically what DSPs (digital signal processors) are optimized to do. Ordinary micros can do this too, but are slower at performing some of the fancy filtering operations. They are generally used in control applications as apposed to signal processing applications. For example, a micro might convert the voltage from a temperature sensor to a number in it's A/D, then use that number to decide how hard to run a fan.

share|improve this answer
add comment

Some temperature sensors output a voltage that can be fed into an ADC (much as tcrosley has suggested) but there are also devices with digital interfaces (e.g. DS18S20 which boasts a 1-wire digital interface) that return the temperature in degrees Celsius.

A Google search can provide multiple tutorials about interfacing the DS18S20 with an Arduino.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.