I really like that you explain in detail the reasons for not doing things a certain way, rather then just telling us how to do things correctly the first time. I find it helps me understand things a lot better when I know the 'why not' as well as the 'how to'. Thank you for sharing your knowledge in such a high quality manner!
The INA226 work on the high side or on the low side. The input voltage ist higer than the INA219. But with 0.1 R it only can take 1 Amp. A lower resistor for higher Amps is needed. 0.02R is about 4 Amps.
An enormous THANK YOU to all TH-cam content creators for providing all of us with additional content during this very trying time! I can only speak for myself when I say you are helping me retain what little sanity I have left having been sheltered in place for the last 2 1/2 weeks!!
I recommend you take a look at the INA260. It’s I2C and works on 3V or 5V logic. It can measure up to +36VDC at 15A continuous on either high or low side using a 2 mΩ sensing resistor.
@@AndreasSpiess true, it's not cheap, but come on as a Swiss you are used to that. 😜 But jokes aside, it is very precise and has a very low resistor value. So the voltage drop is minimal and the measurement range is huge.
I work as a hardware design engineer and tbh high side current sensing is almost always preferred on our circuits for various reasons. We use opamps from TI specifically for this.
The probkem has been, typically, that you need to measure voltages that are higher than the V+ in the DUT, in case where you are measuring your 'own' current consumption, which is a probkem for most amplifiers... of course, low-side measurements make the V- a bit 'floating', but the voltages being measured are referenced to 'ground', making noise suppression easier... high-side measurements also affect the apparent V+ of the DUT. Lots of considerations to make, almost all of them introduce some compromise in the DUT performance/stability, or bandwidth, or sensitivity, or dynamic range, or... I spent a few years doing this stuff...
you videos are such a wonderful resource on the internet. thank you Andreas. Love your country - spent many days leading boy scouts around the country from Kandersteg.
on esp32, you put adc reference to 1.1v. Then use a diode between adc input and ground, and 50k resistor between 3.3v and adc input. This will set the diode voltage drop (cca 0.5v) as your referent zero. Then you can use a shunt on battery negative side without the loss of resolution. With some noise cancelation and polynomial calibration coding, you get a pretty good +/- current meter. I'm using that on a solar system with 60A both ways ;)
I was researching for few months on measuring mains current and voltage. Finally your video. I have seen almost all video. But no video explains as you did. I needed this video a month ago. So that would reduce lot of my hard work.
Nice video as usual. I think that I have tried the INA219 Before and it measures the current in ( Bidirectional + and - ) without no problems. You could connect it to a battery and ( sink , source ) current.
Omar Mekkawy I just checked the data sheet and it does have a sign bit. Also I'm pretty sure I hooked my leads up backward when my mAh tester project the first time and I did get negative current readings when the supply read lower than the load.
Very timely. I am a novice using a small 5v solar panel to power an Arduino and LoRa unit. I think the current drops too low when shady, so it will useful to implement one of these units to track current and only try to send comms when enough current is available. Thanks!
This is good timing...I just got my ACS712 analog sensors in and was testing them and they did not show 2.5V at zero current. Reading up on this, I found that they need a precise 5V vcc to guarantee 2.5v at zero. I stuck a 7805 to deliver precise 5V to it and voila, it worked precisely as expected. You should mention that. The INA226 sensors dont seem as sensitive, they must have a 5V zener reference for their ADC or something like that.
As always a very nice Video and i only have to disagree at a single Topic. At 5:50 you say you have to suply a +- Supply-Voltage to the Opamp. Because all Voltages at the Opamp in the inverting configuration in this Messurment-Circuit are at Zero ore in the positive Range it is sufficient to use only a posetive Supply when You use an Rail-to Rail Opamp. ( The Inputs have to work only from the Negative Rail, without Output Phase−Reversal, the Output would have to work from the negative Rail for the Minimum Current You can messure) You might use even a cheap opamp like the LMV321. Thank You very much for this informative Video.
Andreas Spiess No, you can connect the ground (negative power supply) of the op amp to the Arduino ground. You connect the (+) input of the op amp and the op amp negative power supply to the Arduino ground. You connect the op amp positive power supply to the high side power. You connect, say, a 10K ohm resistor between the power source low side and the op amp (-) input. You connect the same value (or larger, to scale up the output) resistor from the (-) input to the op amp output. This will invert the negative voltage across the 10 ohm resistor to a positive voltage at the op amp output. The op amp drives its output to make the voltages at its (-) and (+) inputs equal: both end up at zero volts (Arduino ground). Thus all the op amp input and output voltages are zero or positive - quite legal! Notes: I have built this circuit and used it in past projects to sense negative voltages with only a positive power supply for the op amp. It works. Carefully read prospective op amp data sheets to select one where the common mode input range includes zero or slightly negative input voltages. This will be true for most op amps that have “Rail-to-Rail” inputs. You also want an op amp with an output range that includes zero volts. This will be true for op amps with “Rail-to-Rail” outputs. Select an op amp that has clamp diodes on its inputs, thus guaranteeing the (-) input cannot go very far negative. The 10K ohm input resistor will limit any transient input currents to the op amp (-) input and its clamp diodes before the op amp output settles.
@@w6wdh, Andreas Spiess and Juergen Schimmer : The Rail-to-Rail feature is not even mandatory as (+) input can be biased to say 1V and the program will cancel that out with a simple I=aX+b (b being negative here). Or did I miss something ?
your channel is the first place to start searching whenever I need something practical and advanced ! ,, thank youuuuuuu man I wish I can meet you someday.
I think you'll find low-side shunt based monitoring fairly common actually! 20:20 INA210 and LMP8603 for starters. If using external shunt the safety benefits are great enough to warrant the loss of short-circuit detection the high-side offers (which is another plus for high-side not mentioned).
@@AndreasSpiess One context for using a low-side shunt is when you have panel mounted shunts a distance away from the monitor. It's safer to then have the shunt sensing leads routed to the monitor because they're nearer ground potential. Not sure if it's a matter of personal taste :)
Hi, I got success to measure current by the hall sensor of a smartphone, I found an app (gauss meter) which has calibration option, and by using this app ,I measured current contactlessly. The sensor of a smartphone has 16bit resolution, so it is very precise
Well presented. I've been using ACS712 sensors in a solar test bed monitoring project for several years now. Lower precision works ok over time, and a single sensor measures battery charge and discharge.
@@AndreasSpiess You're very welcome... I didn't explain... For beginners... If the non-inverting (+) input of the op amp is tied to 0V, the amplifier will attempt to keep the inverting input at 0V too. When a negative voltage (with respect to 0V) is applied to the input resistor, the output of the op amp will go positive enough for the current through the feedback resistor to counter the input current and hence pull the inverting input pin back up to 0V.
Thanks for the nice video ! However I have a few points about INA219 : - INA219 is bidirectional, it is in the title of the datasheet - It can do the power calculation itself, it has register to read it - It can be low side, but you loose voltage and power measurement (prefer INA220 to do this) - Two versions are available, A with 1% accuracy and B with 0.5% accuracy. By-ye :)
You are right with the bi-directional. I did not know it and di not read the ".." manual. But I do not like to cut ground wires. That is probably why I did not even look at this possibility.
@@AndreasSpiess I used to monitor charge and discharge so I remembered positive and negative currents. I prefer the High side measurement too. Thanks for the reply ;)
Yes, it's good practice to show mains voltage a lot of respect! Industry requirement is, at least, 5mm space between mains and low voltage on a PCB which is accomplished with the SOIC you showed. It is also very common practice to actually route a slot in the PCB to generate an air gap isolation which, quite frankly, I think is better. A little "aide memoir" for Ohms law is just to remember V/IR (yes, V for Voltage), cover the variable you want and what remains is the formula for it! Simples! All this time I thought the pointer arm was attached to your your trusty assistant! 😁
For alternative current, there is also clamps without hall effect, only transformer-like, for example SCT-013-000. And they can be clipsed around existing wire, perfect for measuring AC without even disconnecting anything. One may take precautions to over and under voltage if used with some arduino analog input. Combined with a small voltage transformer it can allow to measure power.
Excellent explanation. I just proved your point on destroying an INA169. I put +12v across a 50 ohm RF dummy load from a bench supply with the INA in series. I took the +5v for the INA169 from the 5v pin on a Nano. The Nano was powered from USB. Worked for a while, until I lifted the load. Poof! Unfortunately when it fails it shorts the shunt to ground. Make sure your power supply is current limited.
In the both first cases if the load circuit is different from the measuring circuit i.e. you power the load and the measuring system(here arduino)with two seperate inputs ,you can use the potential difference between the small resistor to detect the current in the load circuit.
I use the LTC4151 as a current sensor for my home off-grid solar system. I use two per shunt to give me bi-directional current sensing. Not a cheap chip but great for my setup.
Thanks Andreas, I want to measure the current used by a small brushless motor inside a tank to not only sense when it is running but also for diagnostics in case it stalls. This video just at the right time!
714 comments and it feels like you have read all them based on the impression of how many you have replied to. I have just tried to do a search on these particular comments for "coulomb" but strg + f does not work so far cause the page is not loaded into the memory I guess. But I have looked into those comments you had replied to therefore I can at least judge a bit about how much effort must have put into reading the comment and replying to all those that needed help and you had answers for. Just a big "chapeau !" or "Hut ab !" from the Andreas on this keyboard to the other Andreas with the hat on his head. I guess this coulomb meter / counter would be a great project if it could work with a pico or esp and a display just to show the current state of a battery in a mobile home / Wohnmobil / RV thanks
You can measure incredibly small currents with the hall sensors by putting an inductor with more turns near it. There are also some self-oscillating inductor types that measure current through a transformer.
@@AndreasSpiess wer viel macht , macht viele Fehler, wer wenig macht, mache wenig Fehler, wer nichts macht, macht keine Fehler und wer keine Fehler macht wird befördert.
I used a current transformer to measure AC current drawn by a refrigeration compressor. It was quick and sensitive enough to detect the inrush surge upon start. (This led to a hurried code patch to ignore the excess current for a number of mains cycles after compressor start.) Accuracy was good enough for the application. Better than 50mA according to an uncalibrated AC meter. A few code tricks to get the "RMS" current from the sine wave... detecting zero-cross points for mains frequency and therefore when to measure the "RMS" current.
To measure the current through the ground line without requiring a negative rail on the op-amp, you could add a bias current by attaching a resistor to a stable positive. The bigger problem I have run into with measuring current on the ground side is that there can be more than one ground connection (such as when you connect the USB and a separate supply. Also, circuits are much more sensitive to voltage changes on the ground than they are to voltage changes on the supply input. Note: Current sources other than from the supply can still affect an accurate current measurement when measuring on the high side of the supply as even I/O lines can provide a current path into the processor. Hopefully these are very small compared to the battery current. At work I have one device I have to test that consumes 10uA in one mode and up to 10A in another. This requires care.
You are right if you conect the opamp to the battery ground. And concerning having two different grounds, your argument is why I do not like to cut the ground wire.
It would be great if you can make a short follow up on the INA3221 triple channel. Once it had arrived and you have something significant to say about it... What strikes me is that it is in a qfp package so transplanting it to a custom board perhaps is more hassle than the tsop ina219 single channed. So then what to do to replace those shunts on it eh? Does it matter that to make a jumper wires off the breakout board. It may be too high resistance to interfere with the measurement? Or am i mistaken, that it does not affect enough being a higher impedance voltage measurement?
Of course the connectors are important. But because Vin pins are connected very close to the shunt resistor, the board connectors have no influence on the accuracy. But on the burden voltage, of course. The INA3221 has quite "beefy pads.
The isolation of the ACS712 is fine. It's just that a stupid module design often makes it moot, because whoever laid out the board thought it was a good idea to flood fill everything with a ground plane. I generally like the ACS712 (or hall effect sensors in general), because you don't have ground/reference issues. I don't have a need for any other current measuring modules (for low currents I just build my own with an opamp). Be careful with the modules you get from ebay/aliexpress. I got some with ACS712s that were wildly out of spec on their output noise (more than 5x higher than claimed in the datasheet), while others from another order (from the same seller) were fine. That was a few years ago though. Wouldn't be the first time that the chinese sell factory rejects. That goes for any chip.
I also like the hall concept. But with a small chip like that it is really not easy to produce the needed distances on the PCB. Most of the power supplies also have a milled slot between mains and low voltage. And I also have a responsibility for unexprerienced viewers ;-) Maybe I create once a video about AC current measuring. Thanks for the "noise" tip.
Hi, great video. Right now I am working on a Design, that needs current measurement. I choose the TLI4970, which can do up to 50A bidirectionally, at very low heat losses. It outputs a clean 16-bit digital signal.
Excellent video. I also appreciate your excellent Spanish subtitles. As a hobbyist playing with electronics who has a need to learn Spanish, I find your videos extremely useful.
As always. A very good overview of available components. You asked for other current measurment needs. Right now I am looking for a 3 phase AC mains measurement sensor/device with one MQTT "result" = +/- Current Power Consumption. Finaly. AC current measurment and power calulation with coils. In case of enough Solar PV power I would like to control the boiler heater with it. Yes, there are final products on the market. Including thyristor output. Some of the power meter do not have an output. Often the Output is very slow. openenergymonitor would be a way to go. Some chinese Powermeter offer products with MODBUS. But in most cases no CE conformity.
Thank you very much Andreas. Yesterday evening I was looking at these types of sensors to improve my project. And today there is your video ! Did you hear me from switzerland !?!? ^ ^ Perfect in timing !
Fine video. I chose to use a now obselete Infineon device, the TLI4970 range. This enabled me to resolve 6.25mA yet still measure 25 amps bidirectionally. I was far from perfect in that it used an SPI interface to obtain the current measurement but a one-wire style bus to minimise bandwidth (needed to get the fine resolution).
Very comfortable to me to understand and also I think that things close to the camera on your hand will move too roughly to try to view., very sincerely
The burden resistor can be changed with the scale; so, the bigger reason for the different connector is the fuse. Usually when there are two different connectors each connector has a different size fuse.
Love your video Mr. Spiess. I am a mechatronics student. I am always able to solve most of my problems and improve my designs just by getting inspiration and knowledge from your videos. Keep up the good work sir and stay safe.
Andreas, thanks for the video. The datasheet of INA219 / 226 / 3221 states that those are bidirectional. For example INA219 datasheet "8.6.3.1 Shunt Voltage Register (address = 01h)" says "At PGA = /8, full-scale range = ±320 mV (decimal = 32000). For VSHUNT = +320 mV, Value = 7D00h; For VSHUNT = -320 mV, Value = 8300h;" Did you test it with reverse current, and didn't work, or am I reading something wrong?
I like the INA260 based breakout from Adafruit with I2C output. Here are some specs: Precision Integrated Shunt Resistor: - Current Sense Resistance: 2 mΩ - Tolerance Equivalent to 0.1% - 15-A Continuous From -40°C to +85°C - 10 ppm/°C Temperature Coefficient (0°C to +125°C ) • Senses Bus Voltages From 0 V to 36 V • High-Side or Low-Side Sensing • Reports Current, Voltage, and Power • High Accuracy: - 0.15% System Gain Error (Maximum) - 5-mA Offset (Maximum) • Configurable Averaging Options • 16 Programmable Addresses • Operates From a 2.7-V to 5.5-V Power Supply • 16-Pin, TSSOP Package
@@AndreasSpiess Seems pretty cheap to me for what you get: 1.5mA precision across a 15A range, thanks to a 16bit ADC! From www.distrelec.ch CHF 13.57, or $9.95 from Adafruit. www.adafruit.com/product/4226
15:26, I thought INA219 can handle reverse voltage, though. The datasheet says it is a "Bidirectional Current/Power Monitor", and the PGA input voltage range is +-320mV (or lower depends on the configuration, but always plus and minus).
FYI. Testing some 50A Bidirectional ACS758, they don't seem to work correctly on 3.3V The data sheet specifies the minimum voltage of 3V and typical of 5V, but if you supply with 3.3V, then the output voltage is far too low, only around 0.5V If you increase the supply voltage to 4V the output jumps to 2V, and if you reduce the supply voltage to 3.3V, the output voltage is correct at 1.65V Strangely the 200A ACS758 seems to work OK on 3.3V. I've tested multiple 50A versions and they all have the same problem. Possibly its a manufacturing batch problem, or because I bought from China and hence they may not be genuine devices. However I think these are probably intended to operate from a 5V supply, given that the datasheet specifies 5V as the "typical" voltage. Hence I'm going to need to scale the output when interfacing to an ESP32 which is 3.3V
Hi Andress, great video. BE CAREFUL WITH SOLAR SYSTEMS. I worked a bit with INA219 some time ago, it can the measure negative currents also, but be carefull with SOLAR SYSTEMS. I you have a Solar charger controller, you CAN'T use two/three INA219 as you say. That's is why, normally, cheap solar charger controllers are "positive common", and you SHOULDN'T join also the negative part with two/three INA219 connected to the same MCU, otherwise SCC won't do its work and everything (load, panel, battery) will be connected thought our "mcu/ina219 common ground". I left that project, but I want to resume it again by using a voltage inverter and use the "positive common" of the solar system as my "negative ground of my MCU and INA219". I hope you undertand me. With a solar charger controller with common ground, it wont be a problem.
Interresting. So far I only used relatively small panels/chargers with negative common. Thanks for the hint to pay attention! I learned from a viewer that they also can measure negative currents. And the INA226 is sold for High and low side. So in your case maybe you could use it on the low side?. But I am not sure.
@@AndreasSpiess But that is not the problem, is it? Low/High side is not a problem, the problem is that you have to "join" ground of each INA226 between them and with your MCU's ground, so you are also joining grounds in your solar system. May be I am wrong.
I came to the same conclusion as Fernando. All INA219 will have ground tied together with MCU. Won’t work cheap voltage controller directly. You may reverse voltage on the MCU to get around and find a way to have common positive everywhere.
@@marcrives279 any idea Marc to solve this? I remember that I thought about using a step up to rise the battery voltage (for example from12-14v to 22v), after, using batt+ as gnd for the LDO, an step down from 10-8v to 5v. So we have now a MCU's gnd joined with all three positive of load, solar and battery connectors in solar charger controller. Then, we have to measure negative voltage and "negative shunts". But I stopped here. Any idea with cheap components?
@@diydsolar My idea would be to set a 5V DC DC *isolator* to power MCU and tie MCU GND to VBatt. INAxxx GND would all be tied to VBatt (common positive). INAxxx V+ (or V-) will be connect to each different ground. You have to watch out for maximum common voltage, reverse voltage readout... But it would do.
Wish i stumbled across this video earlier, what an excellent practical introduction! Wish i'd found you earlier would have saved me a while load of googling time.
In a system where an arduino is connected to an H-Bridge motor controller, would you need different current sensors for different voltages and currents? This is for a model train system where a bipolar signal of about 10kHZ is fed to the train rails. An Aarduino motorcontroller has a current sensor. There are also other motor control boards like Pololu, LMD18200 and other. There is also max471 current sensor board. Most people would run 12-14 volts at 2-3 amps, but others would want anywhere from 12V to 20V at 3 to 30 Amps. How can you get good curent sense sensitivity across such a wide range of currents? We don't want to fry the 5v pin on an Arduino, and we don't want to miss being able to turn off the device if there is a short. Thanks for your fun videos!
I canno solve complex problems in without understanding them fully in two sentences. Maybe you contact another Swiss guy? th-cam.com/channels/hz75ReW4Nd8VsYzfUzcB7g.html
Can I use the INA219 to measure voltage and current of the load itself without using a second microcontroller? As you showed at minute 14:10, I would like to calculate (using 2 INA219) the voltage and the current from solar panel to battery and the voltage and the current from battery to the load (ESP32) using the ESP32 itself (without the MCU).
You can do this with 2 INA219 (you can connect up to 4 INA219 to the same I2C bus if you select different addresses) or one INA3221 (pay attention that you use the improved version).
One important thing to keep in mind about using mains with the ACS712 - Hall Effect-Based Linear Current Sensor is that the 30Amp version does not actually handle 30Amps RMS. You have to remember that a 30Amp rms AC sinusodial current has a peak current of 42.2Amps. The spec for the 30A ACS712 says it can handle from -30A to 30A meaning the peak current is 30A which means it can handle at most an RMS current of 21Amps. You should never attach a load higher than 20Amps RMS. If you don't understand what this means, do not mess with mains loads.
Hi Andreas, it seems I am following your steps - today I am building a power supply for my raspberries and I shall use INA260 for the current/power measurements (with ESP32 of course because who wants to read from the power supply if it can go to home assistant via MQTT ;-) ). I will report the accuracy once done.
@@AndreasSpiess so I finished and I am astonished. First: 16bit ADC inside - quite amazing. Second: only 16mV/A voltage drop so with my 10A power supply it is only 160mV. So I am OK with the results ;-)
I think most of the INAs can be used for high-side or low-side current sensing. Nevertheless I very much prefer the INA260 to any of the ones you presented not just because they have an I2C interface but also they can sense at ridiculous speeds with great accuracy and do not require a (potentially inaccurate) external sense resistor. They also work just fine with reversed current flow and will report the direction accordingly, so they can be used to monitor a rechargeable battery just fine.
@@AndreasSpiess It's fine, especially considering the built-in laser trimmed resistor: A beefy (but lousy +/- 1%) 2mΩ alone does cost around 20% of the whole INA260 with it's 0.1% tolerance resistor. Not to mention that you can use it like that without additional external parts and thus a lot less design issues. Adafruit has a module with it for MSRP $9.95 which sounds very fair and maker friendly to me.
I watch your videos more and more, so I can get good with your accent... At the first time it was horrible, but your knowlage is huge! I build myself many cool projects. I like your and great Scott's videos, because its so great to Learn things. Ok sorry it's pretty late and my brain is already gone asleep, Im sorry for my bad English writing...
Hi Andreas, in your summary you say that the "shunt" type current sensors can only measure current in one direction. I am using a MAX9919 as the current sensor for DC Motors. By using a voltage divider I offset the output coming form the sensor, so the microcontroller's 10bit ADC reads 512 for 0V, 1023 for maximum positive voltage, and 0 for maximum negative voltage.
I like the high-side analogue types as you can feed the output voltage in to the uP analogue input as well as its comparator input. this give the circuit the ability to kill the power on overload without waiting for the software to notice. it's good on safety grounds as it removes the software from detecting the fault current and of course still works if the software has got stuck in a loop. Oh and is faster to act.
I assume this is the reason for the INA226 which has such a pin. For safety, this is for sure a good thing. One other sensor also has a comparator on board for that reason.
@@AndreasSpiess yes it's always better to remove software from detecting faults and acting on them, better at times to act then let the software know. i know you can use interrupts, but interrupts make it harder to demonstrate that the code will always work as you cant easy test your code being interrupted in every possible place. Thank for another thought provoking video.
Be very careful with two things: 1) In systems with high pulse currents (motors, etc) can cause an excessively large voltage drops across the sense resistor. This can be large enough to move the supply line out of spec and possibly even reset the processor. This can be mitigated some by capacitor(s) from supply to ground on the processor side (I recommend a ceramic for fast pulses + tantalum for storage). I you need more than that, you can add a Pi filter (2 capacitors with an inductor between - shaped like pi). 2) On systems that have storage devices (inductors, motors, and/or capacitors) then current can flow back to the battery (negative current). This has to be accounted for (and tolerated).
To point a): You are right. We experience this also with the ESPs when WiFi is switched on. I showed this in one of my videos. b): Magnets are always dangerous and it is advisable to add a diode in the opposite direction to prevent damage. Caps less because their voltage should not go higher than battery voltage.
You are right, I could have focused more on AC measuring. But the video is already quite long, and maybe I will make one for AC, too. There are many other problems to solve like power factor and RMS...
7:20 the best here would have been to use something like an instrumentation amplifier in order to take a differential voltage measurement across the current shunt resistor without affecting the circuit in question.
Great video. I have a question about inline current sensing with a switched reluctance motor. I have a asc712 30A sensor and I'm not able to get measurements when I turn the power on and I'm not sure why. At the moment I think its because it does have pwm rejection. The motor has no magnets and only windings in the stator. I've also isolated the sensor and validated that there isn't any problem with my code.
I think transimpedance amplifier will work on low-side with additional negative supply. There will some error current which can be corrected in software.
Thanks Andreas for another useful and detailed video. Just to mention that the Adafruit script would give the correct bus/load values if you swapped the wires connected to the shunt.
This is exactly what I need for power data logging project of measuring voltage & amperage over time 👍 love this channel & thank you for all the hard work you put in to produce your videos.
Gruetzi Herr Spiess, I got my current sensors in the mail this morning and decided that the obvious thing to do was rewatch your excellent video. But... 8:26, am I gravely mistaken or is it INA3221 instead of INA3321 as you say? I have fond no conclusive reference to a INA3321 sensor in the googlesphere. Have I missed something here?
I would really like to have your opinion on changing INA 219s shunt resistor for different loads and voltages. I absolutely love your videos. You are a beacon to self- made specialists and electronics entrepreneurs.
Herr Spiess! Vielen dank!! This is very timely info. I am looking at monitoring the 230VRMS mains supply to my borehole pump and have now changed my plans away from the ACS714 (which I can easily get at the local hobby shop in South Africa) to the WCS1800 which I didnt know of . . . .In terms of measuring mains Voltage and Isolating it from my little Infineon XMC4500 ARM processor I am looking at using the HCPL7510 which is optically isolated, is there something more appropriate that you know of?
Another super informative video ...I have just gone though this with a project for work although I opted for the ACS 758 higher powered version for my application. It does work very well though as our devices range from 0-13 and 0 to 20 amps.
Under some circumstances I can imagine a usable adaption from the sceme at 7:55. First the upper two resistors should have the same number. If you expect low amps the lost engergy is not so high, so you can chose a not very low Ohms for these two resistors. Now you might lower your input voltage by this... but if the power source is a bug-converter you can use the voltage after the resistor for contoling the outputvoltage of your converter... so you will constantly have the same voltage behind the resistor. Might this work, or did a miss something? Edit: Not the same resitor but similar range for the upper two resistorts... ahhhh it's too early.
If you have a fixed resistor load you can do many things like increasing the resistor. Most loads have various consumption and do not like large resistors in their supply line.
You should have a look at a company called LEM, I thought they have a production plant in Switzerland. I also missed the distinction between open-loop and closed-loop hall based sensors.
I am already using the PAC1934 from Microchip in a few projects and it is much better in terms of performance than the parts demo-ed in the video. I think it is better to look for other options than whatever is available on AliExpress
Depends on what you want. The PAC1934 for sure is a capable chip. I assume, most of the maker projects do not need it. And not everybody wants to create a PCB just for measuring current. This is of course different in a professional application.
@@AndreasSpiess Yes, you're right. For most of the makers the AliExpress modules are probably more than enough. In my case, I am a bit reluctant to rely only on the AliExpress modules due to some bad experiences in the past (some of the AliExpress modules I ordered were using older, buggier revisions of a given chip, sometimes even faulty parts). I guess some of the old chip revisions can be bought fairly cheap by module makers in China. As a maker, I always like to experiment a bit with parts which aren't yet available as modules. This helps me differentiate a bit. PAC1934 has a QFN variant which I soldered on a PCB adapter. Then, I was able to play with the part on the breadboard.
I need to measure the current drawn by a large brushed DC motor 180V 200W driven by a DC Thyristor drive. The rated current of the motor is low at 1.2A. In order to run the motor, DC Thyristor drive needs to be powered by AC mains, which then connects to the two leads of the DC motor. Can I place INA219 in between the drive and motor to measure current? or will it not work because of the high voltage involved?
Hi Andreas, do you know some chip option to measure current bidirectionally? I mean when a battery is charging and when the same battery is discharging. Thank you
Andreas, have you used the 10A range on your UT804 meter to measure fairly low currents? Mine shows 00.000A until I get to about 0.24A (AC if it matters). Once it starts showing a reading it seems to add 30-50mA to the actual current. The lower the current the more it seems to add. It also reacts to changes in current very slowly. I don't have a good way to test above 1.25A right now, but the added current makes less difference and seems to get less anyways. I am not sure if I have a defective unit or if they are all like this.
I just checked. Mine goes down to 10 mA. I did not test the accuracy, though. But it showed similar numbers than the power supply. So yours seem not ok. Or you method is wrong ;-)
I was really liking the WCS1800 to use as a current probe for automotive use but the lack of documentation I can find on the internet is so disappointing. I love your content BTW, very useful info on the ESP32.
@@AndreasSpiess Ah, so it is! That's what I get for using another search engine. I see from the dimensions I can fit a 3 Gauge wire, that should cover everything but the battery cable itself, and I can make a test cable for that. Thanks Andreas, you go above and beyond the call of normal youtubers.
@@AndreasSpiess Hey Andreas, just to let you know I bought one and connected it to a 10 bit AD I use with the ESP on its SPI bus. I've tested it out with the ESP's own current consumption on a 5V line and it leaves a little to be desired, mostly noise at those levels, but for high amperage it'll probably work much better. The ESP does intermittently draw over an amp when using wifi, which is consistent from what I've heard. It is pretty neat, I have the ESP connected to my cell phone via wifi and remotely turn it on and off and change the sampling/duration from the comfort of my chair. Again, appreciate all the info!
Any suggestion on how to measure current for a higher DC voltage, like for 170V nixie tubes running at ~6-30mA? TI has a design documentation using a INA138 with a virtual ground, but I'm wondering if there are other solutions especially since there seems to be some wasted watts using this design.
Just a note. For any one using max4080 you are going to need resistor and capacitor before sending it to analog pin of mcu. Otherwise your readings are going to be all over board.
Have you done video on the ina3221 with two grounds? I have a few of them, but never used them before. Im hopping I can use just one per Meshtasic node to monitor solar panel V&I, battery V&I, and external 5v V&C source.
We use V to pay homage to Volta. "U" is just weird. So was changing anything with "ss" into "B". The SS also stood up straight, you're lucky you weren't forced to bend over for the last 70 years. Oh wait.
@@AndreasSpiess ahh, sure, that makes more "sense" now lol (pun intended) - I figured if you wanted to measure current through a (Load + Rsense) that you could install a current monitoring/voltage sensing MC in parallel to (Load + Rsense), but yes if your load happens to be the current monitoring MC, then you'll have problems as you've illustrated, lol. Thanks for the response, love the vids!
Yes Andreas, ACS712 module is completely junk for measuring High voltage AC specifically. Because I used that module to measure the power consumption of some electrical appliances and after a copule of week the sensor burnout(I don't know why and I had only 20watts of load at that moment) and high voltage AC passed through anolog pin and also completely damage my MCU as well.
@@AndreasSpiess Its being said that both CMRR and offset voltage shuld be low. Shuldnt Common Mode Rejection Ratio be actualy high? Since in perfect op amp it is inifinite. Common singlas provide less distrubance in singals as CMRR is geting bigger and in this case we have to take them into consideration. Ofset voltage shuld be low, as we want our signal to be as close to 0V as it can get when signal is 0V as well.
What would you do/use to sense if mains is on or off on a circuit? The current/power does not need to be measured. The goal is to sense if a teleruptor is on or off, with an arduino.
@@AndreasSpiess thank you for your answer, I've watched many many many of your videos and did not expect you to answer! I expected the community to answer. Waw I'm perplexed you took the time! As to the solution, I'm looking to wrapping a wire around the mains wire and using a transistor array to amplify the inducted signal. See th-cam.com/video/cDuObAR42Nw/w-d-xo.html
Ohm's Law: I = U / R
You are right !
For fans of the streetfighter franchise it's quite easy to memorize: RI=U
@@VincentFischer Or for the Swiss: U = RI
@@markusmohr5470 I was taught I = V/R
Same but different symbols
I learned V = I * R. Pretty basic.
I really like that you explain in detail the reasons for not doing things a certain way, rather then just telling us how to do things correctly the first time.
I find it helps me understand things a lot better when I know the 'why not' as well as the 'how to'.
Thank you for sharing your knowledge in such a high quality manner!
Thank you for your nice words!
That hand-pointer is hilarious!
Thank you!
Yeahh
The INA226 work on the high side or on the low side. The input voltage ist higer than the INA219. But with 0.1 R it only can take 1 Amp. A lower resistor for higher Amps is needed. 0.02R is about 4 Amps.
You are right. These chips work on both sides. My mistake!
An enormous THANK YOU to all TH-cam content creators for providing all of us with additional content during this very trying time! I can only speak for myself when I say you are helping me retain what little sanity I have left having been sheltered in place for the last 2 1/2 weeks!!
Thank you for the nice words. We are glad to help!
I recommend you take a look at the INA260. It’s I2C and works on 3V or 5V logic. It can measure up to +36VDC at 15A continuous on either high or low side using a 2 mΩ sensing resistor.
Another viewer suggested this part, too. Very nice, but not cheap ;-)
@@AndreasSpiess true, it's not cheap, but come on as a Swiss you are used to that. 😜
But jokes aside, it is very precise and has a very low resistor value. So the voltage drop is minimal and the measurement range is huge.
I’ve used this part in a commercial 1kwh 24v battery pack. It performs very well.
I work as a hardware design engineer and tbh high side current sensing is almost always preferred on our circuits for various reasons. We use opamps from TI specifically for this.
I also do not like to cut ground wires...
The probkem has been, typically, that you need to measure voltages that are higher than the V+ in the DUT, in case where you are measuring your 'own' current consumption, which is a probkem for most amplifiers... of course, low-side measurements make the V- a bit 'floating', but the voltages being measured are referenced to 'ground', making noise suppression easier... high-side measurements also affect the apparent V+ of the DUT. Lots of considerations to make, almost all of them introduce some compromise in the DUT performance/stability, or bandwidth, or sensitivity, or dynamic range, or... I spent a few years doing this stuff...
Which opamps please.
which part number are you using ?
@@OmarMekkawy OPA192
you videos are such a wonderful resource on the internet. thank you Andreas. Love your country - spent many days leading boy scouts around the country from Kandersteg.
Thank you for your kind words! You chose a nice place to judge about our country ;-)
6:52 Thank you professor. I thought it is just me who thinking to replaced current sensor with two or more resistor
:-)
on esp32, you put adc reference to 1.1v. Then use a diode between adc input and ground, and 50k resistor between 3.3v and adc input. This will set the diode voltage drop (cca 0.5v) as your referent zero. Then you can use a shunt on battery negative side without the loss of resolution. With some noise cancelation and polynomial calibration coding, you get a pretty good +/- current meter. I'm using that on a solar system with 60A both ways ;)
Interesting concept. Thank you for sharing!
I was researching for few months on measuring mains current and voltage. Finally your video. I have seen almost all video. But no video explains as you did. I needed this video a month ago. So that would reduce lot of my hard work.
Sorry that I was too late!
Nice video as usual. I think that I have tried the INA219 Before and it measures the current in ( Bidirectional + and - ) without no problems. You could connect it to a battery and ( sink , source ) current.
Omar Mekkawy I just checked the data sheet and it does have a sign bit. Also I'm pretty sure I hooked my leads up backward when my mAh tester project the first time and I did get negative current readings when the supply read lower than the load.
You are right. My mistake!
Andreas Spiess, I should have read more of the comments. You stay safe!
@@AndreasSpiess never mind. you are welcome.
Endlich ein Video was genau mein aktuelles Projekt betrifft... Solarzellen, Laderegler, Batterien, Verbraucher... Super Video
Danke! Nun sollten wir nur noch ins Do-it-Yourself gehen dürfen...
@@AndreasSpiess Na zum Glück stellt die Post noch von AliExpress zu ;-P.
Very timely. I am a novice using a small 5v solar panel to power an Arduino and LoRa unit. I think the current drops too low when shady, so it will useful to implement one of these units to track current and only try to send comms when enough current is available. Thanks!
Jason Pluis adding a battery helps, but luckily you're on the right channel to find out about this sort of thing!:)
Without a battery it is probably easier to use the analog input and decide on the voltage at startup.
This is good timing...I just got my ACS712 analog sensors in and was testing them and they did not show 2.5V at zero current. Reading up on this, I found that they need a precise 5V vcc to guarantee 2.5v at zero. I stuck a 7805 to deliver precise 5V to it and voila, it worked precisely as expected. You should mention that.
The INA226 sensors dont seem as sensitive, they must have a 5V zener reference for their ADC or something like that.
I assume the INA219 has a built-in voltage reference. The ACS chips not.
As always, this video is torough, detailled and exact !! Thanks Andreas ! Your work is greatly appreciated !
Many thanks!
As always a very nice Video and i only have to disagree at a single Topic. At 5:50 you say you have to suply a +- Supply-Voltage to the Opamp. Because all Voltages at the Opamp in the inverting configuration in this Messurment-Circuit are at Zero ore in the positive Range it is sufficient to use only a posetive Supply when You use an Rail-to Rail Opamp.
( The Inputs have to work only from the Negative Rail, without Output Phase−Reversal, the Output would have to work from the negative Rail for the Minimum Current You can messure) You might use even a cheap opamp like the LMV321.
Thank You very much for this informative Video.
You are right. If you connect the ground of the op-amp to the battery the inputs would be positive.
Andreas Spiess
No, you can connect the ground (negative power supply) of the op amp to the Arduino ground.
You connect the (+) input of the op amp and the op amp negative power supply to the Arduino ground.
You connect the op amp positive power supply to the high side power.
You connect, say, a 10K ohm resistor between the power source low side and the op amp (-) input.
You connect the same value (or larger, to scale up the output) resistor from the (-) input to the op amp output.
This will invert the negative voltage across the 10 ohm resistor to a positive voltage at the op amp output.
The op amp drives its output to make the voltages at its (-) and (+) inputs equal: both end up at zero volts (Arduino ground).
Thus all the op amp input and output voltages are zero or positive - quite legal!
Notes:
I have built this circuit and used it in past projects to sense negative voltages with only a positive power supply for the op amp. It works.
Carefully read prospective op amp data sheets to select one where the common mode input range includes zero or slightly negative input voltages. This will be true for most op amps that have “Rail-to-Rail” inputs.
You also want an op amp with an output range that includes zero volts. This will be true for op amps with “Rail-to-Rail” outputs.
Select an op amp that has clamp diodes on its inputs, thus guaranteeing the (-) input cannot go very far negative.
The 10K ohm input resistor will limit any transient input currents to the op amp (-) input and its clamp diodes before the op amp output settles.
@@w6wdh, Andreas Spiess and Juergen Schimmer : The Rail-to-Rail feature is not even mandatory as (+) input can be biased to say 1V and the program will cancel that out with a simple I=aX+b (b being negative here). Or did I miss something ?
your channel is the first place to start searching whenever I need something practical and advanced ! ,, thank youuuuuuu man I wish I can meet you someday.
Happy to help! You are also one of my most loyal subscribers!
I think you'll find low-side shunt based monitoring fairly common actually! 20:20 INA210 and LMP8603 for starters. If using external shunt the safety benefits are great enough to warrant the loss of short-circuit detection the high-side offers (which is another plus for high-side not mentioned).
You might be right. But I do not like to cut ground wires...
@@AndreasSpiess One context for using a low-side shunt is when you have panel mounted shunts a distance away from the monitor. It's safer to then have the shunt sensing leads routed to the monitor because they're nearer ground potential. Not sure if it's a matter of personal taste :)
Hi, I got success to measure current by the hall sensor of a smartphone, I found an app (gauss meter) which has calibration option, and by using this app ,I measured current contactlessly. The sensor of a smartphone has 16bit resolution, so it is very precise
Thank you for this info. Interesting!
Well presented. I've been using ACS712 sensors in a solar test bed monitoring project for several years now. Lower precision works ok over time, and a single sensor measures battery charge and discharge.
Thank you for sharing your experience!
At 6:00
An inverting shunt op amp, doesn't need a negative supply, so long as it has an input voltage range that includes the negative rail.
Thank you for the info!
@@AndreasSpiess You're very welcome...
I didn't explain...
For beginners...
If the non-inverting (+) input of the op amp is tied to 0V, the amplifier will attempt to keep the inverting input at 0V too. When a negative voltage (with respect to 0V) is applied to the input resistor, the output of the op amp will go positive enough for the current through the feedback resistor to counter the input current and hence pull the inverting input pin back up to 0V.
Thanks for the nice video !
However I have a few points about INA219 :
- INA219 is bidirectional, it is in the title of the datasheet
- It can do the power calculation itself, it has register to read it
- It can be low side, but you loose voltage and power measurement (prefer INA220 to do this)
- Two versions are available, A with 1% accuracy and B with 0.5% accuracy.
By-ye :)
You are right with the bi-directional. I did not know it and di not read the ".." manual. But I do not like to cut ground wires. That is probably why I did not even look at this possibility.
@@AndreasSpiess I used to monitor charge and discharge so I remembered positive and negative currents.
I prefer the High side measurement too. Thanks for the reply ;)
Yes, it's good practice to show mains voltage a lot of respect! Industry requirement is, at least, 5mm space between mains and low voltage on a PCB which is accomplished with the SOIC you showed. It is also very common practice to actually route a slot in the PCB to generate an air gap isolation which, quite frankly, I think is better. A little "aide memoir" for Ohms law is just to remember V/IR (yes, V for Voltage), cover the variable you want and what remains is the formula for it! Simples! All this time I thought the pointer arm was attached to your your trusty assistant! 😁
Good point about the milled spaces on PCBs!
For alternative current, there is also clamps without hall effect, only transformer-like, for example SCT-013-000. And they can be clipsed around existing wire, perfect for measuring AC without even disconnecting anything. One may take precautions to over and under voltage if used with some arduino analog input. Combined with a small voltage transformer it can allow to measure power.
Maybe I will make a video about AC current measurement in the future.
Excellent explanation. I just proved your point on destroying an INA169. I put +12v across a 50 ohm RF dummy load from a bench supply with the INA in series. I took the +5v for the INA169 from the 5v pin on a Nano. The Nano was powered from USB. Worked for a while, until I lifted the load. Poof! Unfortunately when it fails it shorts the shunt to ground. Make sure your power supply is current limited.
Shit happens... Fortunately they do not cost a fortune...
In the both first cases if the load circuit is different from the measuring circuit i.e. you power the load and the measuring system(here arduino)with
two seperate inputs ,you can use the potential difference between the small resistor to detect the current in the load circuit.
You are right.
I use the LTC4151 as a current sensor for my home off-grid solar system. I use two per shunt to give me bi-directional current sensing. Not a cheap chip but great for my setup.
Thanks for sharing your experience!
Thanks Andreas, I want to measure the current used by a small brushless motor inside a tank to not only sense when it is running but also for diagnostics in case it stalls. This video just at the right time!
Glad you can use it!
714 comments and it feels like you have read all them based on the impression of how many you have replied to. I have just tried to do a search on these particular comments for "coulomb" but strg + f does not work so far cause the page is not loaded into the memory I guess. But I have looked into those comments you had replied to therefore I can at least judge a bit about how much effort must have put into reading the comment and replying to all those that needed help and you had answers for.
Just a big "chapeau !" or "Hut ab !" from the Andreas on this keyboard to
the other Andreas with the hat on his head.
I guess this coulomb meter / counter would be a great project if it could work with a pico or esp and a display just to show the current state of a battery in a mobile home / Wohnmobil / RV
thanks
You are right. I try to answer all comments. This is a few hours of work a week. But I enjoy it.
You can measure incredibly small currents with the hall sensors by putting an inductor with more turns near it.
There are also some self-oscillating inductor types that measure current through a transformer.
This seems to be a quite complex procedure. But you are right. It seems to work.
It's a wonderful audience here - every small mistake is recognized immediately - awesome video btw.
This is the fate of the guy who stands up and does something...
@@AndreasSpiess wer viel macht , macht viele Fehler,
wer wenig macht, mache wenig Fehler,
wer nichts macht, macht keine Fehler und
wer keine Fehler macht wird befördert.
Da hast du recht. Wahrscheinlich sitze ich deswegen immer noch im Keller ;-) Aber ich bin zufrieden.
I used a current transformer to measure AC current drawn by a refrigeration compressor. It was quick and sensitive enough to detect the inrush surge upon start. (This led to a hurried code patch to ignore the excess current for a number of mains cycles after compressor start.) Accuracy was good enough for the application. Better than 50mA according to an uncalibrated AC meter.
A few code tricks to get the "RMS" current from the sine wave... detecting zero-cross points for mains frequency and therefore when to measure the "RMS" current.
Maybe I will come back to you with the "RMS tricks" when I prepare a AC current video...
To measure the current through the ground line without requiring a negative rail on the op-amp, you could add a bias current by attaching a resistor to a stable positive. The bigger problem I have run into with measuring current on the ground side is that there can be more than one ground connection (such as when you connect the USB and a separate supply. Also, circuits are much more sensitive to voltage changes on the ground than they are to voltage changes on the supply input. Note: Current sources other than from the supply can still affect an accurate current measurement when measuring on the high side of the supply as even I/O lines can provide a current path into the processor. Hopefully these are very small compared to the battery current. At work I have one device I have to test that consumes 10uA in one mode and up to 10A in another. This requires care.
You are right if you conect the opamp to the battery ground. And concerning having two different grounds, your argument is why I do not like to cut the ground wire.
It would be great if you can make a short follow up on the INA3221 triple channel. Once it had arrived and you have something significant to say about it... What strikes me is that it is in a qfp package so transplanting it to a custom board perhaps is more hassle than the tsop ina219 single channed. So then what to do to replace those shunts on it eh? Does it matter that to make a jumper wires off the breakout board. It may be too high resistance to interfere with the measurement? Or am i mistaken, that it does not affect enough being a higher impedance voltage measurement?
Of course the connectors are important. But because Vin pins are connected very close to the shunt resistor, the board connectors have no influence on the accuracy. But on the burden voltage, of course. The INA3221 has quite "beefy pads.
The isolation of the ACS712 is fine. It's just that a stupid module design often makes it moot, because whoever laid out the board thought it was a good idea to flood fill everything with a ground plane. I generally like the ACS712 (or hall effect sensors in general), because you don't have ground/reference issues. I don't have a need for any other current measuring modules (for low currents I just build my own with an opamp).
Be careful with the modules you get from ebay/aliexpress. I got some with ACS712s that were wildly out of spec on their output noise (more than 5x higher than claimed in the datasheet), while others from another order (from the same seller) were fine. That was a few years ago though. Wouldn't be the first time that the chinese sell factory rejects. That goes for any chip.
I also like the hall concept. But with a small chip like that it is really not easy to produce the needed distances on the PCB. Most of the power supplies also have a milled slot between mains and low voltage. And I also have a responsibility for unexprerienced viewers ;-)
Maybe I create once a video about AC current measuring. Thanks for the "noise" tip.
Hi, great video. Right now I am working on a Design, that needs current measurement. I choose the TLI4970, which can do up to 50A bidirectionally, at very low heat losses. It outputs a clean 16-bit digital signal.
An interesting part. An "INA219" with a hall sensor! Good choice.
Excellent video. I also appreciate your excellent Spanish subtitles. As a hobbyist playing with electronics who has a need to learn Spanish, I find your videos extremely useful.
The subtitles are made by Luciana, my Translator.
As always. A very good overview of available components. You asked for other current measurment needs. Right now I am looking for a 3 phase AC mains measurement sensor/device with one MQTT "result" = +/- Current Power Consumption.
Finaly. AC current measurment and power calulation with coils.
In case of enough Solar PV power I would like to control the boiler heater with it. Yes, there are final products on the market. Including thyristor output. Some of the power meter do not have an output. Often the Output is very slow. openenergymonitor would be a way to go. Some chinese Powermeter offer products with MODBUS. But in most cases no CE conformity.
I did not cover mains in particular. There you get other sensors. But I have no overview.
Thank you very much Andreas. Yesterday evening I was looking at these types of sensors to improve my project. And today there is your video ! Did you hear me from switzerland !?!? ^ ^
Perfect in timing !
I asked Google what you weree searching yesterday and adapted the viceo accordingly ;-)
Fine video. I chose to use a now obselete Infineon device, the TLI4970 range. This enabled me to resolve 6.25mA yet still measure 25 amps bidirectionally. I was far from perfect in that it used an SPI interface to obtain the current measurement but a one-wire style bus to minimise bandwidth (needed to get the fine resolution).
6mA on 25A is impressif!
Very comfortable to me to understand and also I think that things close to the camera on your hand will move too roughly to try to view., very sincerely
The burden resistor can be changed with the scale; so, the bigger reason for the different connector is the fuse. Usually when there are two different connectors each connector has a different size fuse.
You are right!
Getting expensive watching these videos. I keep buying the stuff you show us Andreas. Loving it though so keep it up.
As long as your wife does not intervene ;-)
Love your video Mr. Spiess. I am a mechatronics student. I am always able to solve most of my problems and improve my designs just by getting inspiration and knowledge from your videos.
Keep up the good work sir and stay safe.
Fantastic! I have not problems wit hCovid-19 because I live in the basement while creating videos ;-)
Andreas, thanks for the video. The datasheet of INA219 / 226 / 3221 states that those are bidirectional. For example INA219 datasheet "8.6.3.1 Shunt Voltage Register (address = 01h)" says "At PGA = /8, full-scale range = ±320 mV (decimal = 32000). For VSHUNT = +320 mV, Value = 7D00h; For VSHUNT = -320 mV, Value = 8300h;" Did you test it with reverse current, and didn't work, or am I reading something wrong?
No, I did not test it ans was not aware of that fact. But you are right, it should work Thank you!
I'm about to start a design for a current data logger. Glad I found this video. Thanks!
Glad it was helpful!
I like the INA260 based breakout from Adafruit with I2C output. Here are some specs:
Precision Integrated Shunt Resistor:
- Current Sense Resistance: 2 mΩ
- Tolerance Equivalent to 0.1%
- 15-A Continuous From -40°C to +85°C
- 10 ppm/°C Temperature Coefficient
(0°C to +125°C )
• Senses Bus Voltages From 0 V to 36 V
• High-Side or Low-Side Sensing
• Reports Current, Voltage, and Power
• High Accuracy:
- 0.15% System Gain Error (Maximum)
- 5-mA Offset (Maximum)
• Configurable Averaging Options
• 16 Programmable Addresses
• Operates From a 2.7-V to 5.5-V Power Supply
• 16-Pin, TSSOP Package
Thanks for sharing your experience. For sure a nice chip! Not cheap, though.
@@AndreasSpiess Seems pretty cheap to me for what you get: 1.5mA precision across a 15A range, thanks to a 16bit ADC! From www.distrelec.ch CHF 13.57, or $9.95 from Adafruit. www.adafruit.com/product/4226
15:26, I thought INA219 can handle reverse voltage, though. The datasheet says it is a "Bidirectional Current/Power Monitor", and the PGA input voltage range is +-320mV (or lower depends on the configuration, but always plus and minus).
You are right. I made a mistake.
FYI.
Testing some 50A Bidirectional ACS758, they don't seem to work correctly on 3.3V
The data sheet specifies the minimum voltage of 3V and typical of 5V, but if you supply with 3.3V, then the output voltage is far too low, only around 0.5V
If you increase the supply voltage to 4V the output jumps to 2V, and if you reduce the supply voltage to 3.3V, the output voltage is correct at 1.65V
Strangely the 200A ACS758 seems to work OK on 3.3V.
I've tested multiple 50A versions and they all have the same problem.
Possibly its a manufacturing batch problem, or because I bought from China and hence they may not be genuine devices.
However I think these are probably intended to operate from a 5V supply, given that the datasheet specifies 5V as the "typical" voltage.
Hence I'm going to need to scale the output when interfacing to an ESP32 which is 3.3V
As you wrote, the datasheet says that they should work at 3.3V. So I do not know the reason.
Hi Andress, great video. BE CAREFUL WITH SOLAR SYSTEMS. I worked a bit with INA219 some time ago, it can the measure negative currents also, but be carefull with SOLAR SYSTEMS. I you have a Solar charger controller, you CAN'T use two/three INA219 as you say. That's is why, normally, cheap solar charger controllers are "positive common", and you SHOULDN'T join also the negative part with two/three INA219 connected to the same MCU, otherwise SCC won't do its work and everything (load, panel, battery) will be connected thought our "mcu/ina219 common ground". I left that project, but I want to resume it again by using a voltage inverter and use the "positive common" of the solar system as my "negative ground of my MCU and INA219". I hope you undertand me. With a solar charger controller with common ground, it wont be a problem.
Interresting. So far I only used relatively small panels/chargers with negative common. Thanks for the hint to pay attention! I learned from a viewer that they also can measure negative currents. And the INA226 is sold for High and low side. So in your case maybe you could use it on the low side?. But I am not sure.
@@AndreasSpiess But that is not the problem, is it? Low/High side is not a problem, the problem is that you have to "join" ground of each INA226 between them and with your MCU's ground, so you are also joining grounds in your solar system. May be I am wrong.
I came to the same conclusion as Fernando. All INA219 will have ground tied together with MCU. Won’t work cheap voltage controller directly. You may reverse voltage on the MCU to get around and find a way to have common positive everywhere.
@@marcrives279 any idea Marc to solve this? I remember that I thought about using a step up to rise the battery voltage (for example from12-14v to 22v), after, using batt+ as gnd for the LDO, an step down from 10-8v to 5v. So we have now a MCU's gnd joined with all three positive of load, solar and battery connectors in solar charger controller. Then, we have to measure negative voltage and "negative shunts". But I stopped here. Any idea with cheap components?
@@diydsolar My idea would be to set a 5V DC DC *isolator* to power MCU and tie MCU GND to VBatt. INAxxx GND would all be tied to VBatt (common positive). INAxxx V+ (or V-) will be connect to each different ground.
You have to watch out for maximum common voltage, reverse voltage readout... But it would do.
Wish i stumbled across this video earlier, what an excellent practical introduction! Wish i'd found you earlier would have saved me a while load of googling time.
Welcome aboard the channel!
In a system where an arduino is connected to an H-Bridge motor controller, would you need different current sensors for different voltages and currents? This is for a model train system where a bipolar signal of about 10kHZ is fed to the train rails. An Aarduino motorcontroller has a current sensor. There are also other motor control boards like Pololu, LMD18200 and other. There is also max471 current sensor board. Most people would run 12-14 volts at 2-3 amps, but others would want anywhere from 12V to 20V at 3 to 30 Amps. How can you get good curent sense sensitivity across such a wide range of currents? We don't want to fry the 5v pin on an Arduino, and we don't want to miss being able to turn off the device if there is a short. Thanks for your fun videos!
I canno solve complex problems in without understanding them fully in two sentences. Maybe you contact another Swiss guy? th-cam.com/channels/hz75ReW4Nd8VsYzfUzcB7g.html
Just ordered a couple samples of the INA260 that has an internal shunt and i2c. Can't wait to see how this compares!
They for sure are ok...
Can I use the INA219 to measure voltage and current of the load itself without using a second microcontroller? As you showed at minute 14:10, I would like to calculate (using 2 INA219) the voltage and the current from solar panel to battery and the voltage and the current from battery to the load (ESP32) using the ESP32 itself (without the MCU).
You can do this with 2 INA219 (you can connect up to 4 INA219 to the same I2C bus if you select different addresses) or one INA3221 (pay attention that you use the improved version).
One important thing to keep in mind about using mains with the ACS712 - Hall Effect-Based Linear Current Sensor is that the 30Amp version does not actually handle 30Amps RMS. You have to remember that a 30Amp rms AC sinusodial current has a peak current of 42.2Amps. The spec for the 30A ACS712 says it can handle from -30A to 30A meaning the peak current is 30A which means it can handle at most an RMS current of 21Amps. You should never attach a load higher than 20Amps RMS. If you don't understand what this means, do not mess with mains loads.
You are right. Thanks for the addition!
@@AndreasSpiess 👍thnx
Hi Andreas, it seems I am following your steps - today I am building a power supply for my raspberries and I shall use INA260 for the current/power measurements (with ESP32 of course because who wants to read from the power supply if it can go to home assistant via MQTT ;-) ). I will report the accuracy once done.
I hope it will be accurate...
@@AndreasSpiess so I finished and I am astonished. First: 16bit ADC inside - quite amazing. Second: only 16mV/A voltage drop so with my 10A power supply it is only 160mV. So I am OK with the results ;-)
I think most of the INAs can be used for high-side or low-side current sensing. Nevertheless I very much prefer the INA260 to any of the ones you presented not just because they have an I2C interface but also they can sense at ridiculous speeds with great accuracy and do not require a (potentially inaccurate) external sense resistor. They also work just fine with reversed current flow and will report the direction accordingly, so they can be used to monitor a rechargeable battery just fine.
The INA260 seems to be very good, but also expensive :-(
@@AndreasSpiess It's fine, especially considering the built-in laser trimmed resistor: A beefy (but lousy +/- 1%) 2mΩ alone does cost around 20% of the whole INA260 with it's 0.1% tolerance resistor. Not to mention that you can use it like that without additional external parts and thus a lot less design issues.
Adafruit has a module with it for MSRP $9.95 which sounds very fair and maker friendly to me.
I watch your videos more and more, so I can get good with your accent... At the first time it was horrible, but your knowlage is huge! I build myself many cool projects. I like your and great Scott's videos, because its so great to Learn things. Ok sorry it's pretty late and my brain is already gone asleep, Im sorry for my bad English writing...
Thank you!
Hi Andreas,
in your summary you say that the "shunt" type current sensors can only measure current in one direction.
I am using a MAX9919 as the current sensor for DC Motors. By using a voltage divider I offset the output coming form the sensor, so
the microcontroller's 10bit ADC reads 512 for 0V, 1023 for maximum positive voltage, and 0 for maximum negative voltage.
In addition, I was wrong. These INA sensors can read current in both directions, too...
I like the high-side analogue types as you can feed the output voltage in to the uP analogue input as well as its comparator input. this give the circuit the ability to kill the power on overload without waiting for the software to notice. it's good on safety grounds as it removes the software from detecting the fault current and of course still works if the software has got stuck in a loop. Oh and is faster to act.
I assume this is the reason for the INA226 which has such a pin. For safety, this is for sure a good thing. One other sensor also has a comparator on board for that reason.
@@AndreasSpiess yes it's always better to remove software from detecting faults and acting on them, better at times to act then let the software know. i know you can use interrupts, but interrupts make it harder to demonstrate that the code will always work as you cant easy test your code being interrupted in every possible place.
Thank for another thought provoking video.
Be very careful with two things:
1) In systems with high pulse currents (motors, etc) can cause an excessively large voltage drops across the sense resistor. This can be large enough to move the supply line out of spec and possibly even reset the processor. This can be mitigated some by capacitor(s) from supply to ground on the processor side (I recommend a ceramic for fast pulses + tantalum for storage). I you need more than that, you can add a Pi filter (2 capacitors with an inductor between - shaped like pi).
2) On systems that have storage devices (inductors, motors, and/or capacitors) then current can flow back to the battery (negative current). This has to be accounted for (and tolerated).
To point a): You are right. We experience this also with the ESPs when WiFi is switched on. I showed this in one of my videos.
b): Magnets are always dangerous and it is advisable to add a diode in the opposite direction to prevent damage. Caps less because their voltage should not go higher than battery voltage.
I am surprised you haven't talked about sct-013 family. (They are split core CTs)
You are right, I could have focused more on AC measuring. But the video is already quite long, and maybe I will make one for AC, too. There are many other problems to solve like power factor and RMS...
@@AndreasSpiess Please, include SCT013 in the future for current measuring. Thanks!
Would like that too.
Is there any other than WSH1300 to measure DC without cutting the cable?
ac current measurement for the next video will be very cool sir
The people of world afraid of covid-19 virus but you work about the electronic so I congratulate you
Thank you!
it was an educational and useful video. I watched every second with pleasure.
Glad you enjoyed it!
7:20 the best here would have been to use something like an instrumentation amplifier in order to take a differential voltage measurement across the current shunt resistor without affecting the circuit in question.
I agree. This is what the high side current sensors contain
Great video. I have a question about inline current sensing with a switched reluctance motor. I have a asc712 30A sensor and I'm not able to get measurements when I turn the power on and I'm not sure why. At the moment I think its because it does have pwm rejection. The motor has no magnets and only windings in the stator. I've also isolated the sensor and validated that there isn't any problem with my code.
Also the power specs are 20v 13A
Maybe you need an oscilloscope to look at the voltages to understand what happens
I think transimpedance amplifier will work on low-side with additional negative supply. There will some error current which can be corrected in software.
Yes, you are right
@@AndreasSpiess sorry, I mean't "without additional power supply".
Thanks Andreas for another useful and detailed video.
Just to mention that the Adafruit script would give the correct bus/load values if you swapped the wires connected to the shunt.
You are right. When I made the video I did not yet recognize that the INA219 can measure current in both directions :-(
This is exactly what I need for power data logging project of measuring voltage & amperage over time 👍 love this channel & thank you for all the hard work you put in to produce your videos.
Glad to read that you can use the content!
@@AndreasSpiess Is it possible to cover power measuring sensors with data logging function in future?
I do not think so because we build our loggers ourselves ;-) So the topic is probably too special for most of my viewers.
Gruetzi Herr Spiess, I got my current sensors in the mail this morning and decided that the obvious thing to do was rewatch your excellent video.
But...
8:26, am I gravely mistaken or is it INA3221 instead of INA3321 as you say? I have fond no conclusive reference to a INA3321 sensor in the googlesphere. Have I missed something here?
Yes, it is an INA3221.
I would really like to have your opinion on changing INA 219s shunt resistor for different loads and voltages.
I absolutely love your videos.
You are a beacon to self- made specialists and electronics entrepreneurs.
Just change the resistor and do the calculations according ohms law (the right one, not mine ;-)
Herr Spiess! Vielen dank!! This is very timely info. I am looking at monitoring the 230VRMS mains supply to my borehole pump and have now changed my plans away from the ACS714 (which I can easily get at the local hobby shop in South Africa) to the WCS1800 which I didnt know of . . . .In terms of measuring mains Voltage and Isolating it from my little Infineon XMC4500 ARM processor I am looking at using the HCPL7510 which is optically isolated, is there something more appropriate that you know of?
Maybe I will make a video about measuring AC. So far I do not have everything together. The HCPL7510/20 is for sure a candidate.
Another super informative video ...I have just gone though this with a project for work although I opted for the ACS 758 higher powered version for my application. It does work very well though as our devices range from 0-13 and 0 to 20 amps.
Thank you for sharing your experience!
Looking forward to using some of these sensors in future projects. Thanks!
Have fun!
Explica muy bien los diferentes tipos de sensores de corrientes existentes para proyectos con microcontroladores, y teoría de cómo funcionan
Gracias!
Under some circumstances I can imagine a usable adaption from the sceme at 7:55. First the upper two resistors should have the same number. If you expect low amps the lost engergy is not so high, so you can chose a not very low Ohms for these two resistors. Now you might lower your input voltage by this... but if the power source is a bug-converter you can use the voltage after the resistor for contoling the outputvoltage of your converter... so you will constantly have the same voltage behind the resistor. Might this work, or did a miss something?
Edit: Not the same resitor but similar range for the upper two resistorts... ahhhh it's too early.
If you have a fixed resistor load you can do many things like increasing the resistor. Most loads have various consumption and do not like large resistors in their supply line.
I have an acs712 monitoring 110v for over/under current to my greenhouse. Been perfect
Very good application. Thanks for the feedback!
You should have a look at a company called LEM, I thought they have a production plant in Switzerland. I also missed the distinction between open-loop and closed-loop hall based sensors.
I looked at their products. It seems to be a very special product for precision usage. The principle is interesting, but nothing for this channel.
I am already using the PAC1934 from Microchip in a few projects and it is much better in terms of performance than the parts demo-ed in the video. I think it is better to look for other options than whatever is available on AliExpress
Depends on what you want. The PAC1934 for sure is a capable chip. I assume, most of the maker projects do not need it. And not everybody wants to create a PCB just for measuring current. This is of course different in a professional application.
@@AndreasSpiess Yes, you're right. For most of the makers the AliExpress modules are probably more than enough. In my case, I am a bit reluctant to rely only on the AliExpress modules due to some bad experiences in the past (some of the AliExpress modules I ordered were using older, buggier revisions of a given chip, sometimes even faulty parts). I guess some of the old chip revisions can be bought fairly cheap by module makers in China.
As a maker, I always like to experiment a bit with parts which aren't yet available as modules. This helps me differentiate a bit. PAC1934 has a QFN variant which I soldered on a PCB adapter. Then, I was able to play with the part on the breadboard.
Great vid!! Though quick question as a newbie in this channel, As said in 21:34 what do you mean with "mains applications"?
Mains is another word for 110/220 AC
INA3221 measures current in both directions “Shunt voltage input” -163.84 to +163.84 mV
you are right. My mistake.
I need to measure the current drawn by a large brushed DC motor 180V 200W driven by a DC Thyristor drive. The rated current of the motor is low at 1.2A. In order to run the motor, DC Thyristor drive needs to be powered by AC mains, which then connects to the two leads of the DC motor. Can I place INA219 in between the drive and motor to measure current? or will it not work because of the high voltage involved?
Hi Andreas, do you know some chip option to measure current bidirectionally? I mean when a battery is charging and when the same battery is discharging. Thank you
Andreas, have you used the 10A range on your UT804 meter to measure fairly low currents? Mine shows 00.000A until I get to about 0.24A (AC if it matters). Once it starts showing a reading it seems to add 30-50mA to the actual current. The lower the current the more it seems to add. It also reacts to changes in current very slowly. I don't have a good way to test above 1.25A right now, but the added current makes less difference and seems to get less anyways. I am not sure if I have a defective unit or if they are all like this.
I just checked. Mine goes down to 10 mA. I did not test the accuracy, though. But it showed similar numbers than the power supply. So yours seem not ok. Or you method is wrong ;-)
@@AndreasSpiess Thanks for checking
Good video Mr Spiess! Those ACS sensors don't last. Even the more expensive 758. An even better way is a current shunt with ADC. :)
Thanks for the info!
I was really liking the WCS1800 to use as a current probe for automotive use but the lack of documentation I can find on the internet is so disappointing. I love your content BTW, very useful info on the ESP32.
Google found a data sheet with all needed info...
@@AndreasSpiess Ah, so it is! That's what I get for using another search engine. I see from the dimensions I can fit a 3 Gauge wire, that should cover everything but the battery cable itself, and I can make a test cable for that. Thanks Andreas, you go above and beyond the call of normal youtubers.
@@jjlebrams4421 Keep in mind: Just one wire goes through the hole. Otherwise the sensor will show 0...
@@AndreasSpiess Hey Andreas, just to let you know I bought one and connected it to a 10 bit AD I use with the ESP on its SPI bus. I've tested it out with the ESP's own current consumption on a 5V line and it leaves a little to be desired, mostly noise at those levels, but for high amperage it'll probably work much better. The ESP does intermittently draw over an amp when using wifi, which is consistent from what I've heard. It is pretty neat, I have the ESP connected to my cell phone via wifi and remotely turn it on and off and change the sampling/duration from the comfort of my chair. Again, appreciate all the info!
Last time a drill bit met my little finger, the outcome was not good.
Glad to see that this isn't always the case! 😂👍🍻🇨🇦
Drill bits and fingers are not a good team, you are right!
Any suggestion on how to measure current for a higher DC voltage, like for 170V nixie tubes running at ~6-30mA? TI has a design documentation using a INA138 with a virtual ground, but I'm wondering if there are other solutions especially since there seems to be some wasted watts using this design.
Maybe you try it on the low side? www.ti.com/lit/an/sboa190/sboa190.pdf
Just a note. For any one using max4080 you are going to need resistor and capacitor before sending it to analog pin of mcu. Otherwise your readings are going to be all over board.
Thank you for your information!
Have you done video on the ina3221 with two grounds? I have a few of them, but never used them before. Im hopping I can use just one per Meshtasic node to monitor solar panel V&I, battery V&I, and external 5v V&C source.
No, I did not do such a video.
1:40 what the hell ??!!!
You are right.
Europeans, well at least the Germans use U for volts, just like ,=. And .=,
Jose Vu
“U”stands for “Electrical potential” which is equal to Voltage.
To avoid misunderstandings in formula (like: V = 3.3V ) we use U instead of V.
We use V to pay homage to Volta. "U" is just weird. So was changing anything with "ss" into "B". The SS also stood up straight, you're lucky you weren't forced to bend over for the last 70 years. Oh wait.
@@sasha.djordjevic3071 problem is not in U but in X (I=U/R , not I=U*R)!1
5:16 could you just put your MC in parallel with the (load + Rsense)?
I do not understand why you would do that. Keep in mind, in my example, the MCU is also the load.
@@AndreasSpiess ahh, sure, that makes more "sense" now lol (pun intended) - I figured if you wanted to measure current through a (Load + Rsense) that you could install a current monitoring/voltage sensing MC in parallel to (Load + Rsense), but yes if your load happens to be the current monitoring MC, then you'll have problems as you've illustrated, lol. Thanks for the response, love the vids!
Yes Andreas, ACS712 module is completely junk for measuring High voltage AC specifically. Because I used that module to measure the power consumption of some electrical appliances and after a copule of week the sensor burnout(I don't know why and I had only 20watts of load at that moment) and high voltage AC passed through anolog pin and also completely damage my MCU as well.
That is what I meant when I said I would not use it in high voltage scenarios ;-)
Cool video, all in one place assembled.
Thank you!
9:59 shuldnt CMRR be big andsmall one, just ofset voltage?
I do not understand your question :-(
@@AndreasSpiess Its being said that both CMRR and offset voltage shuld be low. Shuldnt Common Mode Rejection Ratio be actualy high? Since in perfect op amp it is inifinite. Common singlas provide less distrubance in singals as CMRR is geting bigger and in this case we have to take them into consideration.
Ofset voltage shuld be low, as we want our signal to be as close to 0V as it can get when signal is 0V as well.
@@xsardas1999 CMR has to be high (because of its name rejection) It is more than 115dB on the INA169
@@AndreasSpiess Yes, that what i told. But in the video You states that is has to be low.
9:51 to be exact.
Thank you for the good video. The WCS1800 looks good for AC but beware of its 9mm diameter hall sensor...
Plus you cannot open this ring. So you had to detach then reattach wire somewhere. That’s precisely what we want to avoid on main!
You are right. But at least you do not have to cut it. Cutting is a no go here. Removing and re-attaching is not easy to prove
The hilarious hand pointer makes Andreas look like his left arm has a right hand on the end of it.
:-))
9:54 you mean the common mode rejection needs to be very high right?
I am not sure if it is exactly the same. But you are right: The common mode rejection has to be very high for these parts.
What would you do/use to sense if mains is on or off on a circuit? The current/power does not need to be measured. The goal is to sense if a teleruptor is on or off, with an arduino.
You could use one of those AC current sensors, for sure. I do not know if there is a simpler way.
@@AndreasSpiess thank you for your answer, I've watched many many many of your videos and did not expect you to answer! I expected the community to answer. Waw I'm perplexed you took the time! As to the solution, I'm looking to wrapping a wire around the mains wire and using a transistor array to amplify the inducted signal. See th-cam.com/video/cDuObAR42Nw/w-d-xo.html
I try to answer all comments. I probably will do a video about AC current measuring and cover the principle you mention.