17

I would really appreciate some advice on this. Being a TOTAL noob I have closely followed a guide on the internet explaining how to use a DS18b20 sensor with my Raspberry Pi. The guide is http://www.cl.cam.ac.uk/freshers/raspberrypi/tutorials/temperature/ and has been fairly easy to follow.

I changed the raspi.list file to read "deb http://archive.raspberrypi.org/debian/ wheezy main untested" and then run apt-get update and apt-get upgrade. All that went without a hitch.

I then connected the DS18b20 to 3v, Ground and Data (gpio#4) connecting the data and 3v via a 4.7 ohm resistor.

I've then used the console to run;

sudo modprobe w1-gpio
sudo modprobe w1-therm
cd /sys/bus/w1/devices/

This all works fine. However, when type ls, the guide tells me that I should see the serial number of the sensor listed followed by w1_bus_master1.

All I actually get is w1_bus_master1 but no serial number. I've tried everything I can think of (which isn't much). Is anybody able to offer some guidance on what the problem might be?

Many thanks

Raspnoob.

Dennis Williamson
  • 1,689
  • 3
  • 13
  • 11
Raspnoob
  • 171
  • 1
  • 1
  • 3
  • 1
    It seems that your RaspberryPi does not see your sensor. Double check that it is connected in the right way (for example if you didn't connect sensor pin 1 as pin 3, etc), double check that you connected data pin to gpio 4, check another sensor (maybe you managed to brake the one you are testing right now). Also, since I don't know if this is a typo, double check if you are using 4.7k Ohm (4700 Ohm) resistor, not 4.7 Ohm. – Krzysztof Adamski Nov 15 '12 at 12:36
  • Thanks for the response, that was a typo is is a 4.7k Ohm resistor (yellow, violet, red, gold). I have three temperature sensors and none of them work, it is however possible that I've managed to break all three of them through misswiring. At least there seems to be nothing else jumping out as wrong so I'll start by buying a couple more. – Raspnoob Nov 15 '12 at 14:28

6 Answers6

17

I had the same problem with Pi B+ and solved it by adding a line to /boot/config.txt. Add the following to the bottom:

dtoverlay=w1-gpio,gpiopin=4

found the solution at: www.raspberrypi-spy.co.uk

Ghanima
  • 15,855
  • 15
  • 61
  • 119
waterwombat
  • 171
  • 1
  • 2
15

I suggest double checking your connections. photo of connections
↑ my wiring (which works for me)

Pi header pins ← From pi cheat sheet

screenshot of temp graph and pi commands
↑ commands and example output + RRDTOOL graphs from DS18B20 (the one shown in top photo.)

If a picture is worth a thousand words, why does stack exchange insist on 30 characters?

RedGrittyBrick
  • 611
  • 4
  • 13
  • Thanks HeatfanJohn that is exactly what is was. A wiring error. Your picture fixed the problem in seconds. I'm a little confused that though as to me that is pin 7 which a diagram I have labels it as General Purpose Clock. How is it GPIO#4? Thanks again, – Raspnoob Nov 16 '12 at 10:17
  • @Raspnoob: See pinout in updated answer, numbering is confusing. GPIO numbering is per main system-on-chip makers spec, but the header pins are organised differently and are separately numbered in a zig-zag way instead of along lines of pins. P.S. please click the tick to accept answer if it helped solve your problem. – RedGrittyBrick Nov 16 '12 at 11:16
  • 1
    Can I use a different GPIO? – Andres Feb 05 '14 at 07:41
  • 4
    I couldn't get mine to work with Raspbian 1.4.0 and a model B+ until I did this: Add the following line to the end of /boot/config.txt :

    dtoverlay=w1-gpio,gpiopin=4

    – David Tinker Mar 05 '15 at 04:31
3

You can use DS18B20 in parasite power mode, meaning that you only need two wires: ground and data, no need for pullup resistor for the data.

As per the datasheet (http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf page 2): VDD must be grounded for operation in parasite power mode.

DS18B20 needs strong pull-up on the data line in this mode achievable by issuing this commands:

sudo modprobe w1-gpio pullup=1
sudo modprobe w1-therm strong_pullup=1

EDIT (in response of comment):

  • parasitic power mode features simplicity in wiring. Only 2 wires needed for this mode. This is especially important when one want to wire a big number of sensors together.

  • the disadvantage of the parasite mode is that the IO needs strong pullup to be able to provide enough current. However this is not a real problem with this temperature sensors.

  • another disadvantage of the parasite power is the slower communication speed. One have to charge the parasite capacitor and that takes time, in case of this sensor > 500 ms.

sanyi
  • 201
  • 1
  • 4
  • 1
    What are the benefits or disadvantages of using the DS18B20 in parasite mode over the normal mode? – Matthew Moisen Dec 22 '14 at 04:52
  • (A bit late but) answer added. – sanyi Mar 18 '15 at 18:55
  • Thank you. "parasitic power mode ... is especially important when one wants to wire a big number of sensors together" I currently link up as many as 7 probes on a breadboard without using parasite mode. Why is it important in this case to go parasitic? – Matthew Moisen Mar 19 '15 at 02:34
  • In some scenarios less wires can reduce cost or help avoid mechanical or space problems. This is irrelevant for small hobby projects on someone's desk. – sanyi Mar 19 '15 at 19:45
  • 1
    Presumably if you've used an external pull-up, the pullup=1 configuration is not required? – piers7 Jul 29 '16 at 06:42
-1

If you have a newer version of Wheezy, DO NOT enable "Device Tree" in the Configuration program! I find that it cause all kinds of havoc with you Pis' hardware.

Doing so, you WON'T have to add the line from the above mentioned comments:

dtoverlay=w1-gpio,gpiopin=4

piboy
  • 21
-1

to setup one wire with the latest Kernel you can follow the direction at: http://bigfieldsblog.cloudapp.net/keyes-18b20-temperature-sensor-and-raspberry-pi-2/

-2

PIN 3 must be grounded in parasite power mode!, per the datasheet.

  • 3
    Hi hello welcome. Please expand your answer, e.g. with links, further descriptions, photos or similar. – myhd Feb 15 '14 at 19:57