gd.ritter
Posts: 2
Joined: Sun Sep 06, 2015 7:27 pm

Can't get my first project working

Sun Sep 06, 2015 7:37 pm

Having no luck reading correct temperature data on my Raspberry Pi. If anyone can please offer help, here's my code as txt and wiring image you can download in zip.

I have a TMP36 temp sensor into a MCP3008 analog to digital converter, all going to the SPI on my Raspberry Pi 2 running Windows 10 IoT. The data i'm getting at room temperature is 561, but that doesn't make any sense as far as converting to a temp. I don't know if i'm querying the data incorrectly or just don't know how to convert it to degrees Celsius correctly. Please help!

Trying so hard to get this to work! All code and interface xaml is in the attached zip. Zip also available along with wiring schematic at http://tinyurl.com/ohwerkb
Attachments
Code Only.zip
(4.3 KiB) Downloaded 67 times

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand

Re: Can't get my first project working

Mon Sep 07, 2015 1:43 am

datasheet: http://www.analog.com/media/en/technica ... _36_37.pdf
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. The TMP36 is functionally compatible with the LM50. Both the TMP35 and TMP36have an output scale factor of 10 mV/°C.
now do the math.

gd.ritter
Posts: 2
Joined: Sun Sep 06, 2015 7:27 pm

Re: Can't get my first project working

Mon Sep 07, 2015 2:16 am

Doing the math is not my problem I think. It's that the math is giving an impossible result. An output of 561 out of 1024 = .5478 * 3300mV = 1807.91 - 500mV offset = 1307.91 / 10 = 130.8 degrees Celsius! My room temp is around 28 C. So obviously something is programmed wrong but I don't know what. I've used two different tmp36 with same output so the sensor is not the problem, must be the code. Also, connecting ground to MCP3008 channel 0 gives output of 0 and connecting power to it gives output of 1024. So MCP3008 seems to be working too.

ame
Posts: 7832
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Can't get my first project working

Mon Sep 07, 2015 2:25 am

gd.ritter wrote:Doing the math is not my problem I think. It's that the math is giving an impossible result. An output of 561 out of 1024 = .5478 * 3300mV = 1807.91 - 500mV offset = 1307.91 / 10 = 130.8 degrees Celsius! My room temp is around 28 C. So obviously something is programmed wrong but I don't know what. I've used two different tmp36 with same output so the sensor is not the problem, must be the code. Also, connecting ground to MCP3008 channel 0 gives output of 0 and connecting power to it gives output of 1024. So MCP3008 seems to be working too.
Could you connect the MCP3008 to a potentiometer and verify the range of ADC results (even just a 1:1 voltage divider would be useful to verify a 50% reading)?

Also, put a voltmeter on the sensor output to verify that.

Maybe the conversion mode of the MCP3008 has not been set up properly. I haven't looked at the datasheet recently though.
Oh no, not again.

Return to “Beginners”