This is an accurate LM35 analog temperature sensor library for Arduino with noise cancellation.
Library features
- Synchronous 10-bit unsigned temperature read
- Temperature range: 0.0 .. 110.0 degree Celsius
- Accuracy: 0.1 degree Celsius
- Noise cancellation
- Small footprint
Hardware
Supported hardware
- All ATmega328P MCU (Arduino UNO, Micro, Nano, etc)
- All ATmega32U4 MCU (Arduino Leonardo, Pro Micro, etc)
- Arduino ATmega2560
Notes:
- This library changes analog pins to ADC 1.1V internal reference voltage which affects all analog pins.
- The function
analogReference()
may not be supported with other non-AVR MCU's.
Arduino UNO - LM35 example
LM35 | Arduino UNO |
GND | GND |
Vs | 5V (or 3.3V) |
Vout | A0 (ANALOG pin) |
Notes:
- Keep wires short to prevent noise.
LM35 specifications
- Supply voltage: 3.3V .. 30V
- Low power: Around 65uA
- Analog voltage interface
Examples
Arduino IDE | Examples | Erriez LM35 analog temperature:
Documentation
Usage
Initialization
{c++}
#include <ErriezLM35.h>
// Connect LM35 data pin to Arduino DIGITAL pin
#define LM35_PIN A0
LM35 lm35 = LM35(LM35_PIN);
Read temperature and humidity
{c++}
void loop()
{
// Read unsigned temperature from sensor
uint16_t lm35_temp = lm35.readTemperature();
// Print temperature
Serial.print(F("LM35: "));
Serial.print(lm35_temp / 10);
Serial.print(F("."));
Serial.print(lm35_temp % 10);
Serial.println(F(" *C"));
// Wait some time
delay(2000);
}
Serial output
Analog LM35 temperature sensor example
LM35: 18.1 *C
LM35: 18.2 *C
LM35: 18.2 *C
...
Library dependencies
Library installation
Please refer to the Wiki page.
Other Arduino Libraries and Sketches from Erriez