Although the DS18B20 just looks like a regular transistor, there is actually quite a lot going on inside.
The chip includes the special 1-wire serial interface as well as control logic and the temperature sensor itself.
Its output pin sends digital messages and Raspbian includes an interface to read those messages. Once we enable 1-Wire using the 'raspi-config' tool on your Raspberry Pi the correct kernel modules will be loaded on subsequent reboots.
sudo raspi-config
Select Interfacing Options
Select 1-Wire
Select Yes
Exit out of raspi-config and reboot your Pi so the 1-wire kernel modules load up.
sudo reboot
Verify that the 1-Wire kernel modules have loaded on the next boot. You should see something like the below output when running the lsmod command.
lsmod | grep -i w1_