No video

Arduino, DS18B20/DS18S20 Temperature Sensor and 1-Wire Bus - The Details

Just install some libraries and that’s it. Hold on, there might be more …
↓↓↓ Complete description, time index and links below ↓↓↓
For example: How does that parasitic power thing work? Does it always work? What about several devices on the same 1-Wire bus? And what’s the difference between the DB18B20 and DS18S20 temperature sensors?
I’ll try my best to answer all these questions in this video and then some. At the end we’ll have four DS18B20s connected to an Arduino Nano via two 1-wire busses, one with phantom power and one with a dedicated 5V supply line.
Intro …
00:00 Intro - there shall be two busses with two sensors each
1-Wire bus basics …
01:06 Data transmission - pull-up resistor and open collector/drain pull-downs
02:44 Parasite power - hard pull-up through transistor, timing issues
05:46 Masters - hardware differences between microcontrollers and -processors
Simple example …
07:45 Demo - wired up breadboard and Arduino serial monitor
10:20 Circuit - one bus with parasitic and one bus with direct power, two sensors each
12:56 Code - 1-Wire and Dallas Temperature library
DS18B20 vs DS18S20 …
17:50 Overview - same accuracy (almost) but different resolutions
18:48 Speed - DS18B20 is eight times faster at the same resolution
20:08 Accuracy - DS18B20 is a wee bit better specified
Second example …
21:19 Demo - faster with higher resolution, but what sensor is which on the bus?
24:37 Code - setting resolution and optimized loops
Addressing …
25:55 1-Wire identification - a 64-bit address, talk about internet of things
27:55 Demo - seeing the 64-bit addresses of the devices on the breadboard
28:48 Code - getting addresses and using them to address devices
31:29 Methods - just some suggestions on how to use addressing in practice
Remarks …
34:24 Pull-up resistor - smaller values might be required, but there are limits
38:10 Parasite power - it’s not always working, supported or possible
Wrap-up …
39:00 Wrap-up - a lot of things went unsaid, so just ask for specifics
Tutorials: • Tutorials
#robertssmorgasbord #tutorials #tutorial #how-to #Arduino #temperature #temperaturesensor #bus #dallas

Пікірлер: 51

  • @BASEDinMaine
    @BASEDinMaine2 жыл бұрын

    *thank you* for such a thorough tutorial -- it is appreciated! I am using this sensor for a final project in my year 1 digital electronics class. This is the most detailed I have found so far.

  • @robertssmorgasbord

    @robertssmorgasbord

    2 жыл бұрын

    You're very welcome! And good luck with your project!

  • @rene-jeanmercier6517
    @rene-jeanmercier65174 жыл бұрын

    Hi Robert. Excellent and exhaustive explanation. Despite your remark of non completeness at the end, it is like you have said, all is needed to implement a fully functional system. Thank you for your time. It is much appreciated. Regards, RJM.

  • @robertssmorgasbord

    @robertssmorgasbord

    4 жыл бұрын

    Hello René-Jean, you're welcome! Regarding "fully functional" - I'm still searching for a library that works flawlessly with, respectively, fully supports the DS18B20 (at least the features I need). And if I can't find one I'll probably derive my own from that DallasTemperature library. So there will be an addendum to this video :-) Best Regards, Robert

  • @Monochram
    @Monochram Жыл бұрын

    OMG So simple and tiny sensor, soo many quirks and details! amazing video, just what I need for my current project

  • @robertssmorgasbord

    @robertssmorgasbord

    Жыл бұрын

    Yes, the devil is always in the details. Even if the devil has three pins only 😉 And thanks for the praise 😅

  • @SpinStar1956
    @SpinStar19563 жыл бұрын

    Great video! You are a very good presenter and did very well explaining the hardware and software. SUBSCRIBED! I am just getting into Arduino and videos like yours are very appreciated. so, don't worry about length--the subject dictates the time needed. Thanks so much!

  • @robertssmorgasbord

    @robertssmorgasbord

    3 жыл бұрын

    Thanks for the praise and subscribing! I don't know about being a "very good presenter" - almost blushing here ;-) - but I'm trying to do my best, and I'm always happy when people get something out of my videos. So, thanks again and you're very welcome!

  • @tobydigney3446
    @tobydigney34464 жыл бұрын

    Hello Robert, keep up the great work!Your thorough explanations provide much greater insight than all the short videos out there. I was hoping you could cover how to properly choose a ferrite bead for isolating noise between analog and digital supplies. Perhaps this would be good for the upcoming ADC video you hinted at in the comments of your triac video. All the best, T

  • @robertssmorgasbord

    @robertssmorgasbord

    4 жыл бұрын

    Hello Toby, thank you very much for the praise and yes, I will keep uploading tutorials like this :-) Regarding the application and calculation of ferrite beats: Unfortunately that's not really my area of expertise - yet ;-) Though I will use some inductors in two upcoming videos to filter 5V rails. But their values are either from datasheets or guesstimates :-( However, I'll put it on my wall of video ideas - no promises though. On a side note: A few days ago I was asked to make a video about NTC inrush current limiters for transformers. Also something I've got to read up on first. You guys really keep me on my toes - thank you for that :-) Best Regards, Robert

  • @tobydigney3446

    @tobydigney3446

    4 жыл бұрын

    Looking forward to it, Thank you!

  • @felixcat4346
    @felixcat43464 жыл бұрын

    This video is very interesting. In industry, however, most applications use something called "the 4 to 20 milliamp loop". It would be good to hear an explanation of how that works with temperature sensing. Thanks for posting.

  • @robertssmorgasbord

    @robertssmorgasbord

    4 жыл бұрын

    You're welcome! Ah, the industries great 4…20mA "standard". I assume you're talking about the analog version (German standard DIN 66258) for connecting remote sensors (one per line) and not the digital TTY/V.31/EIA-422/RS-422 stuff. I don't really have any use for that stuff (not being in a noisy industrial environment), but it's indeed interesting. I'll put it up on my wall of video ideas - but no promises ;-)

  • @dhruvjoshi7320
    @dhruvjoshi73203 жыл бұрын

    Keep up the good work Robert, Thank you

  • @robertssmorgasbord

    @robertssmorgasbord

    3 жыл бұрын

    You're welcome - and I thank you Dhruv!

  • @electronic7979
    @electronic79794 жыл бұрын

    Excellent and useful video. I liked it

  • @robertssmorgasbord

    @robertssmorgasbord

    4 жыл бұрын

    Thanks! Glad that you liked it :-)

  • @andymouse
    @andymouse4 жыл бұрын

    This was great, I have a DS18B20 and have used successfully, but I only had a vague idea that it was capable of so much more, i'm starting to read datasheets more carefully (about time at 54 !) certainly if you do a deeper dive into 'one wire' busses I will find it interesting...cheers.

  • @robertssmorgasbord

    @robertssmorgasbord

    4 жыл бұрын

    Thanks! Meanwhile I found another Arduino library specially for the DS18B20. Very simple, but maybe that will work. And you have no idea how deep I will go "down the rabbit hole" in regards to the 1-wire bus next week ;-) BTW the ADS1115 video will come up on the 10th of May :-)

  • @andymouse

    @andymouse

    4 жыл бұрын

    @@robertssmorgasbord great, I will be right behind you in the hole ! not sure I will get as deep as you but I will be tying hard, and i'm hooked on ADC's and making measurements in general, this seems a bit addictive.

  • @nikd0nic
    @nikd0nic2 жыл бұрын

    Hi Robert, thank you for your tutorial. Unfortunately I have also "-127" problem with waterproofing sensors. I noticed that when I connect 1-wire bus to pin 2 (or 3) after loop is running, measuring was ok. So I removed line with "sensors[bus].begin()" and it works fine. So I guess that waterproof sensors are not bad but initialization has to be different.

  • @robertssmorgasbord

    @robertssmorgasbord

    2 жыл бұрын

    Yes, initialization might have been the problem. With these waterproofed sensors you never know what chips are actually in there. The original DS18B20/DS18S20 are relatively expensive, so the temptation to use cheaper copies is definitely there.

  • @orenbous
    @orenbous Жыл бұрын

    Thank You, And one question is there are sides more sensitive than others ? trying to sense temperature of a glass plate (top, flat side, round side or button)

  • @robertssmorgasbord

    @robertssmorgasbord

    Жыл бұрын

    Never thought about that ... and to be honest, I don't know. I usually mount them with the flat side to the surface which I want to measure. In my opinion it is more important to thermally isolate the sides that are not touching the measured surface (e.g. with some foam) and to make sure that the face that is touching the measured surface has a good thermal contact (e.g. by using a bit of thermal compound).

  • @khangeshmatte4930
    @khangeshmatte49303 жыл бұрын

    Hello sir, I am working on the project where I have to use DS18B20 temperature sensor, and When I want to make the connection for Parasite Power mode, It shows me the error value "-127", I keep trying on it, and still unable to get the result, I am using temperature probe for it.

  • @robertssmorgasbord

    @robertssmorgasbord

    3 жыл бұрын

    Well, only one thing comes to mind: Do you have both, pin 1 GND and pin 3 VCC of the DS18B20 connected to ground? Otherwise the parasite power mode might not work. Anyway, without knowing the library you are using I can't tell what the error value "-127" means. Are you using my code from this video?

  • @khangeshmatte4930

    @khangeshmatte4930

    3 жыл бұрын

    @@robertssmorgasbord Yes Robert,. I am using your code and I am using waterproof temperature probe DS18B20,the library i am using is onewire and dallasTemperature, and I also connect vcc to the ground, still the sensor is unable to detect and shows -127degrecelcius.

  • @robertssmorgasbord

    @robertssmorgasbord

    3 жыл бұрын

    @@khangeshmatte4930 Do you have a link to the waterproofed DS18B20 you are using? I guess it has already a cable attached. Maybe they mixed up the colors of the wires and so the sensor ended being connected the wrong way. Another possibility is that your sensor is simply broken. Do you have access to a "naked" DS18B20? If so, you can use it to check if the Arduino side of your system is really working.

  • @khangeshmatte4930

    @khangeshmatte4930

    3 жыл бұрын

    @@robertssmorgasbord Hello Robert here's, the link:-de.rs-online.com/web/p/entwicklungstools-sensorik/2049893/ but I wanted to mention something 1. I am using 4 sensors they all are working fine in Normal mode when I connected Vdd to external power 5v or3 3.3v. 2 .but when I connected with Vcc to the ground(Parasite power) it shows a -127 dc error according to the datasheet it says the sensor is disconnected. 3.I have tried to break the sensor but it is difficult to open it, so I don't have access to the "naked DS18B20" but I am trying to find ways. 4. Do I use Mosfet for strong pull-up? Thank you

  • @robertssmorgasbord

    @robertssmorgasbord

    3 жыл бұрын

    @@khangeshmatte4930 The waterproofed DS18B20 sensors you are using (DFRobot) are absolutely OK. It was not my intension to make you break open one of them, I just thought maybe you have access / can get a DS18B20 without the waterproof stuff around it for tests. Anyway, using the OneWire and DallasTemperature library with an Arduino you won't need an external MOSFET for strong pull-up during temperature conversions - the libraries / the Arduino does everything for you (see 05:46​). I'm a bit at a loss here ... only two three things that come to my mind: 1) Make sure that all sensors on the (single) 1-wire bus are either normal or parasitic power. Mixing devices with different power modes on the same bus leads to disaster. 2) Increase the delay between .requestTemperatures() and .getTemp...() to say 1000ms (temperature conversion time for 12-bit resolution is 750ms). 3) Decrease the value of the pull-up resistor (minimum is 1.4kOhm - see 34:24​). Hope that some of this helps!

  • @softa74
    @softa744 жыл бұрын

    Hello, I need a little help, it's a temperature sensor DS18B20. I wonder if I can influence it to read the wrong temperature. I need to cheat the electronics to which such a sensor is connected at a given moment. It is an electronics for a pellet burner, more precisely a centrometal burner from 2012, and the principle of its operation is such that when the water temperature in the boiler drops below 60 degrees, it goes into automatic ignition. The ignition automatically goes should or should not need hot water. I tried everything but the only solution is to fool the electronics and give it the wrong information about the water temperature, that is. that the electronics receive a signal that the water temperature is 60 degrees or higher. Thanks in advance.

  • @robertssmorgasbord

    @robertssmorgasbord

    4 жыл бұрын

    There are many ways to get DS18B20 to deliver wrong temperature readings :-) But if you need the "wrong" temperatures to have a specific values (e.g. greater 60°C) only two solutions come to my mind: A) If you have physical access to the DS18B20: Use a heating element (e.g. resistor in TO-220 case) to artificially heat up the DS18B20 beyond 60°C. Make sure it doesn't go beyond 120°C though! B) If you have access to the dataline between the DS18B20 and the electronics: Open up the dataline and put a microcontroller (e.g. Arduino) between the DS18B20 and the electronics. The microcontroller reads the data from the DS18B20 via 1-Wire and acts towards the electronics as a 1-Wire slave (code for Arduino available) emulating a DS18B20. The microcontroller then either just forwards the temperature readings from the DS18B20 to the electronics, or transmits a constant temperature, e.g. 65°C.

  • @Mr.Leeroy
    @Mr.Leeroy3 жыл бұрын

    38:16 It's not the same at all. Phantom power is used on a _differential_ _analog_ transmission line and it is _never_ gets disrupted during operation like 1wire gets with pull-down.

  • @robertssmorgasbord

    @robertssmorgasbord

    3 жыл бұрын

    You're absolutely right! My bad for mixing up the terminologies - sorry!

  • @ghijorihajar2563
    @ghijorihajar25634 жыл бұрын

    I used one sensor ds18b20 but i always get -127 C can you help me please

  • @robertssmorgasbord

    @robertssmorgasbord

    4 жыл бұрын

    Well, not really without seeing your code and circuit. -127 can mean many things: Your sensor is not connected correctly ... Your requesting the temperature too early (DS18B20 hasn't finished the conversion) ... Any other possible hardware/software fault ... Sorry that I can't help you out there.

  • @ghijorihajar2563

    @ghijorihajar2563

    4 жыл бұрын

    @@robertssmorgasbord thank you

  • @Shivaaayy
    @Shivaaayy2 жыл бұрын

    Gain lot of knowledge I'm not using parasite mode still not getting more than 85°C for boiling water Below 85°C it works fine..

  • @robertssmorgasbord

    @robertssmorgasbord

    2 жыл бұрын

    Well, according to the datasheet parasite power should work fine up to 100°C. And while accuracy will degrade above 85°C, you should still be able to get readings +/- a few degrees C.