Read the datasheet http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf Both ways can work - Figures 4 & 5.