madmaze
Posts: 6
Joined: Sun Jan 20, 2013 7:47 am

DS18B20 no longer works in parasitic mode, w1_therm bug?

Sat Jun 29, 2013 11:05 pm

Hi All,

So Ive been monitoring my temperature in my apartment with some 1wire DS18B20 temp sensors in *parasitic* mode for about 2 years now, first on an Arduino and for the past 6 months on an RPi.

A few days ago my SD card corrupted on my RPi.
I re-installed everything on a new SD, plain rasbian(2013-05-25-wheezy-raspbian.img), loaded the w1_gpio and w1_therm kernel modules, and was hoping for everything to work again, but not so quick.

As it turns out, all 3 of my sensors show up under /sys/devices/w1_bus_master1, but all of them are always reading 85C now.
After double and triple checking i had everything hooked up correctly I figured, perhaps my sensors are fried (could have had the same cause for the SD card corrupting, voltage spike? i dunno)

So as a result I broke out my breadboard and set up 3 new sensors just as I had them before. But the same issue appeared. Every sensor reads 85C, always.
I played a bit with trying slightly higher and lower resistance on the pull up resistor, but no go.

Just to sanity check my self, I grabbed out one of my Arduinos and attached the same exact circuit and ran the OneWire Temp sensor sample and viola everything works.
I've gone back and forth between the RPi setup and the Arduino setup and its the same thing every time: Arduino works, RPi doesn't. I even switched out the RPi, but no luck.

fullsize image: http://i.imgur.com/1G6RJVu.jpg

So my question,
Has anyone recently had issues with getting *parasitic* mode to work with the DS18B20 on an RPi?
I have suspicion there may be a bug in w1_gpio or w1_therm.

Thanks,

Maze

EDIT:
I should also add that if they are not running in *parasiticI* mode everything works just fine!
Attachments
1G6RJVu.jpg
Breadboard layout
1G6RJVu.jpg (44.66 KiB) Viewed 7671 times

madmaze
Posts: 6
Joined: Sun Jan 20, 2013 7:47 am

Re: DS18B20 no longer works in parasitic mode, w1_therm bug?

Sun Jun 30, 2013 3:30 am

So after some w1_gpio source reading and a bit of experimentation, I have come to a solution.

It seems as though that when the w1_gpio module is loaded, it automatically sets w1_master_pullup to high and because I was doing the pullup with a resistor manually, nothing worked.

Now, the solution was to set w1_master_pullup to 0 and one other tweak I made was to go down to a 3.3k pullup resistor.

Also it looks like in kernel 3.6.11 that the "pullup" kernel module argument doesn't work

Code: Select all

[email protected] ~ $ sudo rmmod w1_gpio
[email protected] ~ $ sudo modprobe w1_gpio pullup=0
[email protected] ~ $ cat /sys/devices/w1_bus_master1/w1_master_pullup 
1
though this seems to have been fixed for 3.8 here:
https://github.com/raspberrypi/linux/co ... 2c898a31f3

marvinspi
Posts: 5
Joined: Tue Aug 13, 2013 4:22 pm

Re: DS18B20 no longer works in parasitic mode, w1_therm bug?

Tue Aug 13, 2013 8:45 pm

Hi,
I am just beginning to set up a temperature sensor and have gotten that 85C result. I have the DS18B20 PAR chip and have tried your suggestions including changing the value of R from 4700 to 3900 ohms. The spec sheet says that the initial default value is 85C after a reset. I tried the pullup command and still 85C.

Have you any further suggestions about a solution. I am almost ready to buy a 18B20 chip as it seems like the fastest way to go.

Any advice would be appreciated. Thanks

Marvin
a1234 AT uwo.ca


madmaze wrote:So after some w1_gpio source reading and a bit of experimentation, I have come to a solution.

It seems as though that when the w1_gpio module is loaded, it automatically sets w1_master_pullup to high and because I was doing the pullup with a resistor manually, nothing worked.

Now, the solution was to set w1_master_pullup to 0 and one other tweak I made was to go down to a 3.3k pullup resistor.

Also it looks like in kernel 3.6.11 that the "pullup" kernel module argument doesn't work

Code: Select all

[email protected] ~ $ sudo rmmod w1_gpio
[email protected] ~ $ sudo modprobe w1_gpio pullup=0
[email protected] ~ $ cat /sys/devices/w1_bus_master1/w1_master_pullup 
1
though this seems to have been fixed for 3.8 here:
https://github.com/raspberrypi/linux/co ... 2c898a31f3

madmaze
Posts: 6
Joined: Sun Jan 20, 2013 7:47 am

Re: DS18B20 no longer works in parasitic mode, w1_therm bug?

Wed Aug 14, 2013 1:27 am

Hi Marvin,

What do you get when you run

Code: Select all

cat /sys/devices/w1_bus_master1/w1_master_pullup 
?
How many sensors are you testing with? From when is your Raspbian image?
Also I am not totally familiar with the ins and outs of the DS18B20 PAR chip.

Cheers,

Maze

marvinspi
Posts: 5
Joined: Tue Aug 13, 2013 4:22 pm

Re: DS18B20 no longer works in parasitic mode, w1_therm bug?

Wed Aug 14, 2013 7:18 pm

Hi Maze,

I get 1 when I

cat /sys/devices/w1_bus_master1/w1_master_pullup

Using only one sensor. Only need one sensor. Always get 85C or 85000 millidegrees. The spec states this is the default after a reset.

RasPi 3.2.27+ kernel

The specs of the 18B20PAR chip seem to require a MOSFET to provide sufficient current for a temp measurement. Since the 18B20PAR chip lacks pin a connection for power on pin 3 it has a capacitor that needs to be charged inside from pin 2. Dallas Semi / Maxim give a procedure in the datasheet on how the use a MOSFET to provide the current. I have not tried this yet. It may be better to get the 18B20 chip with pin 3 connected.

Best wishes,

Marvin

madmaze
Posts: 6
Joined: Sun Jan 20, 2013 7:47 am

Re: DS18B20 no longer works in parasitic mode, w1_therm bug?

Wed Aug 14, 2013 8:22 pm

If you still get 1, it means it's still trying to do a pullup on the RPi, I never got this to work.

My solution was echo-ing 0 into the w1_master_pullup.
To do this reliably I setup a root cron job to echo 0 into it.

Code: Select all

[email protected] ~ $ sudo su
[email protected] /home/pi $ crontab -e
once crontab -e opens, add this line to the bottom:

Code: Select all

@reboot sleep 30;echo 0 > /sys/devices/w1_bus_master1/w1_master_pullup
The above command waits 30 seconds after reboot and then sets the pullup to zero

For this to work, you also need to autoload the one-wire kernel modules.
To do so added this to the bottom of /etc/modules

Code: Select all

w1-gpio
w1-therm
Now after a reboot and waiting at least 30s, does w1_master_pullup give you zero?

marvinspi
Posts: 5
Joined: Tue Aug 13, 2013 4:22 pm

Re: DS18B20 no longer works in parasitic mode, w1_therm bug?

Thu Aug 15, 2013 9:28 pm

Hi Maze,

I ordered and received the 18B20 chip from Digi Key (in less than 15 hours) and it works with no problem. Thanks for the additional suggestions but now I need to get the email working to send the temp to me. That is my major interest right now.

I appreciate your help and best of luck in your projects.

Marvin

madmaze
Posts: 6
Joined: Sun Jan 20, 2013 7:47 am

Re: DS18B20 no longer works in parasitic mode, w1_therm bug?

Thu Aug 15, 2013 10:54 pm

no problem, good luck with yours as well!

thub
Posts: 1
Joined: Sat Feb 08, 2014 8:56 pm

Re: DS18B20 no longer works in parasitic mode, w1_therm bug?

Sat Feb 08, 2014 9:13 pm

It seems that echoing 0 to pullup works fine, but parasite mode works only on 5V input voltage for the ds18b20 and 3k3 pullup resistor for the data wire.

bozzy
Posts: 4
Joined: Fri Apr 11, 2014 9:33 am

Re: DS18B20 no longer works in parasitic mode, w1_therm bug?

Tue May 20, 2014 10:28 am

After some research on the web, I managed to have my DS18B20PARs to work with these settings:

sudo modprobe w1_gpio pullup=1
sudo modprobe w1_therm strong_pullup=1
(or =2)

It seems that both pullup parameters must be specified, especially the strong_pullup that's the key to have parasite power mode to work. It keeps the bus high while the chip is performing temperature conversion and EEPROM writes, as per specs. I have 4 of them working on my RPi now ;)

So... I'm really wondering how have you managed to get yours working without strong pullup?! :?: :geek:

User avatar
tony1tf
Posts: 49
Joined: Tue Jul 03, 2012 12:33 pm

Re: DS18B20 no longer works in parasitic mode, w1_therm bug?

Sun Dec 06, 2015 5:24 pm

I know this is an old topic, now, but I am having problems adding a OneWire temperature sensor to the OpenPi.
Can someone summarise what needs to be changed in the latest Jessie system, please.
I believe I have done all that has been suggested in various forums:

in modules: w1-gpio pullup=1
w1-therm strong_pullup=2
in config.txt: dtoverlay=w1-gpio

I can't get my single DS18B20 to work in parasitic mode - I get the 85degC error - I am using the OpenPi wireless enabled Pi which uses the Compute Module. The sensor works OK when the Vcc pin connected to +5V. I have a 3.9K resistor to +3.3V on the data line, and an additional 6.8K resistor to +5V.

Tony

Return to “Automation, sensing and robotics”