Articles Hierarchy

Articles Home » Arduino Projects » ARDUINO PROJECT: digital temperature sensor

ARDUINO PROJECT: digital temperature sensor

wow, its hot in here!!
lately when i found a new shop in chiang mai to buy small electronic parts, boxes, tools
POLY ELECTRONIC SUPPLY
i asked about temperature sensor, and he had a digital one available, DS 1820
even it was 100THB i had to get one. ( later i found that's only half price from conrad 5)

DALLAS DS1820
Pin Number Description
1 GND - Ground
2 DQ - Data In/Out
3 Vdd - Optional Vdd

Measures Temperatures from -55C to +125C (-67F to +257F)
( 0.5C Accuracy from -10C to +85C )
9-Bit Thermometer Resolution
more see datasheet

hm, a 3 leg sensor on a ONE WIRE BUS
that's a interesting wiring.
Vdd AND GND to GND OR Vdd to 5V, GND to GND
DQ to data in ( here use D4 ) AND pullup to 5V by 4.7kΩ
via this resistor ( and only when the line is HIGH ) the chip gets his power.

get some libraries:
ONE WIRE lib
Dallas lib
( here is a small issue, arduino 1.0.3 not like a library name use "-", must delete in library directory name )
running the example SINGLE from the dallas lib
i see a temperature value of 29.xx deg C ( not far from a local thermometer )
but after more testing BAD LUCK

Dallas Temperature IC Control Library Demo
Locating devices...Found 1 devices.
Parasite power is: ON
Device 0 Address: 10DCBD18020800FC
Device 0 Resolution: 9
Temp C: 85.00 Temp F: 185.00
Temp C: 85.00 Temp F: 185.00
Temp C: 85.00 Temp F: 185.00

but after rewire , and change to 3 wire good again

Dallas Temperature IC Control Library Demo
Locating devices...Found 1 devices.
Parasite power is: OFF
Device 0 Address: 10DCBD18020800FC
Device 0 Resolution: 9
Temp C: 27.56
Temp C: 27.56
Temp C: 27.56
Temp C: 27.56

note: *The power-on reset value of the temperature register is +85C.

i don't know why i now have problem with Parasite power is: ON
but i tested all now without the DALLAS Temp lib...
and there it works.
its a 2 step project, what only use the OneWire.h
step1: only reads the device number,

--Search started--
Device is a DS18S20 : 10-DC-BD-18-02-08-00-FC
--Search ended--

step 2: reads the measuring values

Temp = 80.49 F or 26.94 C
Temp = 80.49 F or 26.94 C

anyway i pack the 2 libs, and the 3 test projects in a ZIP for download here.
pls find in SOURCE CODE (4) as D4 for one wire communication
and 38400 for USB communication
and 10-DC-BD-18-02-08-00-FC for my device serial
to change for you project.