Tmp36 -35ºc?

Hello i´m testing this code

I have a tmp36 connected to gnd and 3v3 , analog out to pin 1

I read -35ºC

My room temperatura is around 25ºC

What could be the problem?

Thank you

I don’t have one to test, but a quick first check… is the tmp36 connected backwards? It easy to do if you look at a schematic that shows bottom and you think is is top or vice versa.

Also, someone correct me if I am wrong, but the pin configuration for driving the LED should be (DIGITAL_OUT), no?

just ignore the led output.I´m just trying to read.
I my code i deleted the led stuff and Farenheit.
I want celsius.

with the writen face looking at me of the tmp36 the left pin is connected to 3.3v center is the output to pin 1 and right the GND.

I tried replace left with right and i felt a lot of heat in my finger

my code
hardware.pin1.configure(ANALOG_IN);
local output = OutputPort(“temp”,“number”);
local reading = null;
local ratio = null;
local voltage = null;
local temperatureC = null;
function update_temp() {
// keep the imp awake
imp.wakeup(10, update_temp);
// get the raw voltage value from temp sensor btw 0-65535
// in this case that needs mapping to the range 0-3.3v
reading = hardware.pin1.read();
// get the ratio
ratio = 65535.0 / reading;
// make units milivolts and get voltage we can work with
//voltage = (hardware.voltage() * 1000) / divider;
voltage = 3300 / ratio;
// get temperature in degrees Celsius
temperatureC = (voltage - 500) / 10.0;
server.log("temp: " + temperatureC);
}
imp.configure(“TMP36”, [], []);

update_temp();

Why do i read -35 ºC
thank you

Put a server.log("reading = " + reading); after reading = hardware.pin1.read(); and see what it says.

i´m powering my april board with usb!! Does this influences the reading?

tomorrow i will use a multimeter…

Sorry, edited my comment… see above.

And no, USB is fine. The April board has an onboard regulator that supplies 3.3v nicely.

If you use USB, you get 5v at VIN, which is nice, because you can use that if you need it. The April board then regulates it to 3.3v, which powers the Imp, and anything you connect to the 3.3v pin. You do need to make sure that you can draw enough current through your USB source, but I wouldn’t think that it would be a problem with the tmp36.

server.log("reading = " + reading)
outputs
reading = 2992

Take a look at the chart on the Adafruit site. Your value, 2992 is about 150mV (if you do the math), and that will evaluate to -35C. So, my guess is that your tmp36 isn’t generating the correct voltage, so I don’t think it is a code problem. The code isn’t actually reading hardware.voltage(); and is just using 3.3v, but that shouldn’t be a problem, unless somehow your voltage is way off of 3.3v.

@Hugo Has anything changed with (ANALOG_IN)? That would be the correct way to read this device, right?

Just out of curiosity, what do you get for reading if the tmp36 isn’t in the circuit?

…and if your sensor has ever felt “very hot” then it’s likely fried…

i tried with 4 other tmp36 and i read the voltage of 677 mv out of the center pin with a voltimeter.

i checked and having the tmp36 connected to pin1 or just removing it i read the same value , around 2992

i changed to pin 2 and now i have +17 ºC

Did i fried pin 1?

:-))

I can’t answer to the state of Pin 1, but I will say that i have found the Imp to be extremely resilient. I’ve hooked things up incorrectly lots of times, and after a reset, they happily blink at me again. The next thing you could do is actually read hardware.voltage() and use that value as your reference, instead of 3300mV. Your temperature will be more accurate. I’m not sure why it is referenced, but then commented out in the code. Maybe the original programmer had some issues with it.

Are you using a Sparkfun April breakout board? If so, then that’s a known issue with those and some imps - it applies a lot of pressure to pin9 (adjacent to pin1) and bends the imp away from the pin1 contact.

If you contact info@electricimp.com we can send you a replacement imp which doesn’t suffer the same way with the sparkfun socket. The adafruit/electric imp devboards don’t have this issue.

just did it by email.
Thank you.

What about smartmaker board?

Not sure on smartmaker board, I’ve not ever tried it.