Introduction: Read Temperature With DS18B20 | Raspberry Pi 2

Picture of Read Temperature With DS18B20 | Raspberry Pi 2

Hello!

This is my first instructable project, so it won't be as professional as others!

We are using DS18B20 temperature sensor to get the temperature of your room.

Enjoy!

Step 1: Supply

Picture of Supply

You will need:

The sensor itself DS18B20

http://www.ebay.com/itm/Waterproof-Digital-Thermal...

Resistor (I'm using 4,7k Ohm)

Because of the picture is blurry the color codes are: yellow,violet,red,gold

Jumper wires

--------------------------------------------------------------------------

You can find the resistor and the jumper wires online, or in your local electronics store.

Step 2: Wire It UP!

Picture of Wire It UP!

The wiring is very simple.

I got the drawn picture from https://learn.adafruit.com/downloads/pdf/adafruits...

Connect the 3.3V (red) from the sensor to the 3.3V rail on your raspberry pi

Connect the GND(black) to the GND rail on your raspberry pi

Connect the Data(yellow) to a pin on the raspberry pi

Connect your resistor with the 3.3v and the Data as shown in the drawn picture

!!!!WARNING!!!!

IT MUST BE ON THE PIN 7 - GPIO04(GPIO_GCLK)

THE BEGINNING OF THE RESISTOR MUST BE ON THE 3.3V (yellow front)


Step 3: Now the Coding! Without It the Sensor Is Just a Piece of Wire.

Picture of Now the Coding! Without It the Sensor Is Just a Piece of Wire.

Turn on your raspberry pi and let's begin.

First step:

First we need to config a file.

Do that by typing: sudo nano /boot/config.txt

This file let's you config your booting.

Here you search for dtoverlay

When you have found it just correct it to:dtoverlay=w1-gpio

Type sudo reboot, to reboot your device

------------------------------------------------------------------------------------------------------------------------------------------------------

Second step:

Type:

sudo modprobe w1-gpio && sudo modprobe w1_therm

ls -l /sys/bus/w1/devices/

cat /sys/bus/w1/devices/28-000006dfa76c/w1_slave

!!!WARNING!!!
My sensor is
28-000006dfa76c yours may be different, so just replace it!

--------------------------------------------------------------------------------------------------------------------------------------------------

Third step:

I will attach a file that contains the temp.py

!!!WARNING!!!
Replace the sensor is in the code with nano temp.py


Step 4: ENJOY!

Picture of ENJOY!

Just type sudo python temp.py to run your code.

Open a beer and celebrate while you get the information about how warm or cold it is in your room.

------------------------------------------------------------------------------------------------------------------------------------------------------

If you have any question, please leave them below!

Cheers!

(it's 25 in my house at the moment)

Comments

AfuaA made it! (author)2016-07-11

Thanks, the instructions were extremely helpful! The attached code was pure genius. I found code on thingspeak.com that allows real-time plotting and combined the two. Great tutorial!

amberrayh (author)2015-07-27

This is helpful. Thank you for sharing!

About This Instructable

18,530views

26favorites

License:

Add instructable to: