GPIO setup for LM35 temperature sensor
I want to connect a three-wire LM35 precision temperature sensor to the Raspi's GPIO. Two of the wires will connect to the +5-v and earth pins. The third wire will then contain a voltage less than 5v, dependent upon the temperature. To which GPIO pins(s) may I connect this and what pin programme setup instructions (I presume one is for INPUT) will I need, please? May I assume what I then read programmatically from that pin will be a variable longint? Thanks for any instructions or comments.
If discrimination is not challenged then we are effectively in collusion with the perpetrators of such behaviour:-Oxford dictionaries
Re: GPIO setup for LM35 temperature sensor
You'll need an analogue to digital convertor for that. Have a look at http://learn.adafruit.com/reading-a-ana ... i/overview
Re: GPIO setup for LM35 temperature sensor
None, the ouput is analog there is no analog input directly on the Pi.
You need to create a suitable analog front end and connect to an A/D converter.
By the way that device can produce negative outputs as well as positive outputs.
If you are only measuring ambient at the chip, then consider finding an I2C or SPI fully integrated temperature sensor a lot less hassle, and fully calibrated solution. Creating your own A/D front end requires some wide temperature range front end design for a device that is speced to measure -40 to +100 deg C.
Powering from just 5V may no give you the accuracy and range you require.
You need to create a suitable analog front end and connect to an A/D converter.
By the way that device can produce negative outputs as well as positive outputs.
If you are only measuring ambient at the chip, then consider finding an I2C or SPI fully integrated temperature sensor a lot less hassle, and fully calibrated solution. Creating your own A/D front end requires some wide temperature range front end design for a device that is speced to measure -40 to +100 deg C.
Powering from just 5V may no give you the accuracy and range you require.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/
or http://www.pcserviceselectronics.co.uk/pi/
Re: GPIO setup for LM35 temperature sensor
That Pi doesn't have any analog input pins. The gpios are only 3.3V safe. You'll need additional hardware.
Re: GPIO setup for LM35 temperature sensor
Thanks to both in spite of the bad news. The hardware is already made. Having done it with Arduino, and used it in the flowpath of a hot vapour, I wanted to reuse it and do the same and better with Raspi. It just never occurred to me that the Raspi was inferior to the Arduino in this respect. Off to the adafruit and a lot more reading . . . .
If discrimination is not challenged then we are effectively in collusion with the perpetrators of such behaviour:-Oxford dictionaries
Re: GPIO setup for LM35 temperature sensor
A technique used on the Pi is to use the voltage to charge a capacitor through a resistor in a charge/discharge cycle. The voltage is calculated by timing how long it takes a gpio to register a high state after being discharged.feverish wrote:Thanks to both in spite of the bad news. The hardware is already made. Having done it with Arduino, and used it in the flowpath of a hot vapour, I wanted to reuse it and do the same and better with Raspi. It just never occurred to me that the Raspi was inferior to the Arduino in this respect. Off to the adafruit and a lot more reading . . . .
E.g. http://www.raspberrypi.org/phpBB3/viewt ... 38#p282038
Re: GPIO setup for LM35 temperature sensor
You may have to create an anlog front end to buffer and amplify and /or offset the voltage depending on the output voltage range you expect from the LM35 for your application. Then of course work out whether you want a 3V or 5V range A/D and 8/10/12/16 bit A/D converter.feverish wrote:Thanks to both in spite of the bad news. The hardware is already made. Having done it with Arduino, and used it in the flowpath of a hot vapour, I wanted to reuse it and do the same and better with Raspi. It just never occurred to me that the Raspi was inferior to the Arduino in this respect. Off to the adafruit and a lot more reading . . . .
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/
or http://www.pcserviceselectronics.co.uk/pi/
Re: GPIO setup for LM35 temperature sensor
After an overnight think, I'm going to try to tackle this by using an Arduino's ADC to do the measurement in the way already proven to work and then send a message from the Arduino to the Raspi, which can then use the Raspi's Lazarus Application for overall control and analysis.
I wonder if this is akin to using a sledgehammer to crack a nut but I'm now so hooked into learning a bit more about Raspi's capabilities it hardly matters.
The absence of a functional ADC in the GPIO scheme of things does, however, bother me somewhat and I'll be pondering that along the way. It seems to me to be a bit of a fundamental original omission, made, no doubt, for good enough reasons.
I wonder if this is akin to using a sledgehammer to crack a nut but I'm now so hooked into learning a bit more about Raspi's capabilities it hardly matters.
The absence of a functional ADC in the GPIO scheme of things does, however, bother me somewhat and I'll be pondering that along the way. It seems to me to be a bit of a fundamental original omission, made, no doubt, for good enough reasons.
If discrimination is not challenged then we are effectively in collusion with the perpetrators of such behaviour:-Oxford dictionaries
Re: GPIO setup for LM35 temperature sensor
The trouble is the SoC was not originally meant for situations where analog I/P occurs.
Then comes the problem with all microcontrollers/SoC that I have used over the years, is the A/D good enough for my application is 8/10 bits OK (the norm in MOST microcontrollers) get noise free A/D at 12/16 bits insode the same chip as other high frequency sections is difficult. Then there is the sampling speeds most are not very fast, and some cannot go slow enough depending on what application area they were intended for.
Let alone once you have A/D most people expect D/A as well and how many spare pins and analog channels do you have as Analog section need to be on dedicated pins, not multi-function for noise and other reasons.
Then comes the problem with all microcontrollers/SoC that I have used over the years, is the A/D good enough for my application is 8/10 bits OK (the norm in MOST microcontrollers) get noise free A/D at 12/16 bits insode the same chip as other high frequency sections is difficult. Then there is the sampling speeds most are not very fast, and some cannot go slow enough depending on what application area they were intended for.
Let alone once you have A/D most people expect D/A as well and how many spare pins and analog channels do you have as Analog section need to be on dedicated pins, not multi-function for noise and other reasons.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/
or http://www.pcserviceselectronics.co.uk/pi/
Re: GPIO setup for LM35 temperature sensor
Sure, and don't get me wrong, Raspi and folks like you have already given me multo help, but how many of those problems would worry schoolkids learning doing physics with a Raspi look-alike with an ADC? Weight, pressure, adjustable volume, temperature, density, heat-intensity, distance, echo stuff projects leap instantly to mind? The Arduino already caters for a lot of that but the Raspi is mooted as a programming-learning aid and is a wonderful innovation with that objective? Having spent all day feverishly
looking for a 'better' solution, I have fallen across alamode and cooking-hacks 'solutions' that both cost more than the original Raspi, as well as the nerdly 'ancient' adafruit idea (too nerdly for beginner schoolkids?). Am I revealing a bit of my early technical-school-instructor background here?

If discrimination is not challenged then we are effectively in collusion with the perpetrators of such behaviour:-Oxford dictionaries
- IvanRoulson
- Posts: 6
- Joined: Fri Feb 22, 2013 5:17 pm
- Location: East Devon
Re: GPIO setup for LM35 temperature sensor
Something that might work, as I've done, is to connect a PICAXE to the Pi via a simple transistor level shifter/inverter and a potential divider for the return signal.
I use the ADC in the PICAXE and have set up some simple serial commands between Python on the Pi and BASIC on the PICAXE. The PICAXE here makes a simple IO interface, low current output buffer and ADC, and the costs are pretty reasonable. Simple to add analogue sensing as well as infra-red remote and DS18B20 digital temp sensors.
Currently I'm measuring light and temperature and uploading to COSM, and has been working for a while now.
If this looks too much like PICAXE advertising, then please remove it. I'm not affiliated but it's helped me.
I use the ADC in the PICAXE and have set up some simple serial commands between Python on the Pi and BASIC on the PICAXE. The PICAXE here makes a simple IO interface, low current output buffer and ADC, and the costs are pretty reasonable. Simple to add analogue sensing as well as infra-red remote and DS18B20 digital temp sensors.
Currently I'm measuring light and temperature and uploading to COSM, and has been working for a while now.
If this looks too much like PICAXE advertising, then please remove it. I'm not affiliated but it's helped me.
Re: GPIO setup for LM35 temperature sensor
If that is advertising, please do more of it. I was not personally aware of the existence of PICAXE until your message, but certainly am now ! A pointer to your software for the temperature measurement would be a bonus. Thanks.
If discrimination is not challenged then we are effectively in collusion with the perpetrators of such behaviour:-Oxford dictionaries
Re: GPIO setup for LM35 temperature sensor
Given that a Pi can do what you seem to want with the cost of a resistor and a capacitor why buy a microcontroller?feverish wrote:If that is advertising, please do more of it. I was not personally aware of the existence of PICAXE until your message, but certainly am now ! A pointer to your software for the temperature measurement would be a bonus. Thanks.
Re: GPIO setup for LM35 temperature sensor
Two seconds later, a 'don't need to' message. http://dangerousprototypes.com/wp-conte ... 00x196.gif shows exactly how to do it. Many thanks.
If discrimination is not challenged then we are effectively in collusion with the perpetrators of such behaviour:-Oxford dictionaries
Re: GPIO setup for LM35 temperature sensor
For Joan.
It can't, SFAICS. But if you really know better . . . ?
It can't, SFAICS. But if you really know better . . . ?
If discrimination is not challenged then we are effectively in collusion with the perpetrators of such behaviour:-Oxford dictionaries
Re: GPIO setup for LM35 temperature sensor
How many links do you need?feverish wrote:For Joan.
It can't, SFAICS. But if you really know better . . . ?
If you are one of the people who say Linux can't do that because it's not real-time (without understanding what real-time means) please say now. I'll stop wasting everyone's time.
Re: GPIO setup for LM35 temperature sensor
One comprehensive link is all that is needed. To measure liquid/vapour temperature in a flowline over a period of around 15 hours, to a calibrateable accuracy no more demanding than say .1 degree, over a range from not much less than room temperature to just below 80 Reaumur. Say sample times every 5 seconds (or less).
If discrimination is not challenged then we are effectively in collusion with the perpetrators of such behaviour:-Oxford dictionaries
Re: GPIO setup for LM35 temperature sensor
The mooted 'one resistor, one capacitor' solution still evidently eluding all and sundry, the examples towards the end of the PICAXE manual <www.picaxe.com> may interest fellow-travellers like myself seized by the need for a simple ADC to use in conjunction with Raspi. Even schoolkids seem to like it. Thanks, IvanRoulson.
If discrimination is not challenged then we are effectively in collusion with the perpetrators of such behaviour:-Oxford dictionaries
Re: GPIO setup for LM35 temperature sensor
The one capacitor, one resistor solution is not an ADC, its a fudge. I saw a guide on how to do it (via Arduino if I remember) months/years ago but I can't find it now. It involved charging a capacitor with the voltage from the sensor, and then switching off the voltage, grounding the capacitor via a resistor and timing how long it took to change from a logic one to a logic zero. From that time it was possible to work out the starting voltage. How accurate it would be with the voltages given out from an LM35 is open to question, or if its even possible.
If all you want is to measure temperature I'd recommend using 'one wire' digital thermometers. Reasonably inexpensive and pretty easy to interface to the Pi.
http://www.cl.cam.ac.uk/freshers/raspbe ... mperature/
No ADC required, I've done it myself, it works.
If all you want is to measure temperature I'd recommend using 'one wire' digital thermometers. Reasonably inexpensive and pretty easy to interface to the Pi.
http://www.cl.cam.ac.uk/freshers/raspbe ... mperature/
No ADC required, I've done it myself, it works.
Don't judge Linux by the Pi.......
I must not tread on too many sacred cows......
I must not tread on too many sacred cows......
Re: GPIO setup for LM35 temperature sensor
Well it takes an analog value and converts it into a digital value. I'd call that analog to digital.pluggy wrote:The one capacitor, one resistor solution is not an ADC, its a fudge. I saw a guide on how to do it (via Arduino if I remember) months/years ago but I can't find it now. It involved charging a capacitor with the voltage from the sensor, and then switching off the voltage, grounding the capacitor via a resistor and timing how long it took to change from a logic one to a logic zero. From that time it was possible to work out the starting voltage. How accurate it would be with the voltages given out from an LM35 is open to question, or if its even possible.
If all you want is to measure temperature I'd recommend using 'one wire' digital thermometers. Reasonably inexpensive and pretty easy to interface to the Pi.
http://www.cl.cam.ac.uk/freshers/raspbe ... mperature/
No ADC required, I've done it myself, it works.
Of course it won't give a result accurate to 0.1 of a degree, that's taken for granted as the LM35 isn't that accurate.
It does work, you just need to time a discharge rather than a charge because of the voltages involved.
Re: GPIO setup for LM35 temperature sensor
Agreed by my good for an idea that something is happening at best equivalent to about a 5 or 6 bit ADC, so aboutr a range of 0-63 values depending on timing accuracy of the application and operating system. Whereas the LM35 is capable of much higher accuracy and resolution resolution at least 0.1 deg C in range of -55 to 150 deg C and accuracy around 0.25 deg C.pluggy wrote:The one capacitor, one resistor solution is not an ADC, its a fudge.
At 1 deg accuracy that is 255 steps (8bit ADC equivalent range), and at 0.1 deg C resolution that is 2550 steps (12bit ADC equaivalent range) by just straight sampling without using CDS, averaging or other techniques.
I doubt it would give accurate to within 2 to 5 degrees depending on how accurate the OS allowed the application to run.pluggy wrote:... How accurate it would be with the voltages given out from an LM35 is open to question, or if its even possible.
Agreed use a digital solution 1 wire/I2C/SPi unless you need the head end in a TO92 or TO46 case to be mounted in a special head for measure temperatures in hostile environments or in liquids or similar.pluggy wrote:If all you want is to measure temperature I'd recommend using 'one wire' digital thermometers. Reasonably inexpensive and pretty easy to interface to the Pi....No ADC required, I've done it myself, it works.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/
or http://www.pcserviceselectronics.co.uk/pi/
Re: GPIO setup for LM35 temperature sensor
The brainpower contributing so generously to this project has been impressive. To my mind, it augurs well for the future practical application of Raspi. My personal thanks for the lessons so freely offered, and for both the crude and more refined methods described.
If discrimination is not challenged then we are effectively in collusion with the perpetrators of such behaviour:-Oxford dictionaries
Re: GPIO setup for LM35 temperature sensor
If its any consolation, there are many requests on the Arduino forum for help with the LM35 and that has ADC. Most problems revolved around the analogue reference voltage on the Arduino. It couldn't be assumed to be exactly 5V if you were powering the Arduino from USB and the LM35 needed a critical reference voltage to be accurate. The DS1820 'one wire' digital thermometers are fairly easy on either platform.
Don't judge Linux by the Pi.......
I must not tread on too many sacred cows......
I must not tread on too many sacred cows......
Re: GPIO setup for LM35 temperature sensor
Thanks for the additional comments.
I encapsulated my LM35 in epoxy resin for a project I made for the arduino. I did not entirely rely upon the technical data publicity but calibrated it against other devices, icewater and steam. This gave me sufficient consistency for my purpose and has been regularly in use for upwards of two years now. However, the advent of the Raspi led me to hope I could adapt what I had already made to a wider purpose, including remote control with a gui over an internet connection. No big deal, this is a hobby thing, I am already using an application to monitor physical security at home, several thousand miles away. However, we also have, in retirement, a non-profit occasional teaching initiative for local schools and the idea of introducing the Raspi as a potential tool for solving everyday practical problems is proving attractive.
I encapsulated my LM35 in epoxy resin for a project I made for the arduino. I did not entirely rely upon the technical data publicity but calibrated it against other devices, icewater and steam. This gave me sufficient consistency for my purpose and has been regularly in use for upwards of two years now. However, the advent of the Raspi led me to hope I could adapt what I had already made to a wider purpose, including remote control with a gui over an internet connection. No big deal, this is a hobby thing, I am already using an application to monitor physical security at home, several thousand miles away. However, we also have, in retirement, a non-profit occasional teaching initiative for local schools and the idea of introducing the Raspi as a potential tool for solving everyday practical problems is proving attractive.
If discrimination is not challenged then we are effectively in collusion with the perpetrators of such behaviour:-Oxford dictionaries