Arduino Ammeter (with OLED) Converted to Wattmeter

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
good afternoon all I've got a couple of a meters here these are the ones I made from three parts the I na 2 1 9 well a meter chip on a little board an Arduino Pro Mini and this little OLED display so that's now displaying milliamps it's jumping around a bit but I've noticed and I'm sure people told me this at the time when I made this thing that that last digit isn't actually changing at all so one change I'd like to make to this now is to remove that last digit but also quite like to put milliamps on there ma this thing keeps tipping forwards so got a blue tick on that programmer board this is the CP to 102 I think it is and that should hold that nice and still good so yes what I'll do is I'll get rid of that last digit put milliamps on there and then after that I want to turn this into a watt meter now that's relatively easy to do we need to just add in a voltage measurement and it measures it between one of these two pins a compartment and which one it is it doesn't matter too much because there's very little voltage across there because there's only the voltage across that current sense measuring resistor that's 100 milliohms I think between there and ground so it measures the voltage between this point and ground and then by multiplying voltage by current of course will get power in watts right so here's the Arduino sketch for the eye and 81:9 up there you can see iron a 2 or 9 and the OLED so it's got sort of UAG to lib stuff that's related to the OLED and it's also got to iron a 2 or 9 we've got a couple of begins down here begin the iron a 2 or 9 begin the UHG - that's for the OLED and then in here we've simply got one variable current in milliamps and then a few statements here which goes and gets the current there's a get current statement there and then prints it to the display now I've been reading the UHG to documentation and it seems that print is pretty much the standard Arduino and I saw from the article on that well maybe I'll go to the article on that actually right so um Arduino CC here's the information for print now it says it's serial print but it kind of just works the same down here we've got print a number and I can print a variable and then comma and then a digit and that digit seems to be the number of decimal places so if you put a zero there you get no decimal places if you put a two you get two decimal places that must be the default because on my ammeter right now I've got two decimal places but the second one has no information in it it's just zero all the time so I think I'm going to put a 1 in here and just have one decimal place right so back in my sketch I've got here UAG to print current in milliamps so what I'm going to do though is I'm going to go comma 1 and that should take me down to one decimal place so let's compile and upload that and see what it looks like and I've hit the camera start recording thing earlier we should see some flashing lights on here once the compilation gets underway I can't see oh yeah there they go that's flashing and that's probably verifying that should reboot all right that's exactly what I want I want the current to just one decimal place this is milliamps because there's no current flowing so it's bobbing around the zero mark but yeah that's better that's got one decimal place right now what I want to put on there is ma I want milliamps on there because I want to know when I plugged these things in whether they're reading milliamps or what when I modify one for what I want to see a W on there so I don't get confused so let's put ma in there right so back to my Arduino sketch now I'm printing the actual variable which is current in milliamps oh that's a varying number now I want another line and it's going to be again u8g to print open brackets now this is where I want to text strings all some quotes mili-amps close the quotes close the brackets and put the semicolon in that should do it compile and upload right let's take a look when this thing starts flashing I can't see my compile and upload because it's actually off the screen but that should go pretty soon there it goes that's the reset light I think there's the upload there's the verify and it should come up with milliamps yay that's pretty good but as this jumps backwards and forwards between the positive value and a negative value milliamps is kind of jumping all over the place so I think what I'll do is I'll position milliamps on the right hand side of the display so that it's not jumping around let's try that right for that down here what I want to do is use this set cursor command both for printing current onto the display so this one says start at the zero X position and start at position 32 in the Y Direction that means start on the bottom row of pixels so let's just copy that ctrl C paste it in before this line which is where I'm printing milliamps and I want to take right over on the right hand side now this is a 128 pixel display so let's put it what would have would that be 64 not a bit more than that let's try something like I don't know 85 maybe 85 it still needs to be on row 32 so it starts printing from the very bottom line so that should put the actual milliamps value the constantly-changing value the left-hand side of the display and then this bit the string ma will be right over on the right-hand side so let's compile an upload right that's uploading and in a minute it will verify it looks a bit different that's because the TX and rx are sort of doing different things right that's sort of what I wanted milliamps is no longer jumping about my number jumps about because sometimes it goes negative but unfortunately I've got that a little bit too far to the right and I'm cutting off most of the a so my guess is I want to come back about mmm I don't know 8 to 10 pixels something like that right so here when I set the cursor in advance of printing MA 85 is too far to the right so I want to go back a bit I think I'll go out there 77 something like that I mean I'm guessing at the moment I could work out how many pixels M and a take but to be honest if I'm making other changes to this kodamas we'll just modify this each time I do it until I get it about right so compile and upload uploading verifying let's see if that fits on the display yes that's fine I can't see whether that's exactly on but certainly don't think I'm clipping any of that ma now now they're in trouble is if that went up to something quite high like 800 milliamps which does it print first I think it prints this number first and then milliamps so milliamps will always be sitting on top of the number so the number might get hidden under the M I'm not it's not a problem at the moment what I hope to do I suppose is find a little circuit to connect onto here so that I've got some milliamps flowing and just see what the effect is right so I got this bulb it's from a car it's 12 volts five Watts that's gonna make it a bit less than half an out maybe point four of an amp so that's 400 milliamps so I'm just gonna connect that into there screw that terminal down and then I've got to find 12 volts somehow to connect up to that right I've got a two point one mil socket here and I found some bits of wire I'll probably use the black one because I'll be coming out of negative so positive can go into V in plus in the end because I haven't I'm done that little screw terminal right that shoves in there that's fine and then negative I'll link from the negative they're round on to the bulb I need a little connector for that alright this one I do these are the little ones that Jeremy gave me which are super super handy so that just pushes in there and the other side pushes in onto the bulb now I'm expecting about half an amp to flow around this circuit that is a circuit isn't it I'm not going to blow anything up no okay let's plug in my solar 12 volts which comes from some lead acid batteries outside there is a fuse on the other end of this cable this actually goes to one of those cigar-lighter plugs there should be a fuse in the tip of that it's probably 5 amps or something we're only gonna be drawing about half an hour but I don't think we'll have any explosions let's find out ok that looks good and yes pretty much as I thought we've got now 352 points something milliamps and the number is sitting under milliamps and so we haven't got an ideal situation here I suppose I could do an if statement if it's greater than a certain number I don't know chop that digit off but actually what I might do is just make sure that digit there's in front of milliamps so maybe I'll lay milliamps down is the first statement we don't need that power supply that powers this when it's not being powered from the usb yes I'll put milliamps down first and then write the number so I can at least see it right so back to my arduino sketch here's all the stuff for a set cursor go and get the current value print it so let's chop that out control X now we do this set cursor and print MA so I'll do that first and then paste this look 12 V paste the actual printing of the live numerical value after I've placed milliamps so now the number should crash over the M and even though it doesn't quite fit on the display at least I get to see the which is the important compile and upload right reset that's the upload that's the verify what happens here yes it looks like nano amps but it's not it's just milliamps with half of the M removed now if I'm going to upgrade this to a watt meter I want to change that and put a W there so that's what I'll do next right so that's a very trivial change that just means that instead of MA in there I'm going to put a capital W for watt compiler and upload and the result of that should be a nice W there are of course some I've set the exposition for the M and the a so I need the W pushed over further didn't think about that I'll just do that now quickly right so I've done that and that's quite a nice narrow W that could probably go a little bit further up I started it at pixel number 100 so maybe I'll increase that gradually as I add in the other code for watts this isn't of watts of course this is to help me the amps there's no way that's 351 what when this is only a 5 watt bulb so now we need to calculate watts and of course watt C's volts times amps now what's the variable that has volts in it this one says get current underscore merely am so is it get voltage underscore V or something I don't actually know so what I'll do is I'll go to file examples now come all the way down to who knows it going to be its Adafruit I na 2 and I'm not sure if that's on the screen get current I think in this sketch it may also get the voltage okay it's called well I suppose I can name it whatever I want but they've named it float mmm really what I want is the load voltage now they calculate the load voltage as the bus voltage - the shunt voltage over a thousand I think what I'll do is I'll just get the the bus voltage which is the voltage actually at the power supply is not quite the load voltage because it'll be the load voltage will be a bit less because there's the burden voltage which is across that current measuring resistor that 100 milli ohm resistor but it's going to be pretty close so let's have a float bus voltage equals zero and then we'll do bus voltages INAT or nine get bus voltage underscore V I'll copy those lines and paste them into my sketch right so my new lines are here float bus voltage equals zero and bus voltage does a get so I na - a nine is the object get the bus voltage underscore V so in volts that will return it into this variable now to get power R we're going to need another float so let's have float hmm power yeah power will do equals zero semicolon right so power we need to now calculate it I can calculate it here it will be power equals and it will be hmm bus voltage times current milliamps times a thousand want it right so let's let that line there power equals bus voltage times current milliamps times a thousand now instead of printing the current milliamps I just want to print power power power in watts of course I don't need to says in watts because they don't say that voltages in volts you know what I mean you know I print the power let's compile and upload and see if that works well let's see if it compiles first well it can pardon uploaded but I'm getting some really weird numbers here and getting some enormous numbers while they're so big milliamps oh maybe I need to oh yes if it's reporting it in milliamps then I'm going to have lie a thousand milliamps is an amp this is about half an amp I think I needed to divide by a thousand I think I got it wrong yes here you can stop shouting at the screen now yes I got that wrong it's divided by a thousand fairly obvious when those really enormous numbers came up compile and upload so did I get that right let's find out upload there if I should have a number around about five watts for this bulb I mean it's not 5 watts why is that still wrong ah yes I know why we actually don't have any voltage I'm not reading the voltage the point is this module the iron a 2 & 9 can only read voltage if mmm how does this work I think ground on the Arduino or ground on the I na 2 & 9 current sense board needs to be referenced in other words needs to be connected to ground on my high current circuit which is actually this black wire here so I need to run a wire from that connection there through to ground on the Arduino I think right I can't find a very easily accessible ground point on the Arduino other than the one that's on this power connector now this is a bodge because i will need that power connector later when i want to run this off 9 volts but just to see whether this works i can plug that in there and then i can use this black wire because that's ground on the arduino and if i shove it in there shouldn't go bang it should give me 4 point 5 watts awesome that's I suppose anything really I can do now just to sort of confirm that this is all working I mean obviously is would be to put a little variable power supply in here so what I might do is feed the 12 volts into a power supply I might use a buck boost actually and then raise the voltage above 12 volts to get more watts and below 12 volts to get less right here's a buck boost power supply I can plug my 12 volts straight into there now in case you're wondering which one this is it's the Ming he model d3 806 I think that means it can put out up to 38 volts which would probably kill that bulb at 6 amps right so let's transfer my 12 volt input which is here disconnect that and plug it into the buck boost just see what it's set to 18 point 5 volts is a bit high so let's bring that down to 12 right that's 1.2 that'll do current is set to 1 amp that's fine don't really need a current limit and now I need to connect the output of that I have one of these conveniently little short 2.1 connect cables which i think came with i think these came with a what was it to power over ethernet type system no that's not going to plug in there very easily I'll rearrange this a bit right let's try this so we've got 12 volts there let's switch on and let's display volt so at 12 volts we've got 4 watts let's wind the voltage up to 12 and a half 4.3 Watts 13 and a half 4 point 8 watts that's interesting that's supposed to be a 5 watt bulb anyway ok I'm going about 14 5.2 watts and probably shouldn't go much about above about 15 for this bulb and there we've got 5.7 watts so yeah that's working fine 5.7 wind that down let's go really low that's getting dim 1.8 watts I like my new watt meter so all I need to do now is find a suitable ground point on this Arduino there's one here actually let me just get a bit closer on that one yeah that one there next to reset it actually says gdn but I think it's ground I think it meant they're supposed to say GND is not gdn garden now so I think that's probably a ground so I could probably put a little pin in there run a little wire over to my ground my zero volt point in my high current circuit which is this circuit here with the bulb and then this becomes a watt meter just does require that additional wire though so that it can measure the voltage at that point in the circuit and therefore indicate Watts let's just whine that voltage back up again get that thing back up to five watts which is what it's supposed to be and there it is so that's pretty cool my ammeter which this one still is actually it's a milli ammeter I suppose because it is reading in milliamps this one doesn't have the MA has been modified to become a watt meter and I think that will be extremely useful in my Muppet experiments cheerio
Info
Channel: Julian Ilett
Views: 32,342
Rating: undefined out of 5
Keywords: Arduino, OLED display, INA219, Watts, Amps, Volts
Id: zvcTUMBGO24
Channel Id: undefined
Length: 21min 5sec (1265 seconds)
Published: Fri Aug 04 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.