Welcome back to another circuit basics. Video today, I’ll be showing you how to set up the DS 18 B 20 temperature sensor on the Raspberry Pi, the D S 18 B. 20 is a small little digital sensor. That looks just like a transistor. The nice thing about this temperature sensor is that it only needs one wires to send data to the PI it uses. What’S called the one wire interface. Only three wires are needed in total, including the power and ground wires in this video tutorial I’m, going to show you how to set up the D S 18 B 20 so that it outputs temperature data to an SSH terminal like putty, then I’ll show you how To set it up, so it outputs to an LCD display I’ll be using some sample code written in Python, then we’ll leave a link to the post where you can copy the code in the video description. Alright let’s get started, got my PI here and a couple bread boards I’m, going to put the D s 18 B 20 in the breadboard. With the flat side facing me on the D s 18 B, 20. The pin on the right side is VCC. The center pin is the data pin and the pin on the left side is ground. Then I’m, going to insert a 4.7 kilo ohm resistor between the VCC and data pins. Next I’ll connect the jumper wire from the data pin of the sensor over to pin seven of the Raspberry Pi.
All the raspberry pi pin numbers I’ll be talking about here are the physical pin numbers on the board. Now I’ll connect the VCC pin of the sensor over to the 3.3 volt pin of the PI. You can also connect it to the 5 volt pin, but I’ll be using the 5 volt pin for the LCD later on now connect the ground pin of the D s 18 B, 22 pin 6 of the pie. You, okay, I’m, going to assume that you established an SSH connection or some other way to access the command prompt I’m going to be using putty. So let me just open up putty and log into my pie. Here I have the full version of raspbian Jessie installed right now, and the first thing we’ll need to do is configure the one wire interface on the pipe to do that. We need to edit the boot config file, so the one way or interface will open up the next time. The pipe boots up so enter sudo. Nano boot forward, slash config, dot, txt and scroll. All the way down to the bottom. Dt overlay equals W one gpio control XampY to save an exit. Now we need to reboot to activate the boot config changes so enter sudo reboot log back in you now enter sudo modprobe w1 GPIO, then pseudo mod probe, w1 therm enter CD. Four slash sis ford, slash bus 4, w one forward, slash devices now answer LS to show the unique address of your D s: 18 B 20.
The one I have connected has the address 8. 0. 0. 0. 0. 0. 6. 6. 3. 7. 6. 9. 6. Now enter CD, followed by the address shown in the previous step, in my case I’m, going to enter CD 8 0, 0, 0, 0, 0, 6, 6, 3, 7, 6, 9. 6. The D s 18 B, 20 stores the temperature reading is a file called w1 underscore slave. Entering cat w1 underscore slave will show the contents of the file, which are the right temperature of VDS, 18b 20 see this number here T equals to six 187 that’s. The temperature in degrees Celsius without the decimal point, so my sensor is currently reading twenty six point. One eight seven degrees Celsius now let’s run a program that will take that raw temperature value and convert it to degrees Celsius and Fahrenheit here’s, the blog post, where you can find more details about the D s 18 B, 20 techno specs. She wiring diagrams steps. We just did to enable the one wire interface so here’s, a Python program that will output temperature to the ssh determinant I’m. Just going to copy all this, you can enter CD to get back to the root directory I’m, going to create a file called temp py right click to paste the code in there I’ll enter Python temp that py to run it okay. So here are the temperature readings output with Celsius first and Fahrenheit. Second, alright, now let’s set this up, so we can get the temperature output to an LCD display.
I’Ll insert my LCD into the breadboard. You now I’ll connect a jumper wire from the VSS pan of the LCD to the negative rail. The breadboard, like the VDD pin of the LCD to the positive rail. The breadboard I’ll insert a 10k potentiometer to adjust the contrast. Then another 10k ohm potentiometer for the backlight brightness, now connect a jumper wire from the vo pin and the LCD to the center pin of the contrast. Potentiometer then I’ll connect the RS pin of the LCD over to pin 37 of the PI and all the pin numbers that I’ll be talking about are referring to the location of the GPIO pins on the Raspberry Pi board. Next i’ll connect the RW pin of the LCD over to the negative rail of the breadboard and the epen of the LCD over to pin 35 of the Raspberry Pi. Now I’ll connect the data pins in 4 bit mode, so we only need to use data pins d4 to d7 I’m going to use a ribbon, cable and it’s kind of hard to see but I’m. Connecting data pin D for the LCD to pin 33 of the PI LCD pin d5 to pin 31 of the pie. Six: two pin 29 of the pie and LCD pin d7 to pin 23 of the pie now I’m going to connect the jumper wire from the a pin, the second to last pin on the LCD to the center pin of the backlight brightness potentiometer, now connect the Last pin of the LCD pin K to the ground rail of the breadboard.
You then I’ll connect one of the outer pins, backlight brightness potentiometer to you, the positive rail of the breadboard. It doesn’t really matter which side you connect. It only affect which direction knob turns increase or decrease the backlight brightness. Next I’ll connect one side of the contrast potentiometer to the negative rail the breadboard same here. The side you connect just determines whether clockwise or counterclockwise turns the knob turn up or down. The contrast now just move the ground wire from the PI over to the negative rail, the breadboard then I’ll connect. The negative pin of the D can be 20 to the negative rail. The breadboard I’ll connect the positive rail, the breadboard over to the 5 volt pin to the PI pin to and the LCD lights up right away. Let me just adjust the brightness and contrast potentiometers you, okay, now that we have the LCD connected, we need to install a Python library to drive the LCD it’s called the RPE LCD library. This library has all the functions we need to print to the LCD and do other stuff. Like scrolling and positioning text. We need to download the library with the Python package index or pip. Pip might already be installed on your PI, but if not enter sudo apt get install Python pip at the command prompt you! Okay! Now we can install the RPL CD library by entering sudo pip install RPL CD, now let’s open up our example program control Katie of the soon now I’ll copy this example program, which will output the temperature readings to the LCD you.
So now you can see the temperature is displayed on. The LCD is the temperature in Celsius and the bottom line shows Fahrenheit, and when I grabbed the sensor, the temperature increases in this program. We’Ve, rounded the temperature value to one digit after the decimal to change. The number of significant figures, edit line 31 in the code for Celsius and line 44 in the code for Fahrenheit, which says round temp C comma one – the one – tells the program to round to one place after the decimal. If we change the 1 to a 3, we get 3 significant figures after the decimal. Do the same for fan you so now the temperature readings are displayed with three digits after the decimal all right, well, that’s about it, hope this videos helped you get this little temperature sensor up and running on your PI.
arduino ds18b20 Video
arduino ds18b20 news
Posted on Friday July 05, 2019An Arduino Sickbay Display Worthy Of The Enterprise Hackaday … Continue Reading »
Posted on Tuesday February 26, 2019The No-Parts Temperature Sensor In Your Arduino Hackaday … Continue Reading »
Posted on Monday March 07, 2016Exploring Edison – The DS18B20 1-Wire Temperature Sensor iProgrammer … Continue Reading »
arduino ds18b20 Social
🔬 Now that you’ve gotten your feet wet, dive into the kit and enjoy all nine experiments. Order yours today: http://bit.ly/2MnQ7fr