Raspberry Pi Temperature Sensor: Build a DS18B20 Circuit

In this tutorial I will be going through the steps on how to setup your very own Raspberry Pi temperature sensor. Like most of the sensor tutorials they are pretty straight forward consisting of a basic circuit and some code.raspberry pi temperature sensor build a ds18b20 circuit

I will be using a ds18B20 waterproof sensor, this probe can provide temperatures over a one wire interface. Even better this is waterproof making it perfect if you need to use the sensor in a wet environment.

Equipment

The equipment that you will need for this Raspberry Pi temperature sensor is listed below. Keep in mind the breadboard and the breadboard wire are optional but I highly recommend investing in these as they may work working circuitry a lot easier.

Recommended:

Raspberry Pi

8 GB Micro SD Card or a 8 GB SD Card if you’re still using an old version of the Pi.

DS 18B20 Temperature Sensor

4.7k Resistor

GPIO breakout kit

Breadboard

Breadboard Wire

Optional:

Raspberry Pi Case

USB Keyboard

USB Mouse

Ethernet Cord or Wifi dongle (If you want networking, keep in mind the Raspberry Pi 3 has inbuilt WiFi.)

Building the Raspberry Pi ds18b20 Circuit

The circuit that we will need to build is pretty straight forward as we only need a resistor and the temperature sensor.

The sensor that I am using in this tutorial is a waterproof version of the DS18B20 sensor. It simply looks like a very long cord with a thick part on the end. If you have just a plain version without wiring and waterproofing, then it looks exactly like a transistor.

This sensor is pretty accurate being within 0.05°C of the actual temperature. It can handle temperatures of up to 125°C (260°F) but it’s recommended you keep it below 100°C (210°F). This device also has an on-board analogue to digital converter so we’re able to easily hook it up to a digital GPIO pin on the Pi.

Keep in mind not all temperature sensors are the same something like the TMP36 will not simply replace the ds18b20 in this tutorial. The TMP36 is an analogue device making it slightly harder to integrate with the Pi. This is basically the same problem we had with the light sensor and is because the Raspberry Pi doesn’t have any analogue pins.

Putting this circuit together is super simple, I will quickly go through some basic instructions below. If you’re having trouble following them then please refer to the video or diagram. If you need more information on the GPIO pins then be sure to check out my guide on getting started with the Raspberry Pi GPIO pins.

  1. First connect the 3v3 pin from the Pi up to the positive rail & a ground pin to the ground rail on the breadboard.
  2. Now place the DS18B20 sensor onto the breadboard.
  3. Place a 4.7k resistor between the positive lead and the output lead of the sensor.
  4. Place a wire from the positive lead to the positive 3v3 rail.
  5. Place a wire from the output lead back to pin #4 (Pin #7 if using physical numbering) of the Raspberry Pi.
  6. Place a wire from the ground lead to the ground rail.

Once done your circuit should look similar to the diagram below.  Keep in mind some versions of the temperature sensor may have more wires than just 3. Refer to the datasheet for more information for each of the wires.schematic raspberry pi temperature sensor build a ds18b20 circuit

For more detail: Raspberry Pi Temperature Sensor: Build a DS18B20 Circuit


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top