Chipkit Uno and LM35 example

In this example we will connect an LM35 temperature sensor to our Chipkit Uno

The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has an advantage over linear temperature sensors calibrated in Kelvin, as the user is not required to subtract a large constant voltage from its output to obtain convenient Centigrade scaling. The LM35 does not require any external calibration or trimming to provide typical accuracies of ±1/4°C at room temperature and ±3/4°C over a full -55 to +150°C temperature range

Here is a picture of the pins, its important to get these correct or you can damage the sensor

LM35-temperature-sensor-pinout

I purchased a small module, which looks like this. This was clearly labelled and helps avoid any mistakes with wiring, I also prefer using cables to modules rather than breadboards

lm35 module

Schematics and Parts

You will need

Chipkit Uno32
LM35 sensor or module
Hook up wire (dupont cables)

Very simple to connect Vcc is 5v, Gnd is any Gnd and out goes to Chipkit Uno 32 A0, you can see this below

Chipkit Uno and lm35 schematic

Code

[codesyntax lang=”cpp”]

//initializes/defines the output pin of the LM35 temperature sensor
int outputpin= 0;
//this sets the ground pin to LOW and the input voltage pin to high
void setup()
{
Serial.begin(9600);
}

//main loop
void loop()
{
int rawvoltage= analogRead(outputpin);
float millivolts= (rawvoltage/1024.0) * 5000;
float celsius= millivolts/10;
Serial.print(celsius);
Serial.print(" degrees Celsius, ");

Serial.print((celsius * 9)/5 + 32);
Serial.println(" degrees Fahrenheit");
delay(1000);

}

[/codesyntax]

Results

Here are the results via the serial monitor

Chipkit and lm35 serial output

Links

LM35 datasheet
5PCS LM35D Temperature Sensor TO92 Packing

Related posts

Chipkit Max32 and ADXL335 accelerometer example

Chipkit Max32 and LSM303 Accelerometer example

Chipkit Max32 and LSM303 Magnetometer example

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Read More