hello have you ever wondered what a load cell was and how you could use one with an Arduino to measure forces was no you’ve never wondered that oh we’ll just pretend that you have because that’s what this video is about this is a load cell here or one variation thereof they come in different sizes and shapes and styles but this looks like a pretty common one and it’s just an aluminium bar with a couple of machined holes here making a cavity which makes it a little bit more susceptible to being bent in this direction like that and there’s a couple of well as four wires going in here and they’re stuck on with some nice sort of a gooey stuff and as far as I can tell there is a sort of a resistor on each side and when this is bent the one at the top will become well if you’re bending it downwards the one at the top will become physically longer and the one at the bottom will become physically shorter and that will change the resistances of them a tiny tiny little bit and we can use this other thing over here which is a amplifier of some sort to bring that variation in voltage that’s produced by the resistance difference there to a level that the Arduino can read in and this little chip talks the Arduino and has some sort of intelligence in there itself to give digital values back from the analog values that it’s reading and from here so as a little bit of a background as to why I found myself interested in this stuff I’ve seen Bruce Simpsons videos where I use as one of these test stands to measure the thrusts produced by various motors and he does a sort of a sequence where he starts off by turning it up to produce 150 grams of thrust and he’s doing that manually which looks about fiddly because he has to sort of look at the screen and adjust the the dial and then look at the screen so it’s kind of a feedback where he’s he’s basically being a human PD controller to just the speed of the motor to get the thrust that he wants so I thought it would be cool to do that but have the computer adjust that automatically so you just tell the computer that you want 150 grams of thrust and it will just do it because the computer can if you’re using a load cell the computer can see the thrust that’s being produced and it can also control the output of the motor as well so that’s why I wanted to do it and also didn’t really feel like buying one of these but my first idea was to buy one of these and sort of fiddle around with it and put an Arduino in here somewhere and connect it up and do it that way but then to be honest I I didn’t even know what a load cell was I’d never heard of one until I saw this comment down here and that sort of set off a little light bulb above my head and I thought I’ll check into a load cell and see what that is and turns out to be exactly what I wanted so I’m not going to buy one of these anymore I’m just going to try and make my own little thrust and test stand so I jumped onto bang good to have a little search for load cells and they have a couple there’s a 10 kg and a 5 kg so I just got the 5 kg and it’s very cheap 3.25 and you also need this other thing which is this seems to be pretty much the one that everyone’s using it’s the HX 7 1 1 so analog to digital that means right ad so it’s it’s a 24-bit precision so it’s very very precise and it can read those tiny tiny variations in voltage and then the code that I’m using for this I found on Sparkfun website and I’ll put the links to this stuff in the description and this is a really good page to explain all about how it works and how to set it up or there’s some pictures of some other types so these little circular ones you’ll find on the bottom of your bathroom scales like that so there’s using two of them there I guess and then further down the page there’s a little bit of an explanation of the circuit that’s actually inside that little bit of sticky stuff on side of the on the side of the load cell and some explanation of what wires go where and also where they go into on your Arduino

and what I still want I’ll get here oh the source code yeah so I came here to find the source code and if you click on here you’ll be taken to a github repo that has a little bit of code in here with some examples I think in this firmware folder there’s some examples there that you can use but you don’t actually have the HX seven-11 the class that you need to use it so this should be I would have expected that there will be HX seven-11 cpp and HC x seven one one dot H files in here but they’re not in there so you can find them separately by just searching for HX 7 1 1 dot CPP and this one here has it and this one here has it but it’s such a small little piece of code that I’ve actually decided to bring it into the sketch that I’m going to upload to my website for this video that’s called load cell demo and as you can see I have one tab which is my main program part and then I’ve put the HX seven-11 class into this sketch as well so you could if you want to try this you can just download this and you’ll have everything ready to go and here without having to install any libraries into your Arduino IDE so let’s have a little look at what it does let me just plug in my Arduino so I have the setup to go into the right pins on the Arduino there so this program is pretty simple all it does is declare an instance of this class and I’ve called that cell and the 3 and the 2 is just saying which pins were using here on the Arduino to to talk to it and then we just open up a serial connection to print something to the serial monitor and then we just repeatedly print the value that we read from the cell and oh I have to restart that because I unplugged it in there hopefully that should restart what’s going on here oh it’s decided to hold on to unplug this and plug it back and I think it’s kind of a pain that that happens now alright now I have to restart this hold on ok now we should have a thing ok sorry about it oh it’s gone to a cm one I see upload yep alright so I just upload that for good measure and now we should be seeing some values showing up there ok so the number that’s coming up there the actual value of that number is not really important we mainly interested in the way that number changes when we put some pressure on to the other end of the load cell so what is it now 8 3 3 4 and if I push down a bit we’ll get 8 4 1 5 if I let go it should come back to 8 3 3 4 so this is just the raw value that the this watch me call it thingy there is giving us so we can use that along with some knowing weights so this is another thing that I found on been good so probably not going to focus but it says 100g on there so I have a few of these 100 gram weights and I’m using these to check the well to calibrate the scale and then to check the accuracy of it afterwards so going back to our program let’s make a little bit more sense of these numbers instead of just 8 3 3 4 whatever first thing I want to do is take an average over a long period of time so that we can figure out what the number is when it’s zero that is when there’s no weight on the scale so to do that we need to have a couple of values here so I’m going to call what’s wrong

Val and I’m going to use a float to count how many reads we’ve done and more sensible to call that count wouldn’t it and then in here I’m going to print out and say Val equals that then we’re going to print out Val but that’s not very useful because that’s what we’re already doing what I really want to do is take the average of this over a long period of time and one way we can do that is if we increment reads oops means equals I was calling it reads before that’s why count maybe I should have just pasted this in so we’re going to increment the value of count so we have counting up one each time and then we’re going to use that to say that the new value of count is going to be you want to keep a running average of the total that we’ve read so far so we’re going to say count – 1 divided by count multiplied by the current value plus 1 over count multiplied by the new value that’s coming in so this looks perhaps a little bit complicated but just imagine for example to use a concrete value imagine that count is currently 100 that means that this value here will be 0.99 because it’s 99 over 100 and this value here will be 0.01 so every time we read in a new value it’s giving less and less influence on the overall value that we’ve kept so let me just run that so now we should see that as it goes on as time passes that number will be changing less and less and I tried this before and for some reason it never really reaches a point where it stops changing completely I don’t really don’t know why that is could it perhaps be the temperature and the room is changing a bit or something like that maybe I’m talking too much and as I’ll hold it hotter washing over it or something but anyway let’s I’ll just pause that there so this this is the value that we’re getting when there’s nothing on the scale so I’ll just grab that number and I’ll just mark that as the value that we get when we are looking at zero so now if I print out the value minus that number and let’s just have a look at that oh except now we don’t want to be averaging it anymore do we we want to just be using the actual value so we want to get clips we want to get immediately updated value now so let me up upload that way and I oughta scroll that okay so now it’s it’s not a perfect zero because it still fluctuates a little bit so this is basically the value that we get when there’s nothing on the scale and we want to compare that with the value that we get when there is 100 grams on the scale because then that’ll tell us how much we need to divide this number by to get a value in grams so actually I need to put put another scale weight on this hand as well all right so put this right about there and now we’re getting 40,000 and 80 and sorry we do actually want to we

want to average this again don’t we yeah we want to we want to take the long long term average of that all right so I’ll just leave that run for a little bit yeah I’m not sure why it goes down consistently see how it’s slowly slowly edging downwards all right I’ll stop it there so 407 6 8 so if we take the number that we have there and divide it by four oh seven six eight and we need to make this a floating-point value so that we don’t do integer division otherwise we’ll lose some precision and that is by the way the reason why I’m using a floating point number for count because we want to do floating point division for these two numbers here as well so anyway obviously dividing this number by itself will give us a value of 1 so we need to multiply that by 100 to give us the value that we’re expecting because we have 100 grams on there not not one gram so we can either multiply it by 100 or we can just move this decimal place over a couple to about there yes we could do that so now when I run it we should be looking at a value of around 100 good auto-scroll back on okay so now we’re reading 100 grams and I can put another weight on there just to see if we get it to 200 or how close it would get it to 200 oh it’s going on there Oh what we’re averaging it all right ok now we’re done with the calibration so we can instead of taking the average value we just take the the most recent value only there we go okay so now it’s fluctuating a bit more because we’re not doing the averaging but it’s still you can see it’s pretty close to 100 grams so now when I put this on we should get 200 yep that’s pretty nice and if I take this third weight I only have three of them but if I put this one on we should get or look at that right on 300 isn’t that good so it’s sort of jitters around a little bit because it’s it’s always giving us the most recent value and I found that if you want to take a little bit of that jittering away what’s gone back to a little bit below zero there if you want to take a little bit of that jittering away you can do a slightly different sort of averaging instead of this one that averages over all values that we’ve read from the beginning until the end we can do a little bit different VAT averaging so we could use let’s say 80% of the current value and only 20% of the new incoming value I need a drink and this will average the values out a little bit so it’s not jittering around so much well what I do there oh I was just averaging okay now it’s now it’s got that all right so this is quite a slow average because each time we do a new read we’re only using the 20% of it and we’re keeping 80% of the old value so when I put the weight on here we’ll see probably see it changing quite slowly to get to 100 I’m going to take that off that’s a little bit slow really isn’t it you don’t usually see scales changing that slowly so instead of 80/20 I think I’ll just use 5050 let’s try that hmm only problem is that right at the

beginning we get some strange numbers but it goes away pretty quickly all right so let’s see how quickly it goes to a goes from 0 to 100 when I do it this time all right well that’s that kind of looks a little bit more like what we typically see on a set of scales like this so I think I’ll do a little bit of comparison here and see this I got on banggood as well by the way I was quite impressed with this it’s only like six dollars or something but the accuracy is pretty good so you’ve got 100 200 and 300 so this this is nice and accurate and we can use that too now that we have a scales that works we think it works we can use it to check the weights of some other things that we don’t know the weight of so what is that 10 11 closer to 11 grams 11 grams yes a little bit this thing here got to try and get it around about the same point I think 51 and a half 51 almost 52 I guess 52 yep good so far something a little bit heavier I have this erm AC adapter thing so hopefully hmm not sure if it’s quite in the right place but that is 292 293 some around there 293 course it a 293 there it’s just a little bit closer to 293 isn’t it on average yeah so anyway that is that’s as far as I’ve got with us so far but you can see that it’s very very easy to use and it’s just a matter of attaching some quadcopter arms to the end of here and doing calibration again because you’ve got to calibrate it for the center of the weight being out here and then you can do some thrust tests of your own and what I’m planning to do is make a nice little GUI so that the my desktop computer can control the whole thing right from calibration through to the 150 gram test right up to a full throttle run and make some nice graphs and stuff but that’s going to be the topic of a future video so for now I’ll thank you for watching and see you later

You Want To Have Your Favorite Car?

We have a big list of modern & classic cars in both used and new categories.