Тёмный

Measure DC Voltage and Current with Arduino 

DroneBot Workshop
Подписаться 598 тыс.
Просмотров 196 тыс.
50% 1

This is the first of two videos on measuring voltage and current with an Arduino. In this video, we will be working with Direct Current.
Article with code samples: dronebotworkshop.com/dc-volt-...
More articles and tutorials: dronebotworkshop.com
Join the conversation on the forum: forum.dronebotworkshop.com
Subscribe to the newsletter and stay in touch: dronebotworkshop.com/subscribe/
There are many reasons why you might want to measure voltage and current using a microcontroller. You might want to measure the current consumption of your project, test the output of a solar cell or monitor the charging and discharging of a LiPo battery.
Voltage and current measurement are fundamental techniques, and so I’ve decided to do a couple of videos about the subject. In this first one, we will work with DC or Direct Current. And, obviously, we’ll be looking at AC in a future video and article.
Although I use an Arduino Uno in these experiments the principle of operation applies to pretty well any microcontroller.
We’ll start with DC voltage measurements, using the Arduino's analog to digital converter, or ADC. We’ll see how we can employ a voltage divider to increase the range of measurement, and how a precision external voltage reference can be used to improve accuracy.
Then we’ll move on to current, using both a Hall Effect and resistive sensor. That last sensor is pretty unique as it can measure both current and voltage at the same time, and it uses an I2C connection instead of the Arduino's ADC.
Here is what you'll find in today's video:
00:00 - Introduction
01:54 - DC Voltage Measurement Principles
05:35 - Basic DC Voltage Experiment
11:07 - Using an External Voltage Reference
14:49 - DC Current Measurement Principles
16:54 - Using the ACS712 Hall Effect Sensor
27:36 - Using the Adafruit INA219 Sensor
As always you can get the code I used and fined more information in the article on the DroneBot Workshop website at dbot.ws/dcvc
And in a few weeks I'll follow-up with a video about measuring AC voltage and current, so if you haven’t subscribed yet please join us so you don’t miss anything.
Hope you enjoy the video - now go out and measure something!

Хобби

Опубликовано:

 

9 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 244   
@Dronebotworkshop
@Dronebotworkshop 3 года назад
I missed a section on using the LM4040 when I assembled this video, however, it is in the article. Sorry about that!
@ogomah
@ogomah 3 года назад
excellent video, would he have a version with the Raspberry
@KirstyTube
@KirstyTube 3 года назад
@@ogomah The Pi does not have analogue inputs so would not work directly with some of these sensors. You would need an ADC / analogue to digital converter. I have moved from Pi Zero's as sensor devices to Arduino for this reason. I'm now moving again to ESP32 as they have built in WiFi / Bluetooth and analogue inputs :) had fun along the way so far and they are far cheaper to replace when the magic smoke escapes :)
@REALIVH
@REALIVH 3 года назад
you are also one bit to high with the ADC the 10 bit analog converter go from 1-1023 not to 1024. the formula is Decimal = (2^bit)-1 because it have to show 0 as well.
@satirthapaulshyam7769
@satirthapaulshyam7769 3 года назад
Can you do it for ac current measurement plzz, or suggest me some article or something like that.It's urgent
@olasyabrian7562
@olasyabrian7562 2 года назад
@@ogomah I had same issue, but then i used the arduino as a peripheral(slave) to raspberry pi(Master). Works Awesome!
@vishalkumar040393
@vishalkumar040393 3 года назад
I have wanted this for quite some time. Thank you very much for all the tutorials. I learned so much from you that I'm short of words to express how thankful I am.
@BarackBananabama
@BarackBananabama 3 года назад
Another great episode!
@capistor1
@capistor1 3 года назад
Great episode. Appreciate your hard work! Keep it going!
@tonybaceski7376
@tonybaceski7376 3 года назад
It's been said many many times before but I have to add myself to the long list of people who LOVE you videos! I own a few invasive meters for tracking my solar and wing turbine efficiency but I look forward to building my own with these modules. Also looking forward to the AC tutorial! Please never stop teaching us. You are a valuable resource.
@dcpowered
@dcpowered 3 года назад
Excellent! Just what i was looking for! Thanks, Bill!
@sandeepkapare
@sandeepkapare 3 года назад
Yet another amazing video. Your explanation is so easy to understand! The pace is also excellent. Keep us enlightening. Let the world be knowledge rich.
@paultakoy7091
@paultakoy7091 2 года назад
Fantastic tutorial. Keep up the great work. I am planning to incorporate this into my variable bench power supply.
@JonathanDeWitt1988
@JonathanDeWitt1988 3 года назад
Bill, This was another great video from you. I was really excited when I saw the topic this video was on. I've watched a video Robojax released on the topic a while back. But whenever you cover topics you tend to be more thorough in your coverage and expand my knowledge on the content. I had no idea what the external voltage reference pin was for. The increased accuracy was really good to know. And now I know how to use that Hall Effect sensor that came with a sensor kit I purchased a while back. Thank you very much for taking the time to make this wonderful video and share it with us all. Jonathan
@acestudioscouk-Ace-G0ACE
@acestudioscouk-Ace-G0ACE 3 года назад
A very useful video, thanks for all the effort you put into these, they are a great learning source.
@AmirASD
@AmirASD 3 года назад
Awesome as always
@Heppetronics
@Heppetronics 3 года назад
I was just making a data logger for voltage and current today. What a coincidence! Was encouraged to see the content of the video matches what I’m doing. Great video :)
@koushikkashyap439
@koushikkashyap439 3 года назад
I wanted exactly this for my PhD research. Thank you so much for this tutorial
@sumantakumardutta986
@sumantakumardutta986 3 года назад
Thank you for including the hall effect sensor in the video.😀
@willlockler9433
@willlockler9433 9 месяцев назад
I had to watch this one again! Years ago, I was more concerned with voltage. Recently, I needed to know more about current. Thanks for what you do. As a retired programmer I now play with the other side of the coin. Thanks!😊
@PhG1961
@PhG1961 3 года назад
Excellent video ! A job well done !!
@sasines
@sasines 3 года назад
Excellent video. Well done and easy to understand. Thank you.
@gazzacroy
@gazzacroy 3 года назад
just what ive been looking for cool :)
@AjaySingh-us6vl
@AjaySingh-us6vl 3 года назад
Thank you so much for this informative video, You explain so well, God Bless you and your Family.
@neail5466
@neail5466 3 года назад
Nicely explained 👏👏. As always
@prashantchoudhari2920
@prashantchoudhari2920 2 года назад
Exactly what i was looking for. Thank you so much.
@petercolls3385
@petercolls3385 3 года назад
Fantastic presentation - A lot of really good information - Thanks
@juankmilisimo
@juankmilisimo 3 года назад
Great video Bill. Thank you
@hommydc2
@hommydc2 10 месяцев назад
High quality videos, thank you!
@amnesie6615
@amnesie6615 3 года назад
Thank you for covering the INA219!!!! :)
@ramonestana7338
@ramonestana7338 Год назад
Thank you for speaking clear english. I am from Germany, but I uderstand nearly every word. And the content is brilliant too! Thanks again👍
@francospagnolo1385
@francospagnolo1385 Год назад
Thank you, your communication on the specific topic is very clear and exhaustive. Bye
@casemodder89
@casemodder89 3 года назад
Excellent video - like every single one is. As i'm a non nativ english speaker i often get better information from your videos then from the ones in my native language 👌😎 thanks a lot !
@johnpaulpineda9821
@johnpaulpineda9821 3 года назад
Thank You! for this Master Bill. This is very helpful to me.
@electronic7979
@electronic7979 3 года назад
Very helpful video 👍
@weavingandmore...4607
@weavingandmore...4607 3 года назад
Excellent as usual ☺️ thank you.
@MrDave9111
@MrDave9111 3 года назад
Excellent presentation!
@stefstaf
@stefstaf 3 года назад
Great demonstration as always. Thank you! Also I didn't realise that if you are using discreet resistors instead of the voltage sensor, it makes a difference which end of your resistor array connects to the positive of the source and which end connects to the ground. Reading your article was explained much better.
@railcat7083
@railcat7083 2 года назад
Very useful presentation. Thank you!
@hatzisn
@hatzisn 3 года назад
Great video. Thanks.
@abedoubari
@abedoubari 6 месяцев назад
Great explanation... Keep up the good work 👍
@place910
@place910 2 года назад
Everytime I start a new project, I find a vid you've made :)
@jj74qformerlyjailbreak3
@jj74qformerlyjailbreak3 3 года назад
Another Great One ☝️
@RobertNgambi-bk8ff
@RobertNgambi-bk8ff 5 месяцев назад
this is well explained. Great 👍
@net6147
@net6147 3 года назад
Thank You very Informative, Always great presentations
@engineerlawalhamzatademola4267
@engineerlawalhamzatademola4267 2 года назад
I've been looking around but....not satisfied but when I played this video randomly and heard you voice I became happy 😁 and I'm sure I'll find all I'm looking for concerning this topic. Thanks for the tutorial sir 👏
@pd8559
@pd8559 3 года назад
Thanks to you I got my first three ESP32s and those Sunfounder 5 breadboards for $10 is amazing price on Amazon. Putting the two short boards side by side and connecting them with the power rails still attached makes the width across the two power rails the Perfect size for putting the ESP32-WROOM-32D DevKitC v4 boards across. Pins line up perfectly. Passing on the tip. Digital output from ESP is 40 mA so looking at dropping that to Arduino 20 mA levels to interface the two. Arduino defaults to 1024 values on ADC but most will support manually setting it to 4096 values if you really need that resolution.
@m.anwrs59
@m.anwrs59 3 года назад
very nice explanation prof
@padcom
@padcom Год назад
GOLD! Thank you!!!
@angryalliance4958
@angryalliance4958 3 года назад
Great Work Sir👍
@tvnsi8556
@tvnsi8556 3 года назад
Thank you! Couple of days I’ve got necessity of measuring current and voltage using arduino.
@neobikes
@neobikes 3 года назад
Staring contest winner :) goood video as always!
@ibanix2
@ibanix2 3 года назад
Excellent! I've had a projects in mind that need voltage/current measuring.
@superuser7545
@superuser7545 3 года назад
Hi, you can use an homemade shunt you measure precisely and then calibrate using a variable load (eg. 0.15 ohm, and have the load downstream. You can achieve decent accuracy when using avr 1.1 volt internal reference and the voltage drop is greatly acceptable. The range is 30mA to above 2000 mA For the voltage, just do a resistive divider adapted to your voltage.
@avejst
@avejst 3 года назад
Interesting as always👍 I would have liked to see the amp meter (instrument) in the last test too Thanks for sharing your knowledge to all of us👍😀
@wclugston
@wclugston 3 года назад
Thanks for covering DC current measurement! I need to setup an Arduino circuit in my RV that checks to see if someone left the water pump running. If the water pump has been running for more than 15 minutes I want the Arduino to break the circuit. Current measuring and relay (normally closed) with the Arduino should do the trick.
@inlywang8157
@inlywang8157 3 года назад
great tutorial
@pd8559
@pd8559 3 года назад
Awesome video as always. Cannot wait until you get your hands on the ESP32-C3-DevKitC so we can see what this new module has on offer!
@scamper_van8470
@scamper_van8470 3 года назад
i did subscribed and thank you.
@bluehornet6752
@bluehornet6752 3 года назад
To make this code more efficient, before the setup() method but after R1 and R2 are defined, do this: constexpr float resistance_ratio = R2 / (R1 + R2); This will cause the compiler to do the math for you, so there's no penalty at startup. Then, in the loop: in_voltage = adc_voltage / resistance_ratio; This may well save a couple of operations in each iteration of the loop: The addition of the two resistance values, and (more importantly) the division operation involved in finding the resistance_ratio. Since there's no floating point unit on the Arduino, any floating point operation you can eliminate will be a good thing. Note that it's entirely possible that the compiler will have noticed you're doing this operation each time through the loop and optimize it for you automatically--but unless you examine the assembly code you won't really know.
@UserName-cb6jz
@UserName-cb6jz 2 года назад
This is why we have the comments section, to get useful suggestions to great videos. 👍🏻
@AlienRelics
@AlienRelics 3 года назад
4:12 A correction: A voltage divider will decrease the input impedance. The input impedance of the ADC is extremely high. For a voltage divider to be accurate, it must be much lower in resistance than the input resistance of the ADC. Certainly in this case, it is MUCH lower. I find it a good idea to insert a resistor between an external reference voltage and Aref. The reason being, when the microcontroller is first powered up, Aref is connected internally to Vcc until your setup alters it.
@phildavis1723
@phildavis1723 3 года назад
I have been wanting to build an accurate wattmeter for audio speakers for AGES, so an AC version of this video would be VERY COOL...
@garycotz563
@garycotz563 3 года назад
Excellent topic... this is always a challenge especially current over time... and graphing it. Also, charging up Lithium batteries using these tools would be awesome since you can control the cut-off point in time per the readings to get many batteries "topped off" at the same values.
@noweare1
@noweare1 3 года назад
Use a timer and take a measurement every x seconds and use an sd card for storage.
@emadabuhagag222
@emadabuhagag222 3 года назад
helpful, thank you
@amrishhirani6096
@amrishhirani6096 3 года назад
Thank you 👍
@Djkadiross
@Djkadiross 2 года назад
Hello, Thank you for this great video. Is it possible to appear V and A at the Same time on an Oled display ? Thank you 😊
@tinkmarshino
@tinkmarshino 3 года назад
AGH! what an idea for a dip switch.. makes me feel like a troglodyte .. Shine on brother! This was a good one for me.. it seems you always cover projects I am thinking about doing.. Carry on!
@lucvanhove9639
@lucvanhove9639 3 года назад
Very good training. I only had bad experience with PIC microcontrollers if I need to take measurements lower than 200mV. It works still works but it is non linear comparing with the higher measure till 5 volt, who are the same result as the Voltmeter Fluke or R/S. External reference and 12 bits controllers gives me the same results. So the low site of the A/D converter is non linear. I like some comment on this.
@BULPIN847
@BULPIN847 2 года назад
I'm trying to build a device that will turn on my well pump from my solar panels. That would sense Peak voltage and run the pump for a certain amount of time, and then divert and split the power back to 36 V to charge my lipf po 4 batterie pack. The well pump runs on 120 volts, with the solar panels in series. 300w solar panels, 36 V. But I need the amperage to charge the batteries, and run the 4 solar panels parallel while charging batteries. I believe many people need this system, keep your well pump from coming on randomly over and over again which wire's out the well pump. Thanks for your great videos especially these days very useful for off-grid. Still looking to make a lifep04, lithium BMS from Arduino. Once again thanks bro awesome teaching thank you
@jdk8787
@jdk8787 3 года назад
Thanks for the video. Very helpful. What discrete resistor values (for the resistor array) do people suggest when measuring battery voltage, for a battery powered Arduino project? I had a datalogging project in the past. When the rechargeable 9V battery died the datafile would almost always be corrupted and I lost all the data. I tried to get the power as low as I could. And I ended up adding two 10kOhm resistors for a voltage divider, read the voltage in between them, and programmed the Arduino to stop logging before the voltage got too low. It worked, but I wondered if higher resistor values would work better to reduce the current draw of the two resistors even more. So I was curious what other people used.
@philippecorbel7365
@philippecorbel7365 3 года назад
Great video, thaks a lot. next step is to calculate Ah and Wh, Thanks
@hacklabdesign
@hacklabdesign 5 месяцев назад
If I have a 3 V coin battery that lights a light, how can I make a check to see if there is voltage and make a counter of how many times the light comes on and off. So basically, it would track the amount of times the flashlight was turned on and off and the duration it was on.
@rangorali5310
@rangorali5310 2 года назад
Great video!! Can I use those current measurement methods to measure the current between two electrodes attached to random object?? in my case, i need to measure the current between two points on a leaf.
@Jayme
@Jayme 2 года назад
So have you made the second video yet? I'm very interested on the AC side of this.
@patrickgemayel4326
@patrickgemayel4326 2 года назад
Thanks!
@Dronebotworkshop
@Dronebotworkshop 2 года назад
And thank you as well Patrick
@bobvines00
@bobvines00 3 года назад
Bill, this is yet another "thumbs up" video and I'm looking forward to Part 2. Also, could you set your future videos to have (automatically generated English) closed-captions? I wasn't able to turn them on due to no "CC" at the bottom of the window.
@andyalexander8064
@andyalexander8064 3 года назад
Great content. Could this be set up to work as a power monitor for a drone, going into a Pixhawk 4? Not sure how to send that info to the FC, and would it keep track of the total usage? I'm thinking for use as a battery failsafe. Thanks.
@yryskeldianarbekov4756
@yryskeldianarbekov4756 3 года назад
well hello and welcome to the workshop
@m0nad539
@m0nad539 3 года назад
Nice vid, thanks! Small note: at 23:38, you do not divide by 1000 because you want millivolts, but rather to get the average of the 1000-sample accumulation from the loop before.
@tonybell5043
@tonybell5043 3 года назад
I was going to mention the same thing but I just happen to check if anyone else posted it too!
@ravindupramod5998
@ravindupramod5998 3 года назад
Nice video😍 Could you please make a video about how to make menu system for oled display!☺️
@ErikThiart
@ErikThiart 3 года назад
Can you explain the 1000 loop on the hall effect sensor, I don't understand from that loop how you get the average?
@josephdada8434
@josephdada8434 3 года назад
Thank you very much for this nice tutorial. Please I need your help, I need circuit diagram with values on how i can measure current from (with AC712 and Arduino) a solar panel without load. Because the load with not allow me to know the main current generated by the solar panel.
@chilledturnip3800
@chilledturnip3800 2 года назад
Please can you explain what you mean when you said the ADC will not "load down" the circuit it's measuring when increasing the input impedance?
@onienav
@onienav Год назад
This video was really helpful! Although I have a question, my current output is giving -0.12 Amps with no load... but when I use a LED diode it went up to -0.05 Amps. is this due to the small current that its reading that's why its in the negative?
@stuffoflardohfortheloveof
@stuffoflardohfortheloveof 2 года назад
Brill! 🙂👍🏴󠁧󠁢󠁷󠁬󠁳󠁿
@SystemsPlanet
@SystemsPlanet 3 года назад
20:09 I thought a hall effect sensor wrapped around a wire to measure magnetic field. How can this be non-intrusive when it's connected directly to the wire?
@vameza1
@vameza1 2 года назад
Hello, great video!!! I tried to find the AC measurement video...did you do that??? Thank you for the reply and congratulations!! Cheers from Brazil!!
@eugy2008
@eugy2008 3 года назад
Informative video. But I have a question. If current sensor reads out both current and voltage why bother using voltage only sensor? Just curious, why did you need a lantern for a load? Could you just measure a current going into your mcu?
@cjones4433
@cjones4433 3 года назад
Thank you for this video! I was searching for a highly accurate volt meter and the external voltage reference was just the ticket. I do have two questions though. A) how accurate is the ina219. The reason I want an accurate volt meter is I am using it to check battery cells while they charge and to shut the charger off when the batteries reach the desired voltage. B) Since the ina219 uses scl and sda how can I attach an external display such as a ssd1306? How do I change the addresses so they don’t conflict? Thanks again. A brilliant job of explaining arduino voltmeter!
@harryohanson
@harryohanson 3 года назад
I am looking to add a volt and amp meter on my bike to monitor the charging system on OLED. How would you go about doing that? Thank you for the help!
@quillaja
@quillaja 3 года назад
I want to made a 'battery monitor' for my van's 12v house system. My current plan is using an esp32 board and INA260, both from adafruit. The INA260 supposedly has a maximum current capacity of 15A, and my maximum load (with all lights on, heater on, etc) could be about 15A or a little more. I'm wondering if there are any devices like the INA260 but with higher capacity? Or can I use a higher capacity shunt inline, and then use the INA260 to read the voltage drop across the shunt and then calculate current. I'm pretty new to this 'hardware' stuff, this being my first time experimenting with microcontrollers, and I'm slowly reading "Practical Electronics for Inventors" by Scherz and Monk. Your videos have also been a great help for me understanding this new realm.
@manavt2000
@manavt2000 3 года назад
Please continue making videos on esp32...I love your videos....how to control different sensors, dc and stepper motors with esp32 wifi and bluetooth
@aeb5307
@aeb5307 3 года назад
Gracias.
@taranagnew436
@taranagnew436 3 года назад
what do you use the AREF pin for, what does it do and if I have a solar cell powering my weather station could I hook up another set of wires to attach to the sensor?
@josphat.Karanja
@josphat.Karanja 2 года назад
Great Lesson on Analog and Digital Pins, can you do a video on UART/JTAG
@richardomonuwagbale2318
@richardomonuwagbale2318 Год назад
Thank you for this great video. Can you do a video for measuring the temperature of the battery?
@solomwanza
@solomwanza 2 года назад
hello, great work. how can we meausure power factor using current sensor?
@poorboybmx2511
@poorboybmx2511 3 года назад
Super video's, excellently explained topics👍 For some reason my notifications keep turning off on your channel, most annoying, I would hate to miss anything.
@surajmusmade7056
@surajmusmade7056 3 года назад
can i use AC curruent with DC load for ACS712 to measure curruent
@pd8559
@pd8559 3 года назад
Raspberry released their very first Microcontroller, the Pico I think they call it. To me it was less interesting than ESP32 but you might want to cover it. Seems like a non wireless microcontroller with a massive amount of ram but that’s all it seemed to me on cursory look to have going for it. To me microcontroller doesn’t need heaps of ram and I’d be interfacing to raspberry pi zero w wireless microcomputer if I need the big boost on processing power and ram while letting the microcontrollers do what they do best with their strengths of always on and instant or near instant execution of programming.
@sam-kx3ty
@sam-kx3ty 2 года назад
fr the INA219 could we attach the Vcc to a solar panel to get both voltage and current readings ?
@marinuspretorius8230
@marinuspretorius8230 2 года назад
What in the follow up video you mention in this video?
@ShrinivasSaindar
@ShrinivasSaindar 3 месяца назад
I want to sense micro amp current which is best for it.
@vechnyak
@vechnyak 3 года назад
What if I already have a shunt in my dc circuit. Could i use INA to read voltage drop across that instead of its internal resistor?
@venkatyalamati3285
@venkatyalamati3285 Год назад
Thanks for the tutorial with such an excellent quality content... I want to make a DC voltage measurement circuit for measuring and auto logging the cell voltages (will be in the order of 1.2V) of a big battery set to an SD card.. But the problem is, how to tackle the negative input (bcz the person who takes the measurements will reverse the probes between positive and negative terminals of cells) - plz tell me any solution
@VASGENR6DJF
@VASGENR6DJF 3 года назад
Cool
Далее
ДВЕ МЕДИЦИНЫ В ОДНОЙ СТРАНЕ
43:03
Is it impossible to cut off so much?💀🍗
00:14
Просмотров 949 тыс.
Different Ways for Measuring Current With Arduino
13:32
How-to: Accurate Voltage Measurements with Arduino
12:15
How to Make a Shunt Current Sense Resistor
11:17
Просмотров 2,3 млн
Милая мебель для котов
0:27
Просмотров 2,4 млн
Косички из морковки 🥕
0:40
Просмотров 7 млн
Гениальная реклама от Volvo.
1:01