Tag Archives: sensor

Measuring temperature with Arduino

Hi guys!

Here’s a fun little thing you can do with your Arduino. If you don’t have a thermometer but would still like to know the temperature in your room, you can build one using the temperature sensor found in the basic kits for Arduino. 



I had to turn the sensor around in this diagram so you could actually see where the wires go. For pin 1 (which when the sensor faces you with the flat side is the left most one, but in this it’s the right most one), you will attach your power line (in this case 5V). Pin 2 goes to an analog source (A1 in my case) and number 3 is your ground pin.

Arduino code:

int tempPin =1; //this is the analog pin you’re connected to

void setup()
{Serial.begin(9600); //serial port connection to the computer


void loop()

int tempRead = analogRead(tempPin); //voltage reading from sensor
Serial.println(tempRead); //puts out the reading in the serial monitor
int tempC = map(tempRead, 0, 1023, -50, 450); //your values will be from 0 to 1024 which you then convert to your degrees using the map function

//10mv correspond to 1 degreeC
Serial.print(“new temp: “);