A lightweight and easy-to-use Arduino library for interfacing with the LM35 temperature sensor.
The LM35_XCR library allows you to read temperature data from an LM35 analog sensor in both Celsius and Fahrenheit. Designed to be simple and flexible, it supports projects requiring accurate temperature measurement with minimal code.
- Read temperature in Celsius or Fahrenheit
- Lightweight and efficient
- No external dependencies
- Ideal for beginners and advanced Arduino projects
- Arduino board (UNO, Nano, Mega, etc.)
- LM35 temperature sensor
- Jumper wires
LM35 Pinout:
+-----------+
| |
| LM35 |
| |
+-----------+
| 1 | VCC |
| 2 | OUT |
| 3 | GND |
- Connect VCC to 5V
- Connect GND to GND
- Connect OUT to any analog pin (e.g., A0)
#include <LM35_XCR.h>
LM35_XCR sensor(A0);
void setup() {
Serial.begin(9600);
}
void loop() {
float temperatureC = sensor.readCelsius();
float temperatureF = sensor.readFahrenheit();
Serial.print("Temperature: ");
Serial.print(temperatureC);
Serial.print(" °C | ");
Serial.print(temperatureF);
Serial.println(" °F");
delay(1000);
}| Function | Description |
|---|---|
readCelsius() |
Returns the temperature in Celsius (°C). |
readFahrenheit() |
Returns the temperature in Fahrenheit (°F). |