TUTORIAL: How to / About the ADS1115 External 16 Bit ADC - Part 2

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay I suppose this is a bit weird and maybe interesting that suppose that I'm going to be using the SP 32 because primarily the Arduino seems to take the command if you like the Arduino is usually they go to microcontroller the all the videos are about by the way I thought it'd be different so PSP 32 I'm going to plug in one side of this into the breadboard it's going to be the side with our X 0 and T x0 in it and I'll just push this signal it doesn't really matter does it all to push it anywhere they will do so push the ESP 52 in and now I think I'll push the the a ds-11 5 in and now let's get some jumper wires home let's sort this thing out so to start with I've got a red wire and I'm going to go from 3.3 volts on the ESP 32 to the VDD pin which I'm sure it's supposed to be VCC then in fact owners just zoom out a little bit that's better so you can just see the ESP 52 then I'm going to go from ground on the SP 32 to ground on the ATS one on five then I'm gonna go from which we go to your next SC ow I always get confused with this but I'll go from pin 22 I hope it's 22 now I got confused between pins 21 or 22 there anyway 22 to a CL I hope that's right then I'm going to go from 21 to SDA oops you could be the other way around but I'll confirm that later pretty sure it will be right there and then I'm going to go from ground again oops I've just pulled that off there and we go from ground again to a DDR address and I just thought I'd add something in at this point if you are working with the Arduino you'd usually use pins a 4 and a 5 thought I squared C off the top of my head anyway I can't remember which ones which but you'd use a 4 and a 5 anyway so now I have a pot ground into a DDR the reason being is because the voltage of a DDR determines the address of the thing so if you have more than one of these then they can have separate addresses and by connectedness the ground that gives it a certain address which which I know and that will help me later on down the line right so I've got the thing wired up but I how we're going to test it it's a test it we really need to read in a voltage of course into the pin so at least one or two other pins so I'm thinking of a quick way to do I mean I could use a current shunts or something but I'm not gonna do that I'm gonna do a very lazy way so what I will do is I'll take out the ground wires let's take out the ground from address and put it into the ground rail like that and then I'm going to put the ground on the aid yes one more v to the ground rail as well and of course address address needs to go into the ground rail too let's put that over there to keep it simple so now what I want to do is I want to make a very simple voltage divider and very lazy I know so I'm going to have a 10k resistor from 3.3 volts to the breadboard and then from the same connector I'm going to go from there to the ground rail just like that so I've got a resistor from 3.3 volts to here and then from here to the ground rail and in the middle I'm just going to have two wires two little jumper wires right in the middle of the tube and one can go to a zero and the other one can go to a two so what should happen now is we should be reading 1/2 of 3.3 volts in two pins a 0 and a 2 and now we should do is we should ground a 1 and a 3 if we're not using them it's considered bad practice to leave them floating so we'll ground those two and the reason being is that it can just get interference so we're going to go from a 1 to ground and I can find another jumper wire here there we go a 3 a 3 also to ground and this is our test break if you like so I'll put this thing in now and we'll go over to the code and let's see what happens right so we need to go to sketch and then include library and then manage libraries and of course the repository is going to show up and it'll show us all the libraries so you've got type or topic all unfilter your search in filter your search type in either fruit and it's this top library here so it's a ds1 x-15 I suppose I've got something to say about Adafruit look how many libraries they write here and they write them for us and we don't pay for them so that's really excellent work and we kind of owe them for that because without them right in these libraries we'd really be struggling or it'd mean is that we'd basically have to write our own libraries or rely on you know the odd the odd guy here he writes one and freely gives it away on github or whatever so yeah they do some very good work so we should probably support them by buying some of their products or whatever so that they can invest the money in investigating new technologies and write and new libraries I suppose so yeah install that thing and then you might have to restart Arduino and then go to examples and then go to a ds1 x-15 and then like I said earlier we've got three different modes that you could use this comparator differential and single ended all three are useful but for the purposes of this tutorial I'm just keeping it simple I'm going to choose single ended and what this means is that we're just going to measure the four different pins individually right to start with we've got the 16-bit version so I'm gonna delete the other line and ctrl T and then over here let's just make some changes 1 1 5 200 that's what I'm used to and then over here I suppose we can comment that out right now whilst gonna gloss over this I was just gonna cross over and move on and say there you go but actually I think it's quite important basically the way this works is that you've got to consider the voltage to use the power the ADEs module so if you're pairing it with 3.3 volts or 5 volts than the input to any one of the analog pins cannot exceed that voltage so in my case I'm pairing it with 3.3 volts and it basically means that I cannot read more than 3.3 volts into any pen any one pin so you can't do it and if you do that you can damage your ADC and likewise of using 5 volts your power of 5 volts do not exceed 5 volts in any of the ADC pins ok then going on to gain this is where I suppose it gets quite interesting you've got to have a trade-off between potentially destroying your ADC and having good resolution so let's say for example you're measuring the voltage drop of a current shunt and let's say the maximum voltage drop could be 200 millivolts then you'd use this one here because the range allows it so you want to get the smallest number you can really but not so small that you would ever exceed this number so for a current shunt 200 millionth millivolts max you definitely use this one what about if you were trying to measure a you know the voltage of a lithium-ion cell or something like that lithium-ion cells range from 3 volts to 4.2 volts so which one would you choose you have to choose this one because 4.2 volts is greater than that one so you couldn't benefit from the precision of that one you'd have to go for this one so yeah basically look at the thing that you're trying to measure and make sure that it is lower than this number if it's higher than your number then you're gonna have problems so yeah so in my specific example what am i doing well I'm reading 1/2 because I've got the voltage divider I'm reading 1/2 of 3.3 volts which is about one point seven five volts or something like that so which game should I use well I can't use that one because one point seven volts is higher I can't use that one I'd have to use this one and these go from minus to plus as well which I don't think I'll go into that but basically the maximum I could read in is around 1.75 volts and therefore this one is the most appropriate so underneath this one you don't actually have to use any but if you don't use any you got stuck with this one which is still definitely fine I mean you still get excellent resolution with this ABS module because it's an excellent module and it resolves to a 65,000 counts which is incredible anyway I'll stop waffling and carry on so gain of 2 okay then over here we've got into a DC 0 1 2 & 3 to define the variables which the values get read in to then we read them into the values and here we've got serial print line which prints the very very walls out so I'll upload that to the ESB 32 I've got it selected and I've got the comm port right so I'll upload it and let's see what happens to start with right so ctrl shift em and let's see what happens so we're reading in these values 0 1 2 & 3 so 0 & 2 are 28,000 300 or 400 or whatever and 1 & 3 are minus 1 and minus 2 and I suppose that makes sense because we're reading values from well there are 65 thousand values potentially that we could be reading from so yeah this denotes near-full kind of and this denotes near zero which is midway between 0 and 65,000 what we need to do now is change it from camps to voltage so let's close that and I suppose it would be a good idea if we just did this so I'll change well not change I'll just write float there so let's do this ffffff and then we will do 80s whoops ABC zero no F ABC zero equals this x and now this is quite cool really we don't really have to do any calculations because Adafruit have already done the calculations for us I mean they're not particularly difficult anyway but whatever so you see this value here on this one here if you have the 80s one one one five choose the gain that you've selected and just copy the amount of millivolts here and that represents the amount of millivolts per count so yeah so flow ADC 0 equals ADC 0 multiplied by the amount of millivolts per count or actually the amount of volts per count where's that millivolts hmm well soon see Amy in fact I think I is millivolts zero point whatever many volts while that's extremely precise anyway so control T and we need to do this for ADC one two and three so 1 & 1 2 & 2 3 & 3 so ctrl T and now we just need to change this so f FF and we might actually have to put string around that as well I'm not sure if it will work otherwise so let's take this then put it in there and let's see what happens so ctrl T control you let's see what happens so it's uploaded now so I'll press ctrl shift m' and see what happens okay so a zero is reading 1750 millivolts and a 1 is reading zero and a 3 is zero on a two is 1716 millivolts so that's bear this in mind 1760 I'll go over to the camera and we'll check it with the voltmeter and make sure so 1760 okay so that's the ADF and the s 332 I've got my voltmeter and I'll set this to the 2,000 millivolt range and let's see what happens so what I want to do is just measure maybe two of these pins so we'll have we'll hold ground on the ground pin and then over here let's do a zero and you can see that it says whoops you can see that it says 1670 let's try the next one see it well 1 millivolt next one 1670 so it's extremely close and the difference could be due to a number of things but it's only a very tiny difference but it's most likely because there's a large amount of resistance in these wires to use along wires and it's cheap cable so I would imagine it probably is absolutely spot-on so we're a couple of millivolts out according to the voltmeter but I'm extremely happy with that and I think that probably more accurate than the voltmeter but who knows so anyway that's how to use the ATS 1 1 1 5 and that's how to wire it up with the SP 32 so of course in real life you wouldn't be using the voltage divider which is here you'd actually plug in the value you know the pins for the thing that you're trying to measure I mean but there you go so that's how to do it that's how to wire it and that's how to use the code which is supplied by Adafruit so thank you for watching you
Info
Channel: Antony Cartwright
Views: 65,481
Rating: undefined out of 5
Keywords: Arduino, ESP32, ESP8266
Id: XxUMc1jnI9U
Channel Id: undefined
Length: 16min 25sec (985 seconds)
Published: Sat Apr 21 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.