Hello, welcome to an Arduino tutorial from Robojax. In this video we are going to to see how we can use this Allegro ACS 712 current sensor that can measure AC or DC current using Arduino. You can get the code for this project by Click on the link below the video in the description that will take you to robojax.com/learn/arduino Let's start with this. My name is Ahamd Shamshiri and I am presenting this tutorial from Canada. using this Allegro ACS712 chip can measure AC or DC current. and these are the most important important features Hardware explained it is the module and it is a chip you can buy it as an independent chip or maybe bite of this module that if sold on eBay. And it only has three pins it works with 5 volts. You can connect the 5 volts here and then it just has a output depending on the amount of current on this side if you look here the current goes through and there is a crying effect sensor identifies the current and convert it to voltage proportionally you get voltage from 66 mV per ampere to 185 millivolts per ampere for each amperes that go through this, you get a voltage here and you can even convert that voltage to a value you can read it that way, it can be used from a current sensor.
This module is presented in 5 10 and 30 amps. it is a 30 amp per version we are going to use. the value of this module is 13 mm and the length is 31.2 mm the height or depth is determined by this connection with the pin on the other side it will be 13.2 millimeters. Datasheet viewed (sorry for the wrong title) let's look at the datasheet it is a low resistance and this means that if 2.1 kilos of volts or 2100 Vols goes through this to isolate your circuit from that voltage you are measuring. The turnout time that it can respond is 5 microseconds and the total output error is 1.5% at 25 degrees it is very important to know. 1.2 mΩ is internal conductor conductor resistance current moves here and the resistance here is 1.2 milliohm pin 1 and 2 is one pin of the connection and 3 & 4 is the other pin of the connection and it's the chip and it's a pin 1 on their side, so pin 1 & 2 is the one terminal and 3 & 4 is the other terminal.
So that it would be connected and pass through this. As you can see it so I let it be set accordingly and then it is a VCC to which 5 volts will be connected this pin and there is another filter between pin 6 and ground with 1 nF so they also set it capacitor here and for the VCC 5 volts there is also zero point 1 micro farad capacitor, so it's a chip, so all capacitors are the two capacitors here and then because there is also an LED a power LED when you connect it, it will turn on so that they place a resistance to it and that is even if there is nothing else about this module. this module is offered in 5 so it is 5 amps, 20 amps or 30 amperes and the module is number is the same except the last part which is 05 B and 20A and there are 30 and here is the rating I mentioned plus minus 5 plus minus 20 which means it has no polarity in any way you can connect it because it can measure AC or DC and here are the sensitivities has 185 millivolts per amp at 5 volts so it is more sensitive as I currently rise, we become one hundred millivolts per ampere and 30A amperes it is 66 mV per ampere and here is the formula on how to calculate the current.
and some features and I have collected all this information and based on those I wrote the code like that We can measure the current and display it to us you need further details on this provide the link for this and you can Wiring explained download it and read it. And here's the wiring. gives the positive and negative positive input (red wire) in the current sensor and the black wire consists of these two pulls to the load. because I wanted to test that I sat with 30 amps thick wire I am still not thick enough for 30A must be at least 12 meters of wire, but it's 14 meters I set it and still is in series with your cargo. Here is an explanation of how to measure the current.
Let's say it is a battery or power supply and it is the load for example in DC it is a positive is connected to the charge and from this side it comes to the negative and the circuit is complete. to measure the current you can put ammeter on one side or on this side only one of the wire and then set it so that the current through the charger and then go through the ammeter and parameter will thus measure demand for the ammeter and series and then we place this module in series and a set ammeter it is our meter so the stream goes here and goes in. we can put it on top the same way.
So it is how to put it in a series with the load to measure the current. here we have VCC will be connected to five volts and then I ground this side connected the VCC which is a red five volts and then the ground the brown one is attached to the ground here and then the middle one is outside connected to analog zero (A0) Code Explained let me now explain the code I have written. we defined the VIN as analog zero A0 I will connect it to analog zero the V-out or the pin-out of the module will be switched on here voltage that you connect for power supply is 5 volts in case it fluctuates enter it here. and then we have the model the model is the determination of the characteristic as I mentioned, we have 5 amps 20 amps version and 20 amps and each has different sensitivity, so this is the array and we use the model and I explained it as a comment here if you use 5 almost version 0 just enter 0 here and if you have 20 and third one and if you use 30 amps use 2 – because the voltage becomes from the data sheet is that we the quiet output voltage QOV as I called it and 0.5 multiply by VCC that you entered and it is a floating voltage variable that is used internally and then within the setup we do nothing but plant this text, initialize the series monitor with 9600 baud if you want to see the series monitor tools -> monitor because it is now not linked show error.
So now it's paired monitor and make sure you set it accordingly, because if you do not correct it, you will not be able to read the text. thereafter in the loop () there are some calculations, so this is a formula where we read the A0 pen and then because the input range is 5 volts and compare it to 1023, 1024 steps we do share it and multiply by the tension you get, so we are get the raw voltage and then the raw voltage you subtract quiet output voltage. This is the quiet output voltage that we have calculated here and there plus offset some error variation so that you can experiment with your own module and change it or maybe just set it to zero until you get the right value and then it is current. The stream is calculated voltage divided by sensitivity of the model the model that you entered, it's array, so you do not change this array you change nothing further point and then we say absolute value of the current, because if it is positive or negative depending on the polarity or in terms of AC you see if the current is greater than the current limit forget to mention here I have the current limit because if you work let's say with 30 amps or 10 amps sometimes 0.5A or 1A be neglected, or it would not be yours interest.
Value let's say above one amperes of 2 or 3 or 5 whatever so you put the one here and we are check if the absolute value of the current if the current is greater than let's say you set it for one amp if it's greater than one amp then we get the power but already in the meantime I also try to push the voltage resulting from this is subtracted from the supply voltage it's the voltage you do not need it is for reference purposes only but it is the most important one you get a stream and we set it to two decimal places and on the screen and we plan the A at the end. if there is if it is not true, then we just say no current and we wait five hundred milliseconds and so on Demonstration here is now the demonstration of this the power supply to this device is now three volts and around the power I try to use a lower voltage but the current is our concern, so I am I will show you the three 3.2 volts and the current is now zero, let me just change here and make it 5 amperes and then there is a range when I turn it on monitor for 4.98 and this is the current which is now displayed by this device.
Let me change it to 10A now ampere. Let's go to 6 now it's 6 so that's the amount we can compensate for because here is a 6 I only increase it by hand is 7, 6.85, so you can see that the the amount of compensation is it 85 it is 150 billion amperes difference because within 30 amperes it's very minimal, but we can still fix it. and where we can fix it is this and here we can add a little tension terms to fix it so experiment with different value got 0.12, so it's about 7 amps we read now, let me just increase it to see 8 if we get it right very good eight and then note it here a current and this is what the series monitor shows it is the current from those of the sensors.
Let me now up to nine, so now it's to 40 billion amps difference is now 10 amps it is very good 11 12 13 14 15 so it's 15 amps 14.8 1 now we still get a deviation of 43 watts I increase the voltage the voltage should not affect it but at five volts let me now increase it to 16A. At 16 we are now getting 300 less 17 18 19 20 it's 20 amps, so about 400 billion amps and let me go for 23 now now it's at 23 amps. now it's this is a big difference now that we read 21 let me see now the device is very hot because all the power is gone through this.
And it's too hot this is not made for 30 amps. the module the chip is good for the purpose, but the the way they designed it can not handle it it was extremely hot I closed it off now let the module cool down and then we will continue it from 23, and we will do it too see if it can handle 30 amps. we can set the amount of current we will not do look at less than 1 ampere 1.10 will be ignored, now show it no stream and i will ignore all things small values the device has cooled the module let me just turn it on at which 23 amps now it's very close to 23, still 450 or 500 milli amperes so I now go for 24 25 26 27 28 29 so 30 amperes we read almost, UFF very hot, I just touched it extremely hot o device gets hot it reads wrong value of almost 700mA difference. tell me you're fine as soon as it gets cooler correction goes and it goes to 11 so now it's 11 enter the device is still a bit hot but cool you see if I hold it in my hand, temperature drops and as you can see it corrects itself, which means that this module needs to be cooled or maybe better design for the track current therefore it can not be trusted above 20A thank you for watching introduction to Allegro ACS712 sign in so you can get updates from me coming videos and also if you have a question or comment please add to the description below I try to answer and answer Ahmad Shamshiri from Canada thanks you for sharpening the video and clicking 'subscribe'.
This is the least hat you can do for me. Thank you. you.