ACS712 Current Sensor with Arduino - Measure AC and DC up to 30 amps
HTML-код
- Опубликовано: 27 авг 2024
- Using the ACS712 current sensor with Arduino, we can measure AC and DC current up to 30 amps. I used the 5 amp version here and tried to improve the measurement noise with a filter capacitor to get better readings.
This was using the 10 bit ADC on Uno. I will compare results when I receive a higher resolution external ADC.
Sketch:
github.com/Gad...
Library (and schematic) used:
github.com/rko...
ACS712 Datasheet:
www.sparkfun.c...
Support the channel by using these affiliate links to check out Banggood's sale on Tools & Electronics this month (2021 4.07 - 4.18) :
Banggood hot brand tools bit.ly/3dSyO2l
Electronic Brand Sale bit.ly/2PHpeau
Creality 7th Anniversary Sale bit.ly/3d0fLUi
Support me on Patreon: / gadgetreboot
Thank you for your research. I just bought some of these boards and this is going to really me out.
I have also played with one of these hall current sensors, and been similarly disappointed with the precision when measuring low currents. There is always making a shunt with a thick piece of Nichrome Wire, then using an opamp to boost the voltage.
When I get a chance I am going to take another look at it And see if there’s a way to improve it with a better ADC precision. I seem to have run out of Bench Work space again so that might get in the way. I’m already working on an electronic DC load experiment that I don’t want to have to tear back down to make room.
@@GadgetReboot 3 years ago, to your comment about bench space, I could have said the same thing. No more room!
Now, it's almost 2023 and... sigh.... EVEN LESS ROOM! ROFL
very clear explaination
I don't know if it can do the equation, but maybe a 1 in 1 out averaging table might be better. That's how I did my digital manometer on my flowbench, which jitters a lot on the physical side.
Nice catch on C2 capacitor.
Question: Did you remove the SMD cap and solder in a 47nF cap? Or did you just solder the 47nF cap right over the SMD cap that is there?
I find so much stuff with Arduino to not be super stable when it comes to measuring anything.
Pretty much any sensor I use, I have to write an "averaging" routine to stabilize it.
I'm only now getting into ESP32s, so I wonder if they are any more stable when it comes to projects like this.
hello have you tried it?
if you have
can you tell me whether the additional capacitor is only installed without having to remove the default capacitor or the default capacitor must be removed
Useful video 👍
Thank you very Much It works good :) ..... The best code :)
Thanks allot made you help to accelerate my project a bit thanks! :-)
the readings are jumping, because you are using it with only USB, whose voltage are know to jump around 4.8>5 volts and cause noise, there fore your voltage formula is always wrong,
SOLUTION: power it with extrnal supply, that way regulator will output nice and smooth DC, meassure it and than put that in formula, its often not accurate 5 but 4.9ish max time.
I'm lost with your use of pins 2 and 3. How are you connecting these to switch the modes. Or are you connecting a jumper wire to change the levels? I missed in the video where you explained how you were doing this.
looking in the Arduino sketch pin 2 changes between reading DC or AC and pin 3 is used to calibrate the sensor depending if the inputs are set high or low so I’m just using a jumper wire between VCC and ground when I want to change a mode. each time the sketch goes through the main loop it will read the inputs and decide if it’s calibrating or reading AC or reading DC current.
Are you sure the resolution of the ADC is sufficient? It looks like your noise could be attributed to the lower 2 bits being inprecise. (Did not do the math though)
It’s possible more resolution would make it even better, I believe it’s 0.185 mV/mA on the sensor so if every step of this ADC is about 4.88 mV then that could be improved upon, but I wanted to see what I could achieve with a cheap Arduino. Adding the filter capacitor seemed to help. I can’t remember if I ordered a 12 bit ADC to play with. Maybe I will revisit.
An air/fuel ratio sensor on an automobile has a current output. Zero current is ideal air to fuel mixture. A positive current is rich and lean mixture is negative current. Would this sensor family measure plus/minus currents of 50 milliamps considering the frequency of swings is very slow.
my experience with this family has been that for lower currents, I don’t find it very precise. I have much better results with the INA219. ruclips.net/video/FXQoZbvM3Kw/видео.html
can the current sensor handle a large amount of current? what will happen to the current sensor if there will be an overcurrent (example: short circuit)? And how will it affect the MCU?
This sensor is available in three different options with a maximum current measurement of 5, 20, or 30 A.
The load current path is electrically isolated from the rest of the chip similar to an optocoupler so the MCU should be safe within reason.
The datasheet says it can tolerate 100 A of overcurrent for up to 100 ms duration. I don’t see any information about what happens for lower over current conditions but I would make sure there’s external overcurrent protection or fusing to protect against that.
Hello, your code works great! But what if I want to use multiple ACS712 current sensor? How can I integrate those into the code?
Hello. Can you help me with this error of 'ACS712_05B' not being declared in the scope"? I keep seeing this error even if I already imported the .zip library files. Hoping for your response. Thank you
I know that your comment is over 6 months old, but did you figure out the problem?
I ran into something similar just last week. I'm working on a project and following a video so that I learn it quickly. It was for ESP32 and the Round display GC9A01.
I got a similar "not declared" error message.
It turns out, in this case anyway, that it was because I was using NEW libraries. Not the older ones in the older video.
I just removed the newer libs and installed the same ver as the video and problem solved.
Of course, once I get the cute round display under my belt, I'll use new libraries that possibly have better funtionality.
Thanks for this! Do you have pictures of the transformer setup? Did you have to strip the wires?
I don't have pictures and can't remember now that it's almost been 2 years but I think the transformer belonged to something I still needed so I would have either plugged it into a jack and clipped onto the leads or wrapped wire around the barrel and stuffed wire in the end and taped it to hold. I remember everything was falling off the edge of the table and I couldn't get everything in the shot.
@@GadgetReboot thanks!
Sir i keep having the error 'ACS712_30A' was not declared in this scope, I manually installed a zip library of acs712 and used #include . what could be the problem? thanks in advance
you are not using the correct library. Download it from the link he provided.
@@angry_moose94 I have the same problem as him. Can you try this on your own and see if there is anything wrong with the library? Your help is highly appreciated. I cannot solve this problem as well.
can you tell me the installation circuit on Arduino and what type of capacitor is used
The circuit used is the same from the link in the description for the library as well as what is showing on screen in the video. The capacitor is a 470 nF polyester (also known as trademark name Mylar) type.
can you suggest any good current sensor for precise measurement
I can't think of one off hand but generally what I find is I would need a different sensor to handle different ranges, so if one can measure up to 5 amps within just a few volts of output signal, I won't expect it to be able to get precision results on lower currents. I am thinking about looking into a product like uCurrent Gold, or the Current Ranger, which will also give a voltage output signal, but can do various input current ranges accurately.
Bought one of these and the output goes lower than the 2.5v idle when current is detected? (Mine does). Thought it would have added to the output -- guess not. Confirm anyone?
I believe it goes higher or lower than the centerpoint based on if the current direction is positive or negative so you could try reversing the wires on the sensor
@@GadgetReboot Yeah ! Discovered that after posting. The right hand rule, right? -- thanks they should include documentation with these.
these hall effect sensors are so super noisy. try placing them inside an iron can for magnetic shielding, and see what happens.
I know that your comment is over 3 years old, but that's a good idea. It also may help to put ferrite cores on the input and output wires. I wonder too if twisting the "out" wire with the GND wire might help.
I was working with those nRF2401L radios on Arduino Nano Every boards.
They are so difficult to work with (the cheap ones I guess) and are so noisy that it was almost impossible to maintain a solid signal between them.
I had them on the lab bench and in running simple TX/RX tests, having it notify a little Nextion display of drops, when I just moved my hand near their wires, they'd go nuts!
So I ended up creating twisted wires with the wires that I had, then wrapping each set in tinfoil, which I grounded. I added little ferrite cores at each end, as close as possible to the PCB of the radio and as close to the PCB of the Arduino. WHAT A DIFFERENCE! The TX/RX was solid after that.
However, I've dropped that project for now, because those danged nRF24 libraries take up so much memory, that there's not enough space for the code I need to write. Sure, basic code is fine, but not much more.
So now, I'm learning ESP32 with their WiFi radios. WOW! Instantly solid signals! Zero drops on the same Lab bench.
@@BlondieSL great job. 👍 keep it up.
Why do I get negative readings on my Arduino Nano? I'm getting values like -0.053
What happens if you reverse the wires to the sensor? It measures current flow in both directions and has a polarity.
@@GadgetReboot I am getting alternating positive and negative values. I'm measuring AC by the way. It's the same when I reverse the polarity. I'm using the USB port as power for my Nano.
It’s strange to get negative readings on ac, trying to think of any little things, was a calibration performed while there is no current flowing? The library could get negative numbers by trying to subtract the wrong offset maybe.
And is it a sinusoidal AC with the correct frequency specified for the AC measurement?
Is the current reading looking accurate otherwise, just the polarity being weird? And is the actual current that low, around 50 mA, and which version of the sensor are you using? I remember it wasn’t really performing great for me at low current, sometimes my error was even 50 mA, and if using a sensor greater than 5 A, it may be even more jumpy because it has less room to represent the measured current in the output so any noise would more greatly distort the reading.
Same, i also get negative readings on my Arduino Uno. The values kinda -0,47 ish
Hey sir how to calibrate the sensor?
The general method I have seen for this sensor is to take baseline readings with no current through the sensor and if there is an offset, consider that offset as zero in software and then use the data sheet equations to calculate current while factoring in the offset zero reading.
@@GadgetReboot bro how to save the calibrated settings when i restart the program? when i restart it the values are again uncalibrated, please help me if you can