ADC (MCP3008) 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 be covering a little bit more of an advanced tutorial so I'm going to be talking about how to set up an analog to digital converter for the Raspberry Pi so the things that you're going to need include a set of male to female jumper cables breadboard in this case it's a half size of breadboard the MC p300 8 analog to digital converter and some flat breadboard jumper cables they just make wiring a lot nicer they're not really necessary you can get away with regular jumper cables but in this tutorial I'm going to be using them Raspberry Pi in this case the Raspberry Pi 3 and for testing purposes we are going to use a capacitive touch sensor which is analog so there are two ways of wiring the mCP 3 0 0 8 I'm going to show you how to wire it up for Hardware SPI so that's a lot easier of a configuration process for the Raspberry Pi so with all that said done let's go ahead so moving some of this stuff to this side let's focus here on this half size breadboard so I've already went ahead and put some of these flat jumper cables in the mCP 3 0 0 8 the orientation is very important so if you see here there's a little dot so that should be on the top the the VDD I believe is this top pin on the right should be hooked up to 3.3 volts so I've essentially bridged this this pin here to the positive rail and then also the VR EF is also going to three point three so it's on this positive rail and as for their grounds their grounds include the AG and D so that's bridge to the negative and then for the for the other ground which is a d GN d which is this bottom most pin is also British De Niro so now we're going to need for GPIO connections to be made so I'm going to just rip off four of these right here and just attach them in a linear fashion so there will be four ports available so just go ahead and plug those in so now that that's done we just need to make the appropriate connections on the PI so the topmost pin is the SCL K and I know I apologize so that this yellow jumper cable is connected to the C L K and that goes to the s CL k pin on the PI which is the ninth on the bottom row so let me go ahead and count that one two three four five six seven eight nine and then continuing continuing on we need D out which is the green pin are the green jumper cable and that's connected to the miso pin on the PI which is right next to the yellow pen I apologize for this slow process I'm sort of reading off this manual here yes so now that we got the clock D out we need D end so of course DN is the blue cable in my case which is a third going down and that's hooked up to up to mo s I which is right next to the green pin obviously and finally we're left with the CS HS / s HD n which is the bottommost purple pin and that's hooked up to CT 0 1 so C 0 1 is right across from this yellow pin and there we go that's pretty much done so yeah I apologize if this is hard to fall it'll be a schematic on the website that should clearly lay it out for you so now that we've hooked all the necessary connections to em cp3 0:08 we need to go ahead and get three more jumper cables so I'm just gonna pick three random ones this is your right here so I have a red brown and black cable so the red cable this is gonna go to the positive rail which will be 3.3 volts and then the ground will go to the negative rail so this red cable goes to 3.3 volts and then black hip goes to any available ground so let's just do two three third pin from the top so that's ground and then this will be our signal cable so as you can see we've plugged everything up on this right side so these are the available channels I believe there's yeah there's eight available so we're gonna start at zero which is the topmost and then plug that in right so I made an error we're actually going to need two more jumper cables so we're gonna need we're gonna need to supply the sensor with power so we're gonna need to hook into this positive and negative realm right here so I'm gonna just go ahead and do that so now actually let me flip that around so it makes more sense so rad will be positive all around thank you sometimes these holes are there we go so looking at this type sensor we can see that it has a ground VCC and signal so ground obviously is the orange kibble here so that goes to the negative real VCC we supply the 3.3 volts and the signal cable in this case is brown so this goes to signal so this is sort of the the process that you're going to go through to hook up an analog sensor so in this case it's a capacitive touch sensor but if you had another sensor this is essentially where the only change would happen right here of course that's not the case for all sensors but for the most part so now that that's done we're gonna go ahead and head over to the Linux terminal to activate the SPI interface and also download the mCP three-zero-zero a library and then we're gonna go ahead and run some test scripts and a sample script for the capacitive touch sensor okay so I jumped over to my other computer and I've essentially fired up a browser here and I'm looking at the Adafruit tutorial for the mCP 3:08 this is sort of the guy that I'm following if you ever run into issues I highly recommend you take a look at this guy there'll be a link in a description below so as you can see here it sort of walks us through the process the two different pin out setup so we're going through the hardware SPI setup currently so let's go ahead and fire up a SSH terminal and login to the PI the first thing that you're going to need to do is sudo RasPi - config and you're going to need to go down to interfacing options and go to SPI and make sure that it's enabled yes okay and then just finish so now that that's done we're gonna need to go ahead and essentially check to see if SPI is enabled so I believe the command is Ellis mod yeah so Ellis Maude we can see that SBI underscore BC M 2 8 3 5 is that his present so I believe that it's an indicator that SBI has been enabled we can there's also some or all the ways to check but that's sort of a quick check so now we're going to go ahead and install the bigot project the Adafruit git project for the NC p30 right so you go ahead and do a git clone I'm also assuming that you your current raspbian is up-to-date so if I don't know if you've already have but go ahead and do this to apt-get update if you haven't make sure you go ahead and do that if you ever run into problems or dependencies ish dependency issues double check the Adafruit site that I mentioned previously so now that we've cloned the the gate project let's navigate to the new directory so CD go ahead and install seto setup sudo python setup I install I already installed it so you'll probably see different output okay in this case it was successful and now we can do an LS to see more of the contents within this directory and let's navigate to the example subfolder there were presented with two different Python scripts so go ahead and use any editor text editor that you want we're gonna have to make a couple changes so here in simple tests by default the hardware portion is commented out so go ahead and comment the SPI configuration part so anything like the CLK down to MCP go ahead and comment that out and then uncomment everything under this hardware line here so SPI port to NCP make sure that's uncommon today head and save that double-check differentials off by and make sure that's the same case here go ahead and comment out all a head of the software SPI portion and uncomment the hardware portion okay so now that I've made the changes to the script I'm gonna go ahead and run the test script so I'm going to do Python simple test py I'm gonna hit run and then I'm gonna go ahead and touch the capacitive sensor and you should see some changes to the zero channel so let me go ahead and do that see here the zero channel is where we hooked up our capacitive sensor so when I wasn't touching it you could see that it was all zeros and then right here when I touch the sensor is essentially a binary result and if the value changed 2023 so now we know that the analog to digital converter is set up correctly and the final script that I made was more in line with the capacitive touch sensor so in this case every time we touch the sensor it'll register like that touch event happened and there will be a time out so that way it doesn't constantly like print to the screen that message so I'm gonna go ahead and run this Python touch py script so again I'm gonna go and run the script and then touch the sensor and you should see the output so there you go guys you can see that every time I touched it it print out this message touch detected and that's essentially how you interact with the analog to digital converter on the Raspberry Pi stay tuned for upcoming content I'll be going through some of the more interesting sensors that don't natively work with the pi unless you have this sort of conversion setup and oh and I hope you leave a like and subscribe comment down below if you have any problems I'll try and answer to the best of my ability and peace [Music]
Info
Channel: PiddlerInTheRoot
Views: 40,942
Rating: undefined out of 5
Keywords: MCP3008, Raspberry, Pi, ADC
Id: jDJAklvIuPY
Channel Id: undefined
Length: 16min 35sec (995 seconds)
Published: Sat Aug 26 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.