Arduino Nano LM35 Temperature Sensor

This project demonstrates how to use an LM35 temperature sensor with an Arduino Nano to measure ambient temperature in Celsius. The LM35 is a precision integrated-circuit temperature sensor that provides an analog voltage output proportional to the Celsius temperature.

How It Works

An analog temperature module converts temperature into a voltage the Arduino Nano can sample directly. Two parts dominate hobby kits: the LM35 precision sensor and NTC thermistor modules such as the KY-013.

The LM35 is the easier of the two because its output is linear by design: exactly 10 mV per °C, referenced to 0 V, so 25 °C produces 250 mV. No calibration curve is required — divide the measured millivolts by 10 and you have degrees Celsius.

A thermistor is a resistor whose value falls as it warms. The KY-013 places a 10 kΩ NTC in a divider with a fixed 10 kΩ resistor, so the module outputs a voltage that changes with temperature but not linearly. Converting it properly needs the Steinhart–Hart relationship, or its simplified B-parameter form, using the thermistor's nominal resistance at 25 °C and its B coefficient (around 3950 for common parts).

The Arduino Nano samples with a 10-bit ADC, so analogRead() returns 0–1023 across 5 V.

Components Needed

  • Arduino Nano
  • Analog Temperature Sensor module
  • Arduino Nano
  • USB cable for programming and power
  • Arduino Nano

Wiring to the Arduino Nano

Connect the module's signal pin to A0, VCC to the 5 V rail and GND to ground. With a 5 V supply the output spans 0–5 V, matching the ADC range directly.

Any of A0–A7 (eight channels, two more than the Uno) will work; A0 is used here by convention.

Keep the sensor away from the board's voltage regulator and any motor driver. Both dissipate heat and will bias readings upward by several degrees if the sensor sits next to them.

Module pinArduino Nano pinFunction
S / OUTA0Analog voltage proportional to temperature
VCC / +5VSupply
GND / −GNDCommon ground

Build and Upload

Open the Arduino IDE and create a new sketch.

Copy and paste the provided Arduino code into the sketch.

Upload the code to the Arduino Nano.

Open the serial monitor with a baud rate of 9600.

Observe the serial monitor output displaying the current temperature in Celsius.

Example Code

Reading an LM35 on the Arduino Nano with averaging to suppress ADC noise. Upload it with the board set to Arduino Nano and open the Serial Monitor at 9600 baud.

Reading an LM35 on the Arduino Nano with averaging to suppress ADC noise
const int SENSOR_PIN = A0;
const float VREF = 5.0;      // ADC reference voltage
const int   ADC_MAX = 1023;   // 10-bit converter
const int   SAMPLES = 16;

void setup() {
  Serial.begin(9600);
}

float readCelsius() {
  long total = 0;
  for (int i = 0; i < SAMPLES; i++) {
    total += analogRead(SENSOR_PIN);
    delay(5);
  }
  float counts  = (float)total / SAMPLES;
  float volts   = counts * VREF / ADC_MAX;
  return volts * 100.0;            // LM35: 10 mV per degree C
}

void loop() {
  float c = readCelsius();
  Serial.print("Temperature: ");
  Serial.print(c, 1);
  Serial.print(" C  /  ");
  Serial.print(c * 9.0 / 5.0 + 32.0, 1);
  Serial.println(" F");
  delay(1000);
}

Applications

A lm35 and lm75 temperature sensor modules turns up in a wide range of projects. These are the uses where it is the right choice rather than a compromise:

  • Room and greenhouse climate logging
  • Over-temperature cut-outs for motors, power supplies and battery packs
  • Thermostat control for heaters, fans and incubators
  • Cold-chain monitoring where a readable margin of ±1 °C is acceptable
  • Compensation inputs for other sensors whose output drifts with temperature

Working with the Arduino Nano

The Arduino Nano is built around the ATmega328P and runs on 5 V logic with 2 KB of SRAM and 32 KB of program flash. These details change how this circuit is wired and what the sketch can do, so they are worth stating plainly before you build.

The Nano shares the Uno’s ATmega328P but adds A6 and A7, which are analog-input only and cannot be used as digital pins.

Its DIP footprint drops straight into a breadboard, which suits permanent sensor builds.

Older clones use the CH340 USB bridge and may need that driver plus the "ATmega328P (Old Bootloader)" processor option.

Arduino Nano characteristicValueWhy it matters here
Logic voltage5 VMatches most hobby modules directly
ADC resolution10-bit (0–1023)Sets how finely an analog reading can be resolved
Analog inputsA0–A7 (eight channels, two more than the Uno)Determines how many analog sensors can share the board
PWM outputsD3, D5, D6, D9, D10 and D11Needed for brightness, speed and tone control
I²C pinsA4 (SDA) and A5 (SCL)Fixed by hardware — wiring copied from another board may not match
Interrupt pinsD2 and D3 onlyRequired for counting fast or asynchronous events
Seriala single hardware UART shared with USBMonitor runs at 9600 baud by default

Troubleshooting

Most problems with this module fall into a handful of categories. Work through these before suspecting the part itself:

  • Readings sit around 0 or jump wildly — the signal pin is on a digital pin rather than an analog one.
  • Temperature reads several degrees high — the sensor is picking up heat from the regulator or a nearby driver; move it away from the board.
  • Values drift slowly over minutes — self-heating. Sample periodically rather than continuously.
  • A thermistor module reads nonsense when treated as linear — the KY-013 needs the B-parameter conversion, not the LM35 formula.
  • Code written for an ESP board gives odd analog values — the Arduino Nano uses a 10-bit ADC returning 0–1023; rescale any constant taken from a 12-bit example.
  • An I²C sensor is not found after copying wiring from another Arduino — on the Arduino Nano I²C is on A4 (SDA) and A5 (SCL).

Taking It Further on the Arduino Nano

Once the basic reading works, where you go next depends very much on which board you are using. These are the directions that suit the Arduino Nano specifically:

The Nano’s DIP footprint makes it the natural choice once a breadboard prototype becomes a soldered build. Mount it on female headers rather than soldering it down, so the board can be recovered if the project is retired.

With A6 and A7 available in addition to A0–A5, the Nano can read two more analog sensors than an Uno. Remember that those two pins are analog-input only — they cannot be used with digitalWrite or as digital inputs.

For battery-powered builds, the Nano’s regulator and USB bridge dominate idle current. Powering the 5V pin directly from a regulated supply and removing the power LED substantially extends runtime.

Notes and Practical Limits

Averaging sixteen samples, as the sketch does, trades response speed for stability and removes most of the least-significant-bit jitter. Each ADC step is roughly 4.9 mV, which corresponds to about 0.5 °C with an LM35 — the practical resolution limit without an external amplifier.

For better than ±1 °C, or for readings sent over any distance, prefer a digital sensor such as the DS18B20 or DHT22. Digital parts transmit numbers rather than voltages, so cable resistance and connector corrosion stop mattering.