Linkit One and an LM35 sensor

In this example we will connect an LM35 temperature sensor to our Linkit One

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 pinout of the sensor, its important to get these correct or you can damage the sensor

lm35-temperature-sensor-pinout

This is not a difficult sesnor to work with, I bought a little module. Here is the module

lm35-module

 

Schematics and Parts

You will need the following parts for this example

Linkit One
LM35 sensor or module
Hook up wire (dupont cables)

Very simple to connect. Connect the Vcc to 5v on your board, Gnd goes to the Gnd and out goes to Linkit One A0, you can see this below

%e2%80%8clinkitone-and-lm35_bb

Code

[codesyntax lang=”cpp”]

//initializes/defines the output pin of the LM35 temperature sensor
int outputpin= A0;

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

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

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

[/codesyntax]

 

Results

If you use the Arduino IDE you will have to change the port used. You program using the debug port, so you will need to change thise port and open the serial monitor. If you use the wrong port you will see nothing inthe monitor. You can of course use another terminal program such as Putty if that is easier

 

Here are the results via the serial monitor

24.41 degrees Celsius, 75.95 degrees Fahrenheit
24.41 degrees Celsius, 75.95 degrees Fahrenheit
23.93 degrees Celsius, 75.07 degrees Fahrenheit
23.93 degrees Celsius, 75.07 degrees Fahrenheit
23.93 degrees Celsius, 75.07 degrees Fahrenheit
23.93 degrees Celsius, 75.07 degrees Fahrenheit
23.44 degrees Celsius, 74.19 degrees Fahrenheit
23.93 degrees Celsius, 75.07 degrees Fahrenheit
22.95 degrees Celsius, 73.31 degrees Fahrenheit

 

Links

LM35 datasheet
5PCS LM35D Temperature Sensor TO92 Packing