15 Minute Arduino Project: OLED Ammeter INA219

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
good morning all today I'm going to build an ammeter using an OLED this little 128 by 32 and a current sensor the I n a 2 1 9 now I've already done a couple of videos one on the I n a 2 1 9 census offered a card up there for that and also another card for the OLED which I also did using the u8g 2 library this one 28 by 32 OLED another card up there for that one now in those 2 videos I used an Arduino Uno or something very similar but this time I'm going to use the Arduino Pro Mini and it's this particular type with the 2 rows of pins down one side because if you flip it over the I squared C which is VCC ground a 4 and a 5 roughly lines up with the pins on the current sensor and also the pins on the OLED so let's have a closer look at that now firstly you can remember that a 4 is SDA because D is the fourth letter of the alphabet that doesn't work with a 5 and SCL but just remember the D bit so here we have VCC ground ground VCC so those will have to be flipped around SEL SDA we've got SDA SEL those two will have to be flipped around and for the OLED sitting on top of this board ground VCC they're in the correct positions ground VCC and again SCL and SDA will have to be flipped around so I'm going to take the pins out of the OLED display take the pins out of the current sensor and just use pieces of wire to make a sandwich of these three boards so the first thing I need to do is to take the plastic piece off this 4-way pin adaptor because then when that plastic piece is off I can just heat up these pins give it a whack and they should drop out onto the bench right let's see if this is going to work just heat up these pins one at a time and flick them out yeah that works well that one didn't shy ground okay they those two are going to need a little more encouragement right I'm going to use some of this 24 swg tinned copper wire as my little link wires so cut off some pieces of this that's probably a bit too long really bit alright for wires for wiring the OLED on to the pro mini right let's solder those onto the front of the board ground VCC SC l SD a okay so this is how I'm going to do it we've got ground ground VCC and then SC LSD a cross over now at the moment those wires are touching but once I've pushed this right down as far as I can reasonably get it then I'll force a screwdriver in there and just push those two wires apart so they're no longer touching I'm just wondering whether to put a bit of a sticky foam pad in there perhaps I'll do that after I've soldered it right let's solder these on here but I'm not going to cut these off because these carry on and we'll go through the current sensor board II I and a two one nine so let's just get those four soldered and try remember not to cut them off because I can now snip these off on the top of the OLED board because I don't want these sticking out it's here so let's trim those whoops that one shot across the room yeah so that's fine now I just need to separate those two no which are they they're SCL and SDA so it wouldn't blow up if those were shorted but it certainly wouldn't work either so put a screwdriver between these two wires which are crossed over and I think you can just about see that they are now separated so they're not going to short out and this is quite rigid but I put a little foam packer in there later but now let's get the current sensor board on now once again I need to get all these pins out so I'm going to heat these up and give them a whack there's one two there's six of these although two of them of the V in - and V in + but I'm probably going to wire that into the terminal block there that's five of six out that's it done so there are two crossovers here our VCC and ground are crossed over SCL and SDA or crossed over so that needs to fit on there like that I've got to push that far down as I can get it and then ease apart the crossovers so that they're not shorting right let's solder these four wires and then that's all the interconnections between the current sensor the arduino pro mini and the little OLED good let's ease those wires apart right I need a 6 pin right angled header for programming the Arduino I probably should have thought of that earlier so I've had to bend the whole head up a bit but that can fit in there so just going to push that down on to the blue TAC and start soldering that on right here's my sandwich of OLED Arduino Pro Mini and the current sensor with the wires all bent and twisted to get the pins all going to the right place got my programming header here I've got a ch3 40 programmer here and I should check I suppose that this is a 5 volt Pro Mini I'm also going to need a power input so I'm going to connect that to roar there are aw and ground which is sat right next to it I'll probably use a two pin jst for that and then I can use one of my 9-volt pp3 battery holders right here's my 9-volt battery box and I've plugged it into a jst 2 pin socket so I've got to get the red to roar so it's going to have to go that way I think it's kind of to come in from the side because I can't really put on the top now because the O LEDs not really in the right place I suppose I could have moved the OLED further towards me but anyway I'll bend the pins on this jst and have it coming out the side for the moment cuz this is only a prototype unit right my power socket is soldered on to raw and ground but I don't need power for this yet so that can come out because I'm going to power it from the CH 340 USB to serial adapter because I just want to get a program in here and make sure that the OLED is running so I'll just put my whole ed program in there now right I couldn't find a USB extension lead so what I've done is I've swapped out this what is it CH 340 module with a type-a USB for this little CP to 102 module which has a standard micro be on there so that's going to be a bit easier to connect up let's hook that up and load in the OLED program right here's my OLED 128 by 32 sketch we set the OLED up as the univision hardware I squared C and this is a reset thing I think this is all detailed in the video about the 128 32 OLED that I did before now what this does is it just prints Milly's so if I upload this to or download it to the pro mini arduino then we should just simply get a Milly's count on the display a 5 times a second and yeah that's working that went via the CP to 102 into the pro mini and we have indeed got the midis count coming up on the OLED there so that's good so now what I need to do is get the program which i think is Adafruit an Adafruit example for the I na to 1/9 current sensor munge that together with the OLED code and come up with well an ammeter right this is the Adafruit I na 2 1 9 code and I don't need wire because I've already got wire in the other program I do need this include the Adafruit I also need the this is is that the constructor call yes I think that's the constructor call so I'll take those two lines right in set up for the Adafruit I don't need the serial begin because I'm not going back over sewer now I do need this one i na two one nine begins so let's copy that switch to my new program which I've called OLED i na two one nine and that will go in setup so should I put the OLED first I mean the current sensor first yes that's what I've done on the line above so let's put a return in there paste that in so we've got an I na two and nine begin and a u 8g to begin let's just tidy that up a little bit right in the loop I don't need the shunt voltage or the bus voltage run it that stuff all I need is this float current in milliamps I'll need this one current milliamps is I na to online get current milliamps and then I don't really need all this serial print stuff so looks pretty straightforward let's copy that right so that's my program complete to constructor calls ine two or nine and u8g two which is the display begin both of those objects and we have a float which is the current in milliamps it gets that from the ia to were nine and then prints it on the display in milliamps let's compile and upload that and the result is this and there is a bit of an offset on here and at first I thought well that's a massive offset but of course this isn't amps this is milliamps so we're getting sort of up to 1 milliamp of offset on this current sensor I can't remember whether the sensor has an option for removing that but it doesn't really matter at the moment right this lamp should draw about 100 milliamps a bit less because it's 100 milliamps at 12 volts I'm going to put nine volts on there and we have 91 milliamps so my little ammeter is working now I need to power this really off not the USB five volts but my 9 volt input here my raw input which goes through the regulator on the pro mini the voltage regulator which is there somewhere so let's power this now from another 9-volt battery and there it is powered by the 9-volt battery measuring the current flowing through this circuit another 9-volt battery and a bulb now that's showing 87 milliamps this should be able to read bi-directional current so I should be able to flip these two wires over and get a negative reading let's try that I'll do this on camera if I can get Kemp now camera can't see that right so let's come around there take these wires out that should go to 0 or there abouts yeah swap these over and poke them back in and okay so we'll have to do them up with anyway there there is the negative reading so - 89 milliamps with the current flowing the other way so this can read current flowing in either direction that gives you a plus or a minus indication so that works I think that's enough for this particular project now ultimately what I want this for or is to measure the current flowing into and out of lithium 18 6.50 cells which long I put in this holder initially I can have just one of these amateurs measuring the current flowing from one lithium cell to the other or back the other way depending on which one's more charged later I want to put two of these amateurs on each cell and then when charging the cells we can see the difference in current going into those cells depending on the different capacities of the cells but that can come another time for another project and I'll put the Arduino code that I've written today for this onto hast bin so that you can copy that and have a play with it if you want but at the moment that's it cheerio
Info
Channel: Julian Ilett
Views: 250,020
Rating: undefined out of 5
Keywords: 18650, Lithium Ion, INA219, 128x32 OLED, Pro mini
Id: 8ikyp4lu45M
Channel Id: undefined
Length: 14min 5sec (845 seconds)
Published: Mon Mar 20 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.