Page 1 of 1

DS18b20.....again

Posted: 21 Sep 2019, 17:17
by Sasch600xt
Hello all :)

again it´s me and again i have trouble with connecting my tempsensors together.

using "normal 4MB from 27.08.2019" on a NodeMCU.

i have a 12 meter long cable (microphonecable).
after 7 meter there is the first sensor, then after 2 more meter the second and at the end at 12 meter there is the last sensor.
So 3 sensors in summary.
I used an external 4,7k resistor.

It looks like random i loos a sensor by showing up in "devices" with "NaN".

So any ideas would help me a lot right now....

Questions:
in "Hardware" i can config the port (GPIO-1/D10/) as Input or output high/low.
Do i have to set somthing here or leave it as "default" ?

Thank you so much for your help
Sascha

Re: DS18b20.....again

Posted: 21 Sep 2019, 18:55
by Shardan
Hi Sascha,
to my experiences there are no settings needed for high/low on the GPIO's.
4K7 resistor is correct, at least following datasheet.

I did some testing with DS18B20 and have a sensor chain running at my company with 5 sensors on a 12 m cable.

First, microphone cable did not work for us, it just failed. The wires are too thin obviously.
We used a standard phone cable 2x2x0,6mm JYSTY. Avoid stubs, sensors should be placed near to the cable.

Even that can run into problems, as we experienced. A small electrolytic capacitor of about 10µf
on every sensor from Vcc to GND solved that, it's running fine now for more then a year (still on an old R147 version).

An even better idea might be using a cat cable (ethernet cable).
Use two or three wires for each, Vcc and GND.

A basic thought about DS18B20:
The datasheets say the sensor needs a supply with 3.0 to 5.5 V.
So with 3,3V we are really near the lowest voltage.
The consumption is very low so a long cable should do no harm.
That's about theory so far.

The fact that we had to use capacitors to make things work tells another story.
They work near to the ESP8266, even 10 sensors do, I've tried. On longer cabling is on another note.
Obviously the voltage loss on the wires and / or influences from outside give troubles reading the signal.

Sadly i never found some spare time to check, if it is possible to use a levelshifter with a DS18B20,
so the DS18B20 runs on 5 volts. A simple level shifter (2 resistors and a 2N7000 should do the job).
see https://letscontrolit.com/wiki/index.ph ... Inside.jpg
Basically that should work as levelshifters are fully transparent to both sides.
If you want to try you may ommit the 10K-Resistor on the 5V side - it's already there as you have a 4K7-Resistor placed there.
Place the 2N7000 and the resistors together.

PS: The 2N7002 on the schematic is just the SMD version of the 2N7000, no worries :)

Re: DS18b20.....again

Posted: 21 Sep 2019, 19:17
by grovkillen
I've used level shifters as well as 3.3V and given longer distance I've preferred to use 5V logic together with level shifter just to be safe.

Re: DS18b20.....again

Posted: 22 Sep 2019, 10:04
by Sasch600xt
thank you all for your answeres ! :)

What i try today is a levelshifter to use 5V for the sensor.
i have some 4 channel levelshifter, wich are "ready to use".
so i try one of these first.

And i connect a 10uf capacitor in front of each sensor.
"in front" means 1 meter, cause i cant get closer with the capacitor, i hope it will do the trick also with 1 meter distance.

i will report my results then :)

Have a great day
Sascha

P.s.: Oh no :( i was not reading properly : "A small electrolytic capacitor of about 10µf"
i did not use a electrolytic one.......may it work also or did i used the wrong capacitor ?
IMG_20190922_100950_4_small.jpg
IMG_20190922_100950_4_small.jpg (1.44 MiB) Viewed 10940 times

Re: DS18b20.....again

Posted: 22 Sep 2019, 10:27
by Patou
The important think is the capacitor value not the technology used
So it should work as it was an electrolytic one

Re: DS18b20.....again

Posted: 22 Sep 2019, 11:23
by Shardan
Hi Sascha,

we used electrolytic caps just because they were in the shelf.
You may use any 10µf capacitor you have at hand.
Just make sure the capacitance is really 10µF, not 10 nF.

Just remember that another pullup resistor comes with the ready made levelshifter.
10 KOhm in parallel with your 4,7KOhm gives a 3,3KOhm, might be a bit low.
Change the 4,7K to a 8,2K or 10K resistor to get a resulting of 4,5..5KOhm

Re: DS18b20.....again

Posted: 26 Sep 2019, 21:13
by Sasch600xt
Thank you all for help :)

after i used the levelshifter and a 10uf capacitor in front of each sensor it works without a problem :)
i had to use an 22k resistor to get 4.3k.

Thank you for solving my problem :)

Have a great day !
Sascha