Temperature Sensor (DS18B20) Raspberry Pi

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] what's going on guys in today's video I'm going to show you how to set up the D s 18 B 20 digital temperature sensor with a Raspberry Pi so the things that you're need for this build include a Raspberry Pi can be of any flavor 0 PI 3 0 W whatever you have you're going to need a set of jumper cables in this case I have a female-to-male set of three jumper cables and then you're also going to need a DES 18 B 20 digital sensor probe so this one comes with a breakout board I highly recommend getting this piece because then you won't need to you know attach a resistor and breadboard it's a lot cleaner of a solution and that this particular sensor also came with this wiring harness so with all that said let's go ahead and get it wired up so the first thing you can see here on the sensor there will be three wires you have a yellow a red and a black wire so on this little breakout board you're presented with the DAT which I believe stands for data VCC and ground so ground is the black wire red wire plugs into the VCC terminal and then the yellow cable plugs into the data terminal right here so just go ahead put plug those in and screw them down so it's tight go ahead and get the attached wiring harness and then also plug them in in the similar fashion so you want the colors to be the same so for example here I know it's hard to see that the yellow cable is plugged into data red VCC in black in the ground and and then we'll just take our GPI GPIO jumper cable here and plug it to the end so for example I'm just going to egg I'm going to make yellow yellow so that's data and then I have green which will be green will be VCC which will be in the middle and then will be ground so that now that that set up we have everything wired up except for the PI so we just need to hook to the PI now so if I remember correctly blue was blue was ground so that's easy that's the third pin from the top always ground VCC which is red VCC who in it is the green cable so this goes to the 3.3 volt GPIO which is the first pin on the bottom row and for the data signal pin which is this yellow wire we're just going to pick a generic GPIO pin so let's call it 17 which is a six on the bottom one two three four five six so there you go that's it it's pretty much all you need to do to wire it up to the PI a note on the sensor here you can see that it's heat-shrink and there's this metal cover I believe it's also waterproof so you should be good to submerge it in water I don't know about how hot the water can be I would say probably not boiling water but it can handle you know somewhat lukewarm ER or hot water if you needed a high temperature sensor I think they have a ceramic temperature probe but that's something for a later video so now that we have all that set up let's go ahead and head over the computer and check out some of the code I lied we actually have to do a bit of setup before we can get to the code so what you're going to need to do is make an edit to your boot config configuration file so to do that we're going to type in sudo sudo nano /boot config dot txt you're going to add a line I've already done it but just scroll all the way at the bottom and at this line DT overlay equals W 1 dash GPIO save it so ctrl X and then hit yes and then after do that just do a sudo reboot I've already done that but you're going to do that for the changes to take place once that's done go ahead and type sudo mod throw W 1 dash GPIO and then pseudo-mod throw W 1 dash start once that's done setup we can go ahead and navigate to that specific sensor so if I can see D slash this but W 1 devices and then LS and you should see a 28 - like the serial number for your sensor probably will be different but as long as you see this you should be good to go so once you see that we can navigate to the to that specific instance right here so cd28 LS and then if we type cat w1 underscore slave we should see this output which means our sensor is working so that's a good sign so with all that said I'm done you know that your Raspberry Pi is properly configured and it's seeing the IDs 18 V 20 sensor so now we could move on to the code so you're going to want to open up PI charm and look at the script real quick so what I have here is a essentially a Python script which will read the temperature and output it so I'll just run you through what we have here real quick so it's made up of I believe 4 functions so the first function here sensor this is what picks up that serial number value which is right here so that way you don't have to type in anything it will find it dynamically if you have multiple devices - it should find all of them I think with the DES 18 B 20 you can read multiple sensors in parallel so that's like really that's really cool but it's not going to cover it in this tutorial this read function is what actually goes through and will parse the data and output Celsius and Fahrenheit and we'll return the Celsius and Fahrenheit values and then this loop function is what actually just prints it to the screen so with all that covered let's go ahead and run the script so all the files will be on the website and the links will be in the description as well so just FYI so now if I go to my PI and go back to my home ivory uploaded it here so python es 18 be 25 and run enter so you can see that every second is just posting the current value in Celsius and Fahrenheit so I'm going to really quickly put the probe into a cup of ice water and we should see the change occur so as you can see it's dropping quite rapidly right here from 10 degrees Celsius and it's a currently at 6 degrees now so we know that's working so that's pretty much it it's pretty straightforward to get the yes 18 b20 sensor up here with a PI it's pretty useful because it's waterproof and it can handle a sort of decent range of temperature and as for accuracy I'm not really sure I think it it performs a little bit better than deep the dht11 which I have a tutorial in a previous video so yeah I hope you enjoyed this tutorial if you like the channel leave a like or comment and I hope you subscribe and stay tuned for more content in the future thanks guys [Music]
Info
Channel: PiddlerInTheRoot
Views: 122,619
Rating: undefined out of 5
Keywords: ds18b20, temp, temperature, Raspberry Pi, Temp Sensor
Id: j7LLVkPpQ78
Channel Id: undefined
Length: 10min 8sec (608 seconds)
Published: Fri Jul 07 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.