The DS18B20 is a nice little temperature sensor that can be used in various simple projects. This part uses the 1 wire bus and you can connect multiple sensors up to your Arduino.
The part is also relatively low cost and only requires a 4k7 pull up resistor. In the example below we shall make a basic example that reads the temperature and outputs via serial and can be verified using the serial monitor in the Arduino IDE.
Lets look at the parts list and the the parts laid out on a mini breadboard which sits on an arduino protoboard shield, as you can see 2 parts and some hook up wire.
|DS1||DS18B20 1-Wire Temperature Sensor||part # DS18B20|
|Part1||Arduino Uno (Rev3)||type Arduino UNO (Rev3)|
|R1||4.7k Ω Resistor||package THT; tolerance ±5%; bands 4; resistance 4.7kΩ; pin spacing 400 mil|
You need to download 2 libraries and copy them into your Arduino libraries folder, this makes life easier.
Now copy and paste this into a new sketch
//the pin you connect the ds18b20 to
#define DS18B20 2
//read temperature and output via serial
Serial.println(” degrees C”);
When you upload the sketch, go to Tools -> Serial Monitor and you should see something like the following. Put your finger on the DS18B20 and you should see the temperature vary.
I’m seeing some great prices for DS18B20 parts, 10 of these for about $7.