Arduino + DS18B20 Temperature Logger
Arduino Uno reads a OneWire DS18B20 and prints temperatures over serial.
Difficulty: Through-hole. Estimated build time: about 45 minutes. Estimated parts cost: about US$12.00. 5-line bill of materials. Compare supplier offers when available. An Arduino Uno reads temperature from a DS18B20 digital sensor over the 1-Wire protocol and prints readings to the serial monitor every second.
Wire the sensor
Connect DS18B20 VDD (pin 3) to the Arduino 5 V pin, GND (pin 1) to GND, and DQ (pin 2) to digital pin 4. Place a 4.7 kΩ pull-up resistor between DQ and VDD. This resistor is mandatory—the 1-Wire protocol relies on the line being pulled high between transactions. Without it you will read -127 °C, the library's error sentinel.
Install libraries
Open the Arduino IDE Library Manager and install two libraries: OneWire by Paul Stoffregen, and DallasTemperature by Miles Burton. These handle all 1-Wire bus timing and DS18B20 command sequences. If you see a library already installed, confirm the versions are recent (OneWire 2.3+, DallasTemperature 3.9+).
Upload and read
Write a sketch that includes both libraries, defines ONE_WIRE_BUS as 4, initialises OneWire and DallasTemperature objects, calls sensors.requestTemperatures() in loop(), then prints sensors.getTempCByIndex(0). Open the serial monitor at 9600 baud. You should see temperature readings every second. Hold the sensor in your fingers and watch the reading rise.
Add bypass capacitor
Place a 100 nF ceramic capacitor between the DS18B20 VDD and GND pins, close to the sensor. Power supply noise can cause spurious -127 °C readings even when wiring is correct. The capacitor filters this. If readings are intermittent, this is the first thing to check.