Analog to Digital Converter [ADS1115] (Raspberry Pi)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey what's going on guys today's tutorial i'll be covering how to set up an analog to digital converter in this case i'll be using a pi hat that utilizes the ads-1115 so just a quick note analog to digital converters are pretty varied in their capabilities so i'll leave a link in the description that goes over the specifications for the ads-1115 so that way you can evaluate if it is suitable for your use case and as always you can find the links to all the components i'm using as well as the link to the official write-up in the description below so let's move on to the physical setup so quickly going over some of the components here i have a raspberry pi 4 three dupont jumper cables male to male the adc hat as well as a test sensor in this case i'm using a capacitive moisture sensor so the first thing you're going to do is take the included wiring harness on the moisture sensor and attach it to the header and then you're going to move on to the adc and attach the three cables to the screw terminals so let me quickly throw up a diagram and walk you through the wiring so on the adc side you're going to plug in the orange cable to 3v3 the yellow to an 0 and the green to ground then you're going to match them on the opposing side to the moisture sensor so the green goes to ground orange goes to vcc and yellow goes to a out just a quick note i'll only be covering setting up one channel for this tutorial but if you wanted to set up multiple sensors you would follow the same wiring scheme the only difference being for each sensor you'd have to change the yellow wire to the correct pin so it would be and one two or three and you'd have to double up on 3v3 and ground so this is what it should look like once you have everything wired up the final step is to attach the hat to the headers on the raspberry pi so it'll look like this and then at this point you're ready to go we just need to boot up the pie and then set some things up on the os so let's hop over to the terminal okay so i've ssh into my raspberry pi if you're using the q you can just open up a terminal and follow along it'll be the exact same process so the first thing we need to do is ensure that our i squared c interface is active so we just need to run the command sudo raspy dash config from here we're going to go to interfacing options and select ice to see here and then just hit yes and then we get this message and we can just go to finish so at this point we need to check to see if it's detecting our adc hat so the command we're going to run is pseudo i squared c detect dash y one and then it should spit out this grid formation and it's usually set to 48 by default there's a little jumper thing that you can switch if you want to use a different address but if you see 48 that means everything is good to go so at this point we need to install the circuit python library for the ads1115 so the command that you're going to run is pseudo pip 3 install adafruit dash circuit python dash ads 1 x 15 and just hit enter okay so now that it's done let's clear screen real quick so the library includes a few examples that you can run right off the bat to check to see if your sensor is working so if you navigate to the github link for the ads library i'll leave a link in the description there's actually an examples folder that adafruit provides for some test scripts so i'm going to go ahead and run the simple test i'm going to modify it a little bit so that the output is more descriptive but um as you can see here uh the code's uh pretty straightforward it's just defined the um input channel so channel 0 and then it's just going and printing the value as well as the voltage okay so i copied the simple tests uh script contents into a script that i called the adc test so if we just inspect that real quick uh you can see the changes i made i just added some print descriptors here so uh chan zero is what's printing out and then also if you notice like the chan equals analog in ads p0 i also added this commented line to demonstrate how you would add the additional sensors so p0s already defined we have p1 and then two and three and then also you would copy this print line with uh you know channel one two three um so yeah that's basically the script setup and how it works so if we go ahead and run that with kudo python 3adc test.pui so when i hit enter you should see the channel number the raw value and the voltage and then i'm going to quickly touch the sensor to change the capacitance and then you should see the values change so the script is running now i'm touching the sensor and you can see that it is changing and there you go so we have verified that the adc is working the sensor is working you can go ahead and stop the script so that concludes the tutorial for today in regards to the analog to digital converter with the raspberry pi in the future i plan on featuring specific analog sensors and showing you how to set them up with this platform i hope you enjoyed today's tutorial it's always appreciated leave a like and subscribe and yeah stay tuned for upcoming content peace
Info
Channel: PiddlerInTheRoot
Views: 26,004
Rating: undefined out of 5
Keywords: Raspberry, Pi
Id: tFefuPWqXT4
Channel Id: undefined
Length: 6min 47sec (407 seconds)
Published: Thu Dec 31 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.