Skip to content

Technik Blog

Programmieren | Arduino | ESP32 | MicroPython | Python | Raspberry Pi | Raspberry Pi Pico

Menu
  • About me
  • Contact
  • Deutsch
  • English
Menu

Arduino Lesson #5 – analog temperature sensor LM35DZ

Posted on 21. October 202210. March 2024 by Stefan Draeger

In this new post at my technic-blog, I like to show, how to read temperature values from an analog LM35DZ device at Arduino UNO.

Arduino Lesson #5 - analog temperature sensor LM35DZ
Arduino Lesson #5 – analog temperature sensor LM35DZ

  • Buy a LM35DZ sensor for Arduino
  • Technical data of sensor LM35DZ
  • Pinout analog temperature sensor LM35DZ
  • Simple circuit with LM35DZ at Arduino Nano
  • Sample code in Arduino IDE 2.0
  • Linechart in Arduino IDE 2.0

Buy a LM35DZ sensor for Arduino

The analog temperature sensor of type LM35DZ is very cheap, and you get this device at ebay.de for €1.7 without shipping cost*. If you want it a little bit cheaper, and you can wait for your delivery, you can take a look at aliexpress.com, banggood.com or wish.com.

Note from me: The links marked with an asterisk (*) are affiliate links. If you make a purchase through these links, I will receive a small commission to help support this blog. The price for you remains unchanged. Thank you for your support!

Technical data of sensor LM35DZ

  • Temperature measuring range from 0 °C to 100 °C
  • Precision ±0,4 °C
  • Supply voltage 4 V to 30 V

The LM35 DZ sensor has a linear relationship between the output current and the measured temperature. For every full 1 °C, the electrical voltage decreases by 10mV. I.e. 0 °C is 0 V at the output signal.

analog temperature sensor LM35DZ
analog temperature sensor LM35DZ

Pinout analog temperature sensor LM35DZ

This device has 3 legs and below you find the pinout.

Pinout analoge temperature sensor LM35DZ
Pinout analog temperature sensor LM35DZ

Simple circuit with LM35DZ at Arduino Nano

The tiny microcontroller Arduino Nano has the same pins as the big one Arduino UNO R3. But this device does not have an external power connector.

Here you can find a simple circuit with this analog sensor.

Arduino Nano with analog temperature sensor LM35DZ
Arduino Nano with analog temperature sensor LM35DZ

Sample code in Arduino IDE 2.0

To read the actual value and calculate the temperature, you dont need a library. Here i like to show you a short sample code to read actual value and calculate temperature in Celsius, Fahrenheit and Kelvin.

//temperature sensor connected to analog A0 pin
#define temperatursensorPin A0

void setup() {
  //begin serial communication with 9600 baud
  Serial.begin(9600);
}
void loop() {
  //read curent value
  int value = analogRead(temperatursensorPin);
  //calculate temperature in dregree Celsius
  float temperatureCelsius = (125 * value) >> 8;
  //calculate temperature in Fahrenheit
  float temperatureFahrenheit = temperatureCelsius * 1.8 + 32;
  //calculate tempeature in Kelvin
  float temperatureKelvin = temperatureCelsius + 273.15;
  //print temperature value to serial interface
  Serial.print("Temperatur :");
  Serial.print(temperatureCelsius, 2);
  Serial.print(" °C");
  Serial.print(" | ");
  Serial.print(temperatureFahrenheit, 2);
  Serial.print(" F");
  Serial.print(" | ");
  Serial.print(temperatureKelvin, 2);
  Serial.print(" K");
  Serial.println();
  delay(500);
}

This code will print the values to the serial interface. You can read this with the serial Monitor from the Arduino IDE.

print temperature values from LM35DZ to serial interface
print temperature values from LM35DZ to serial interface

Linechart in Arduino IDE 2.0

The Arduino IDE has a very good feature for number values, you can print this values on linechart.

serial Plotter with temperature values
serial Plotter with temperature values

To write this values to the linechart you have following some rules.

First the labels in the legend will be written with text following on a colon, the value will be added automatically with the next line followed by a line break.

 Serial.print("Celsius:");
 Serial.println(temperatureCelsius);
 Serial.print("Fahrenheit:");
 Serial.println(temperatureFahrenheit);
 Serial.print("Kelvin:");
 Serial.println(temperatureKelvin);

Here is the complete code to print values from an analog temperature sensor LM35DZ to the serial plotter.

//temperature sensor connected to analog A0 pin
#define temperatursensorPin A0

void setup() {
  //begin serial communication with 9600 baud
  Serial.begin(9600);
}
void loop() {
  //read curent value
  int value = analogRead(temperatursensorPin);
  //calculate temperature in dregree Celsius
  float temperatureCelsius = (125 * value) >> 8;
  //calculate temperature in Fahrenheit
  float temperatureFahrenheit = temperatureCelsius * 1.8 + 32;
  //calculate tempeature in Kelvin
  float temperatureKelvin = temperatureCelsius + 273.15;
  //print temperature value to serial interface
  Serial.print("Celsius:");
  Serial.println(temperatureCelsius);
  Serial.print("Fahrenheit:");
  Serial.println(temperatureFahrenheit);
  Serial.print("Kelvin:");
  Serial.println(temperatureKelvin);
  delay(500);
}

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Fragen oder Feedback?

Du hast eine Idee, brauchst Hilfe oder möchtest Feedback loswerden?
Support-Ticket erstellen

Newsletter abonnieren

Bleib auf dem Laufenden: Erhalte regelmäßig Updates zu neuen Projekten, Tutorials und Tipps rund um Arduino, ESP32 und mehr – direkt in dein Postfach.

Jetzt Newsletter abonnieren

Unterstütze meinen Blog

Wenn dir meine Inhalte gefallen, freue ich mich über deine Unterstützung auf Tipeee.
So hilfst du mit, den Blog am Leben zu halten und neue Beiträge zu ermöglichen.

draeger-it.blog auf Tipeee unterstützen

Vielen Dank für deinen Support!
– Stefan Draeger

Categories

Links

Blogverzeichnis Bloggerei.de TopBlogs.de das Original - Blogverzeichnis | Blog Top Liste Blogverzeichnis trusted-blogs.com

Stefan Draeger
Königsberger Str. 13
38364 Schöningen

Tel.: 01778501273
E-Mail: info@draeger-it.blog

Folge mir auf

  • Impressum
  • Datenschutzerklärung
  • Disclaimer
  • Cookie-Richtlinie (EU)
©2025 Technik Blog | Built using WordPress and Responsive Blogily theme by Superb
Cookie-Zustimmung verwalten
Wir verwenden Cookies, um unsere Website und unseren Service zu optimieren.
Funktional Always active
Die technische Speicherung oder der Zugang ist unbedingt erforderlich für den rechtmäßigen Zweck, die Nutzung eines bestimmten Dienstes zu ermöglichen, der vom Teilnehmer oder Nutzer ausdrücklich gewünscht wird, oder für den alleinigen Zweck, die Übertragung einer Nachricht über ein elektronisches Kommunikationsnetz durchzuführen.
Vorlieben
Die technische Speicherung oder der Zugriff ist für den rechtmäßigen Zweck der Speicherung von Präferenzen erforderlich, die nicht vom Abonnenten oder Benutzer angefordert wurden.
Statistiken
Die technische Speicherung oder der Zugriff, der ausschließlich zu statistischen Zwecken erfolgt. Die technische Speicherung oder der Zugriff, der ausschließlich zu anonymen statistischen Zwecken verwendet wird. Ohne eine Vorladung, die freiwillige Zustimmung deines Internetdienstanbieters oder zusätzliche Aufzeichnungen von Dritten können die zu diesem Zweck gespeicherten oder abgerufenen Informationen allein in der Regel nicht dazu verwendet werden, dich zu identifizieren.
Marketing
Die technische Speicherung oder der Zugriff ist erforderlich, um Nutzerprofile zu erstellen, um Werbung zu versenden oder um den Nutzer auf einer Website oder über mehrere Websites hinweg zu ähnlichen Marketingzwecken zu verfolgen.
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
Einstellungen anzeigen
{title} {title} {title}