Page 1 of 1

Can't add more than 2 DS18B20 using GPIO driver

Posted: Wed Apr 30, 2014 9:53 pm
by TheoraJones
Hi folks, having an odd one;

I have 5 waterproof DS18B20 sensors (the ones in a metal can on a flying lead), hooked up to the GPIO ports in the configuration described here; http://www.cl.cam.ac.uk/projects/raspbe ... mperature/

I have found through trial and error that I can connect 2 (any two, which rules out a faulty sensor) sensors and have them work just fine.. but add a third and I get no slaves, nothing showing as a device.

I guess I am really looking to find out if this is expected; is anyone out there using four or five sensors this way?

My RPi is a 1st gen Type B (one of the original element 14 order into the UK no less!),
running a NOOBS Raspbian image - uname tells me that it's "#474 PREEMPT Thu Jun 13 17:14:42 BST 2013"

SD Card is a Kingston sdc4/16gb in one of the adafruit micro SD adapters

I have tried a couple of PSUs, and this one seems very stable - it's a 2A Samsung tablet one.

I'm hoping to use this RPi as a controller for my solar thermal water system, so this is a bit of a disappointment. annoyingly, I did a wee proof of concept with just two sensors, and it worked just fine, and wrote some code around that. I'd rather not change technology completely to owfs or i2c if there's something simpler that I can do...

So, any ideas or insights?

Re: Can't add more than 2 DS18B20 using GPIO driver

Posted: Wed Apr 30, 2014 11:11 pm
by FLYFISH TECHNOLOGIES
Hi,
TheoraJones wrote:So, any ideas or insights?
Most likely, the problem is capacitance of wires, what is the first limit you typically bump in. This is not specific to RasPi, but a result of non-ideal world we live in. ;-)

So, what you can do is to connect each sensor to a dedicated GPIO pin and modify the code accordingly.
Another option is to purchase a dedicated chip which either handles the capacitance better, and/or which natively offers more 1-wire buses.
If you pick the second option, you could consider using chip listed here: http://www.flyfish-tech.com/FF32. Sample code for reading temperature from DS18B20 is also available for download there.


Best wishes, Ivan Zilic.

Re: Can't add more than 2 DS18B20 using GPIO driver

Posted: Thu May 01, 2014 9:12 am
by dpenezic
FLYFISH TECHNOLOGIES wrote:Hi,
TheoraJones wrote:So, any ideas or insights?
Most likely, the problem is capacitance of wires, what is the first limit you typically bump in. This is not specific to RasPi, but a result of non-ideal world we live in. ;-)
How you know that , did you see connection picture ? I never have any capacitance problem with 1-Wire devices, and connect a lot of it. So very probably isnt that problem at all.
FLYFISH TECHNOLOGIES wrote: So, what you can do is to connect each sensor to a dedicated GPIO pin and modify the code accordingly.
Did you ever try that solutions on RPi ? From my knowledge Kernel modules support only one GPIO pin for 1-Wire master bus. Did you kreate a new kernel module ?
FLYFISH TECHNOLOGIES wrote: Another option is to purchase a dedicated chip which either handles the capacitance better, and/or which natively offers more 1-wire buses.
If you pick the second option, you could consider using chip listed here: http://www.flyfish-tech.com/FF32. Sample code for reading temperature from DS18B20 is also available for download there.
Best wishes, Ivan Zilic.
Nice try, how user spouse to connect your microcontroler to RPi ? I dont see any support for RPi on your page, did i miss something ?

Regards,
Dubravko Penezic

Re: Can't add more than 2 DS18B20 using GPIO driver

Posted: Thu May 01, 2014 9:23 am
by dpenezic
TheoraJones wrote:Hi folks, having an odd one;

I have 5 waterproof DS18B20 sensors (the ones in a metal can on a flying lead), hooked up to the GPIO ports in the configuration described here; http://www.cl.cam.ac.uk/projects/raspbe ... mperature/

I have found through trial and error that I can connect 2 (any two, which rules out a faulty sensor) sensors and have them work just fine.. but add a third and I get no slaves, nothing showing as a device.

I guess I am really looking to find out if this is expected; is anyone out there using four or five sensors this way?

...
I have tried a couple of PSUs, and this one seems very stable - it's a 2A Samsung tablet one.

So, any ideas or insights?
Hi,
did you check 3.3V on all sensors ? , did you have any other extended board connected to RPi on same time ... I did try to connect 5 of DS18B20 on my RPI and work normal. May you send picture of your connection ?

Regards,
Dubravko Penezic

Re: Can't add more than 2 DS18B20 using GPIO driver

Posted: Thu May 01, 2014 12:51 pm
by FLYFISH TECHNOLOGIES
Hi,
dpenezic wrote:
FLYFISH TECHNOLOGIES wrote:Most likely, the problem is capacitance of wires, what is the first limit you typically bump in.
How you know that , did you see connection picture ?
In messages we can usually get a feeling what is the background of poster. When somebody mentions proof of concept he already did, then it should be very clear to anybody, that the person has some mileage... and asking him if "all wires are connected" is a bit disrespectful.
Although, this doesn't mean that it cannot happen to anybody... but when the same person mentions also trial and error actions he already did, you should better think twice.

dpenezic wrote:
FLYFISH TECHNOLOGIES wrote:So, what you can do is to connect each sensor to a dedicated GPIO pin and modify the code accordingly.
Did you ever try that solutions on RPi ? From my knowledge Kernel modules support only one GPIO pin for 1-Wire master bus. Did you kreate a new kernel module ?
Google for "bit-banging".

dpenezic wrote:
FLYFISH TECHNOLOGIES wrote:Another option is to purchase a dedicated chip
Nice try, how user spouse to connect your microcontroler to RPi ?
USB comes to mind.
dpenezic wrote:I dont see any support for RPi on your page, did i miss something ?
Is it confusing for you that the support exists despite the fact that there is no big Raspberry Pi logo present ?


Best wishes, Ivan Zilic.

Re: Can't add more than 2 DS18B20 using GPIO driver

Posted: Thu May 01, 2014 2:47 pm
by dpenezic
Hi,

first user have only one post, secondly it is usual mistake, third your knowledge of electronic is higher then many person on this forum. So good question for this user will be how you connect your DS18B20 , and check a picture of that connection.

According many response and experience bit-banging isnt very well supportet on RPi (https://raspberrypi.stackexchange.com/q ... ample-code).

For you and your module is good that support exist, how ever i like to see it available on suggested link too .

Regards,
Dubarvko Penezic
FLYFISH TECHNOLOGIES wrote:Hi,
dpenezic wrote:
FLYFISH TECHNOLOGIES wrote:Most likely, the problem is capacitance of wires, what is the first limit you typically bump in.
How you know that , did you see connection picture ?
In messages we can usually get a feeling what is the background of poster. When somebody mentions proof of concept he already did, then it should be very clear to anybody, that the person has some mileage... and asking him if "all wires are connected" is a bit disrespectful.
Although, this doesn't mean that it cannot happen to anybody... but when the same person mentions also trial and error actions he already did, you should better think twice.

dpenezic wrote:
FLYFISH TECHNOLOGIES wrote:So, what you can do is to connect each sensor to a dedicated GPIO pin and modify the code accordingly.
Did you ever try that solutions on RPi ? From my knowledge Kernel modules support only one GPIO pin for 1-Wire master bus. Did you kreate a new kernel module ?
Google for "bit-banging".

dpenezic wrote:
FLYFISH TECHNOLOGIES wrote:Another option is to purchase a dedicated chip
Nice try, how user spouse to connect your microcontroler to RPi ?
USB comes to mind.
dpenezic wrote:I dont see any support for RPi on your page, did i miss something ?
Is it confusing for you that the support exists despite the fact that there is no big Raspberry Pi logo present ?


Best wishes, Ivan Zilic.

Re: Can't add more than 2 DS18B20 using GPIO driver

Posted: Thu May 01, 2014 4:17 pm
by FLYFISH TECHNOLOGIES
Hi,
dpenezic wrote:According many response and experience bit-banging isnt very well supportet on RPi
We might have (also) here some terminology issues with understanding what "support on RPi" means. My understanding is that if you can directly control pins level and direction (and you can), then bit-banging is supported.

Another question is timing - what are your time slots requirements. In the link you provided, the question is about UART at speed 9600...
Don't generalize. Quick math returns a value of at least 25x higher sampling rate needed for 9600 UART bit-banging comparing to 1-Wire communication. Very important fact is also that UART bit-banging requires significantly more resources due to its asynchronous nature.
dpenezic wrote:For you and your module is good that support exist, how ever i like to see it available on suggested link too .
It is listed ever since the web page was composed.


Best wishes, Ivan Zilic.

Re: Can't add more than 2 DS18B20 using GPIO driver

Posted: Fri May 02, 2014 7:31 am
by TheoraJones
Hi guys,
Quite a discussion! - Flyfish, thanks for your input, but I am really not looking for such complexity in my solution.

I am not so sure capacitance would be te problem here, simply because of the small size of my board etc; Maxim seem to have suggest that legs of up to 3m are okay and bus lengths of >30 metres. each sensor is on a 70cm wire, and total bus length is only about 1.5m with three sensors.

Here's a picture;

Image

Image


there's not a lot to it!

Re: Can't add more than 2 DS18B20 using GPIO driver

Posted: Fri May 02, 2014 1:46 pm
by FLYFISH TECHNOLOGIES
Hi,
TheoraJones wrote:there's not a lot to it!
This is exactly the overall mystery... ;-)

I wondered if each sensor includes sealed also pull-up resistor, but according to various responses in forums, this is not the case.
The only idea I have right now is to perform measurements what is going on. If you have an oscilloscope available, check the communication at voltage level and bit timing.


Best wishes, Ivan Zilic.

Re: Can't add more than 2 DS18B20 using GPIO driver

Posted: Fri May 02, 2014 10:46 pm
by pluggy
I've had problems with DS18X20's disappearing on an Arduino setup in a similar manner to the OPs problem. I resolved it by sticking some more pullup resistors around the place. I'd always have one at the end of the run as well as the beginning, they are quite tolerant to more pullup, not so tolerant to less in my experience. Probably tied up with lead capacitance..... ;)

Re: Can't add more than 2 DS18B20 using GPIO driver

Posted: Sat May 03, 2014 1:51 am
by iinnovations
90+% of 1 wire issues can be solved with a 1wire bus master and owfs. Don't reinvent the wheel. Ds2483 is $1.

Colin

Re: Can't add more than 2 DS18B20 using GPIO driver

Posted: Sat May 03, 2014 2:42 am
by danjperron
This is really strange

I got my Pond system with 5 sensors and never had a problem with my RPi model B version 1.0

The system is working since november 2012 and it is outside Checking the pond during the winter. I'm in Canada so i get down often below -20C.


If you check closely the picture , I do have the same setup than you . The only thing I had was a 0.1 uF between the ground and 3.3V.

Image

Did you try to decrease or increase the 4k7 resistor.

Maybe one of your sensor misbehaves.

Daniel.

Re: Can't add more than 2 DS18B20 using GPIO driver

Posted: Sat May 03, 2014 10:23 am
by pbogaart
@Daniel,
What is the reason for the capacitor between ground and +3.3V?

Re: Can't add more than 2 DS18B20 using GPIO driver

Posted: Sun May 04, 2014 3:53 pm
by danjperron
old habit,

spike filtering on power.

electronic device tends to drive current when they are activated and this will be induce on the power line. This is why it i always a good idea to have decouple capacitor, to reduce the current surge , near each I.C.

Daniel