***help:  how to read analog output from lm34

Hi I am new to this forum and arduino

i have this project that i am working on where i need to connect the LM34 heat sensor to a buzzer and my objective of the project is to make the buzzer buzz whenever heat is detected (depends on the ranges i set it at)

My major problem right now is the fact that i dont know how to read the output of the LM34. the serial monitor on the arduino program is showing 0 all the time. What should i do?

this is all i have so far:

int analogInput = 4;

int value = 0;

void setup() { beginSerial(9600); }

void loop() { value = analogRead(analogInput); printInteger(value); printByte(10); delay(10); }


use Serial.print(data) and Serial.println(data) instead of printInteger; those are old commands and I am not even sure if they work anymore. See the commmand reference in the Arduino software's help menu. D

Hi daniel, I think the printinteger command works cause that's what I wrote for the last project with the potentiometer and it output correctly. But this time I am just not sure what the output should the lm34 give me. I should be expecting to get values of the mili-voltage from 0F (0.00v) to 100F (1.00v) or am i wrong?


After fiddling with the arduino some more,
i tried not to use any resistor to connect and then it started to burn, the LM34 started heating up really fast n burned up
then i tried adding a 1k resistor in and now on the serial monitor, i am getting values like 875875

Do i even need a resistor?
what do those values stand for?

I looked at the datasheet, and: 1) No resistors should be necessary 2) the output should be directly compatible with the arduino analog inputs. Are you sure you are connecting it properly?

Acording to the datasheet for the sensor you need the resistor. It’s there to protect the sensor from being damaged by too much current. Removing it will cause to much current to go through the sensor and fry it.

If everything was working you should get numbers in the serial monitor between 0 and 1023. 0 = 0V on the analog pin 1023 = 5V on the analog pin. Depending on the value of the resistor and the temperatrure you are sensing you might get values that do not cover the entire 0 - 1023 interval.

If the sensor got very hot, it’s likely that it is damaged.

The analog in pins are connected to a AD (Analog to Digital) converter in the Atmega processor. It will convert a voltage in the range 0V - 5V to a 10 bit value, i.e. a number in the 0 - 1023 range.

Hope this helps a bit.


hmmmm thanks for the reply I think I fried it... sorry i am kinda new to this... Can someone teach me how I am supposed to connect the resistors for the heat sensor? I got some 1K resistor... but is that enough to lower the current so it won't burn?

I tried heating up the sensor with a blow dryer and the value does go up... so is the sensor really burnt? but I am still getting these 800000+ values for the output... what's wrong?

Sorry for my previous reply about the resistor being required, Westfw is correct. The resistor is only used in certain circumstances.

I assume you have connected

pin 1 on the sensor to analog pin 4 on Arduino Pin 4 on the sensor to Arduino Ground in 8 on the sensor to Arduino +5V

Thats how it shoul be connected if you are powering the sensor from the Arduino board.

If this is the case, i would try to disconnect pin 1, and meassure the voltage between pin 1 and 4 on the sensor with a volt meter while you make some temperaure changes. This way you can see what voltages it is actually putting out. If these voltages are not in the 0V - 5V range something is wrong.

I had all kinds of problems with my LM34DZ. I was getting odd values. I think it was a bit of a loose wire though, because now it is working perfectly. I was able to bring the temperature down by placing an ice cube in a shot glass next to the LM34DZ.

LM34DZ TO-92

+5 to +Vs GND to GND Analog 0 to Vout

Here's my code:

int analogInput = 0; int tempF = 0;

void setup(){ beginSerial(9600); }

void loop(){

tempF = (500.0 * analogRead(analogInput)) / 1024; Serial.print("Temperature: "); Serial.println(tempF, DEC); delay(100); }