Different Ways for Measuring Current With Arduino

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all these modules are used to measure current with the Arduino and today we'll go over all of them and check an example of each I will share with you the connections and the code for each example so if you want to use the same module just download the files from my website depending on the project I sometimes use one or another option and that's why I want to show you each so let's get started [Music] thank you [Music] hey guys PCB way is sponsoring this video and let me just tell about their services for example look how awesome their prototyping pcbs are and you can get this for only five dollars they are so professional and they will make your project work a lot better and to order such pcbs you only need a few minutes on their website where you can select any configuration that you want for your boards along with that you can also order the snd stencil for soldering the components using solder based and you can also use their services for flexible pcbs and create some unique projects and if you want to make your project start to finish you can get the pcbs assembled together with the mode injected part or maybe 3D printed metal parts or other CNC Services all with PCB way what's up my friends welcome back the first option to measure the current is directly use the Arduino to do that using one of its adcs on pins a0 to A5 so let's say that our testing load will be this DC motor by Ohm's law the current is voltage divided by resistance so let's add a resistance to our load and in order to not dissipate too much power let's use a low value resistor such as a 0.5 ohms one so output of these resistors in parallel to do that the circuit that we need to make is something like this with the DC motor in series with the resistor so the current will pass through the load and our resistor and all we have to do is to measure the voltage drop on this resistor and since the current is voltage divided by the resistance value and we know that the value is of 0.5 ohms getting the current is very easy we measure the voltage drop with the Arduino adcs connected on pin a0 and the code is also very simple we measure the voltage drop using the analog read and divide it by 0.5 ohms and we get the current value we multiply that by 1000 in order to get milliamps instead of amps so I upload this code and let's give it a test we have the loading series with the resistor and we Supply let's say 12 volts to the circuit and to compare the results I also add a multimeter in series as you can see the multimeter shows a current value of almost 300 milliamps when I run the monitor of the Arduino we get this value so the measurement is pretty decent but the measurement Precision is based on the Arduino ADC Precision which is only of 10 bits which is not that much so to get a way higher Precision we could use the same setup but with an external ADC such as the ads-1115 this one has a 16 bit resolution which is a lot higher than the Arduino internal adcs so we connect this module like this to the Arduino on pins A4 and A5 for SDA and scl since this module is using the icecrest communication and in the code to use this module we need to install this Library so download it from below and install it to your Arduino IDE we first start the X currency communication with the module and using this function we can read the voltage on the resistor and then again we divided by 0.5 ohms and we get the current value but this time with a lot more precision so I run this code and again I get a decent current value pretty much the same as my commercial multimeter and this time we have a lot more precision and look when I increase the load both values are increasing the same but you see 0.5 ohms is quite a lot for high current values because imagine that you measure 5 amps for example and that equals to A voltage drop of 2.5 volts over the 0.5 ohms resistor and that also equals the wasted power of 12.5 watts and we don't want that that's why usually the shunt resistors are very small around 0.1 ohms or even lower this for example is a hypo resistor that I've used for my power meter tutorial and this is of only 0.01 ohms which is a very low value and this one here is another shunt resistor that I've used for my full sign inverter it's just a piece of metal with a known resistance of only 10 Milli ohms so using lower value shunt resistors equals to a different problem because now the voltage drop will also be smaller and the Arduino adcs might not be able to reach such a low value and that's why it's a great idea to use the 16-bit ADC in order to measure voltage values of only a few millivolts with decent precision and that was the second option for measuring current with the Arduino but now if you don't want to make your own circuit with a shunt resistor use external adcs and so on you can use a module like this one that already has everything that you need it has a resistor of 0.1 ohms and this IC and this is the in8219 power monitor and this IC already has inside again amplifier and an ADC it would measure the current at the load the supply voltage and the voltage at the load so with these values we could also get the power it could measure up to 26 volts and 3.2 amps of current and with an internal ADC of 12 bits the resolution is of 0.8 milliamps to use it we have to connect it like this to the load in series respecting the positive polarity then you go to the Arduino IDE and open the library manager now we search for the Ina 219 and we install this library from Adafruit now you go to examples and we open the get current code and as you can see we have these four functions to obtain the shunt voltage the bus voltage the current and the power and we also calculate the load voltage so upload this code to the Arduino and we make another test and as you can see I run the Monitor and we get all the values this is such a simple way of measuring current but this is limited to values below 3.2 amps and you could use multiple modules like this one at the same time and to change the i3c address we can use these pads here and that was the third option to measure current now this module has a big brother the Ina 3221 this one is kind of the same but it has three channels basically you can read the current of three channels at the same time for example the current of a brushless motor in my case I bought this module because I want to make some tests for the FOC driver this driver PCB is controlling a triple phase motor and this IC could be great for measuring the current of each phase and the connections will be something like this and for the code just go to the library manager and install the Ina 3221 Library then you go to examples and open this code and it's quite of the same we use the get current function or the get voltage function to measure the values for channel 1 2 and 3. and that's it you have the schematic and the code on electrodes.com okay so the next option is probably the easiest one we use a whole effect sensor such as the ACs 712 I use this module all the time but it also has some downsides the ACs 712 has three models one for 5 amps 20 amps and 30 amps and depending on that value the resolution is different for example the 5 amps module will output 185 millivolts for each amp of current so all we have to do is to measure that output with the Arduino ADC so we connect it like this in series with the load and the output is connected to the Arduino ADC on a0 and the code once again is very simple we measure the voltage from the module and also subtract 2.5 volts because this IC could measure both positive and negative values and the middle point of 2.5 volts is for 0 amps and then we divide it by the resolution which in this case is 185 milliamps and that's it I run the code and give it a test as you can see I run the Monitor and we get the current value the same as on my multimeter and this module works with high voltage as well for example 230 volts from the home Outlet because this one is based on hall effect so it's insulated from the Arduino so one thing to have in mind this module is affected by the magnetic fields because it's based on this whole effect for example if I place a magnet on top the current readings are different so it's also affected by the magnetic field of the motor so maybe this is not a good option for highly magnetic projects for example the FOC project that uses magnets and brushes motors with also powerful magnets but the IC is very easy to use that's why I use it all the time for my pcbs for example my Arduino based multimeter is using this chip to measure the current and I've also used it for my mppt controller and a lot of other projects now the module is a little bit big but you could also use directly the IC and look how small it is and you don't need a shunt resistor or anything else just the whole effect I see and a small filtering capacitor of one Nano farad the resolution is decent but again it will get better by using an external ADC of 16 bits instead of using the default Arduino ADC but this one could measure up to only 30 amps what if you want more than that well that's why we have the ACs 758 this would measure up to 200 amps for example this module is for 50 amps but we also have the 100 amps and 200 amps and the b stands for bi-directional so it could measure both positive and negative values and the rest is pretty much the same this will be the connection to the load and the Arduino and this will be the code we Define once again the resolution which for the 50 amps module is 40 and these other values are for the rest of the modules in case that you want to use a different one then we get the raw voltage and calculate the current and that's it so we run this code once again and we can see the current value on the monitor but the value is a little bit off because this is for 50 amps but I only use 300 milliamps but it works now for the 200 amps model the only part that I don't like are the connectors because they're a little bit too small to handle such a high current value so if you want to make your own PCB consider making these pads a little bit bigger and the last method that I want to show you for measuring current is the non-invasive one and this option doesn't have to be connected in series with the circuit we can place this on top of the wire that we want to measure and I've made a full tutorial on a non-invasive probe and how to make a homemade one using the Arduino basically inside we have a thread core and a coil the passing AC current through the measured wire is inducing current into that coil we measure the voltage drop and by knowing the ratio we can get the current value for example this one is giving one volt for each 15 amps of current and if you search on AliExpress for example you can find other options for sizes and shapes and you could even make a homemade one using a thread core and some copper wire or you could even use a fried core and a whole sensor as I've used for my homemade non-invasive probe for the oscilloscope but if you don't use the whole sensor this only works for AC current so please check my previous tutorial on the homemade current clamp and learn how to use this with the Arduino we have a lot of other options for measuring current but pretty much all the options are based on the shunt resistor method the whole effect method or the non-invasive Transformer and these are the three main methods to measure current and the rest are only versions of amplifications adc's readings the gain the size the sound value Etc you have each example and more on electrons.com so check the links below I hope that you have learned something new and if so consider giving me a like or comment below thanks again and see you later guys hey guys so that was another project and I hope that you like it as you all know to buy all these modules a huge help from you is from patreon so if you want to support me you can support me there but also just commenting below giving me a like or sharing this video it will also support my channel so thank you very much to all my patrons and to you guys
Info
Channel: Electronoobs
Views: 71,788
Rating: undefined out of 5
Keywords: current, modules, measure, Arduino, INA219, INA3221, ACS712, ACS758, induction, non invasive, ADS1115, shunt, amplifier, how to measure current
Id: Q2OjWrSSvYU
Channel Id: undefined
Length: 13min 31sec (811 seconds)
Published: Sun Apr 30 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.