DS18b20.....again

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
Sasch600xt
Normal user
Posts: 164
Joined: 10 Sep 2018, 16:37

DS18b20.....again

#1 Post by Sasch600xt » 21 Sep 2019, 17:17

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
"the flat earth society has members all around the globe"

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: DS18b20.....again

#2 Post by Shardan » 21 Sep 2019, 18:55

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 :)
Regards
Shardan

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: DS18b20.....again

#3 Post by grovkillen » 21 Sep 2019, 19:17

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.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
Sasch600xt
Normal user
Posts: 164
Joined: 10 Sep 2018, 16:37

Re: DS18b20.....again

#4 Post by Sasch600xt » 22 Sep 2019, 10:04

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 10621 times
"the flat earth society has members all around the globe"

Patou
Normal user
Posts: 106
Joined: 21 May 2018, 10:33

Re: DS18b20.....again

#5 Post by Patou » 22 Sep 2019, 10:27

The important think is the capacitor value not the technology used
So it should work as it was an electrolytic one

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: DS18b20.....again

#6 Post by Shardan » 22 Sep 2019, 11:23

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
Regards
Shardan

User avatar
Sasch600xt
Normal user
Posts: 164
Joined: 10 Sep 2018, 16:37

Re: DS18b20.....again

#7 Post by Sasch600xt » 26 Sep 2019, 21:13

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
"the flat earth society has members all around the globe"

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 23 guests